Skip to main content

Posts

An Idea- Just an Idea

An idea came to me today: let's talk about how to get ideas!  What should be the thought process when we are thinking of an idea.  We all want to make an impact and we all got some great ideas, some of us even take action to complete them, but only a small fraction of us actually succeed in making an actual impact. Let's see some of the rules we should follow: Write down everything! First and foremost, always have a pen and paper while brainstorming about the idea.  Think of the problem first, not the solution! Next, just think of the problems you are facing and how your idea is gonna be helpful for you. And the best part is, many great ideas are revolving just around you, you have to identify your problems and they should be the actual source of the idea.  Next, always think of a simple way out of the problem. Nowadays people are really smart and would only use your product/app/website if they feel that a great need. Making them pay for it is far more difficult. So,...

Path Finding Algos

 Breadth First Search(BFS) Breadth first search's principle is quite simple, traverse level by level until we find the destination. Now, in a grid system we can traverse by making a radial expansion having center as the source cell. So you may see such visualization which is quite self explanatory. But how do you implement that? Algorithm: 1. Make a queue and push the source vertex in it.  2. while(q.length!=0) Pop the element from stack check if any of points  (x+1,y), (x,y+1),(x-1,y) and (x,y-1) are destination vertex. If yes: return If no: push  (x+1,y), (x,y+1),(x-1,y) and (x,y-1) into stack. Code:  class QItem { public : int row; int col; int dist; QItem( int x, int y, int w) : row(x), col(y), dist(w) { } }; int minDistance( char grid[N][M]) { QItem source( 0 , 0 , 0 ); // To keep track of visited QItems. Marking // blocked cells as visited. bool visited[N][M]; for (...

Sorting Algos

 Bubble Sort This is the most simple sorting algorithm. Just swap adjacent elements until the array is sorted. Like we have to traverse whole array n-2 times and in each traversal we have just this condition: check if the the left node is greater than right. If yes, just swap them. Time Complexity(Average, worst, best)= O(n^2) code(in C++): for (i = 0 ; i < n - 1 ; i ++ ) // Last i elements are already in place for (j = 0 ; j < n - i - 1 ; j ++ ) if (arr[j] > arr[j + 1 ]) swap( & arr[j], & arr[j + 1 ]); Insertion Sort Another Simple and intuitive algorithm, yet an efficient one. Its just the way we normally sort as "normal" humans. Suppose we are at some position of array, i, what we do is to take the element at the i th card and then swap it with the element it should be to make the array before i position ,sorted.  Time Complexity:  O(n^2)(Average and worst)  O(n)(Best case)(When array is alr...

STL

STL: Standard Template Library(C++ Only) As you may have seen vectors now in Arrays, you might be wondering about more such amazing pre-defined data structures and methods. So here is a list of all such "magical containers" STL has to offer and when and how to use them. Introduction to STL: (All misconceptions) STL: Standard Template Library. STL is a library that gives us many predefined functions and "containers" to make our life much easier!  See, many of you now would be wondering: If there are such magical containers, then why learn things like linked lists and all which are quite difficult to understand and implement. Also, is using STL recommended, or is it just a "quick fix".  First of all, STL is not at all "magic". Every container is made by the creators of this library and we can and should use it to make code look a lot cleaner and easy to both understand and write. Secondly, the theory of ...

Stacks

Stacks: One Stop CONCEPT: Stacks are linear data structures with a simple idea: just stack the elements! You can think of it as a pile of books stacked over each other(as a very trivial example). And you can only take books from the top, and if you want to take book at a any other position you would have to take the books up to that one out and then only you can reach that book(I know you can directly pull that off, but lets consider that is not an option).  Application Stacks are very powerful if used in a smart manner. Like think of it you can add to top in O(1) time, remove from top in O(1) and access to top in O(1). Moreover they are used with loops to solve quite difficult problems like bracket matching, post-fix to prefix and vice-versa. Real world applications are doing undo and redo (just think of it!),browsers for going to previous URLs, and much more.  There are just these four operations in stack: Push: Push an element to the top(Inserting element at top) Pop: Pop ...

Ultimate Roar

So, I was just looking at my blogs I wrote 2 months before, and specifically the college plans blog. That time, I thought it would be wise to analyze my goals and gear up that way but now I think that making a long term plan doesn't work for everything. It may be good for an organization, but for an individual, or should I say a very volatile individual like me, it just ends up like a mess. And now I have this one important life lesson today: Be in a hurry, always. Now this might sound a little controversial but I think life is short and we gotta hurry. I don't want any of my ideas not being implemented, or any sense of guilt and that's why I am really really afraid of being stagnant. So, I would list down some short goals which I think can level my technical skills, problem solving skills and communication skills. So, for technical skills, I would be learning some frameworks in web and complete the ideas I have(which are mostly startup ideas). The number one in list would...

Life getting overly Simplified

 The last post included the things I have to do, but this one, this one is going to be simple and straight forward:- what I want with my life. I have seen many people taking important life decisions vaguely without much thinking and mostly following others. I have done this too. I had no idea about Coding, still jumped into it. And now, I find it a nice decision by chance.  I have some simple personal projects which are definitely not brilliant ideas but yeah, you can have a good impact with them. And most importantly learn from them. And I am getting better at hunting ideas and implementing them too. But still, there are many things I got to do: Improving my GPA which is currently 7.25, Improving rating on codeforces which is currently 1280, and on codechef, which is around 1700. As these are just numbers, I don't are that much about them. But a god idea at this point of time would be to become famous and posting good things on linkedin and promoting game of codes, guruji pra...