Skip to main content

Posts

Showing posts from 2020

Trees Pt I

Trees: All Branches One place Trees are hierarchal data structures built to store information that is connected to each other. As the name suggests, it is a tree, just upside down that stores data in its leaves and connected through branches .  So, this was the introduction, now let's see what we gonna cover in this blog: Applications of trees Binary Trees Traversals Some Trivial Questions The diameter of a binary tree LCA of Binary Tree Questions(Trivial) This is all we gonna cover. This part is not that much tough, but it's likely to get a little frustrating when it comes to trivial questions. (At least for me 😢 )

Important Hackathons and Coding Contests

I thought it would be the right time for juniors and second years like me, to have some important dates in hand instead of just Mirzapur season release dates. So these are some sites, some annual hackathons, which I researched, and have compiled for you all, also, it includes some internships as well. So, get yourself some pen and paper, and let's start: Hackathons: Some important sites which conduct hackathons: Devfolio Devpost MLH Hackerearth https://www.hackathon.io/network http://www.hackalist.org/ Some important hackathons which occur annually: SIH Some important open source programmes GSOC

Number theory Pt II

The Return of Number Theory  We covered in the First part: Primarily Test Prime Factorisation Sieve of Eratosthenes Binary Exponentiation Euclid's Algorithm for GCD Number of divisors/sum of divisors Segmented Sieve We would cover: Modulus Operations Binomial Coefficients Extended Euclidian Algorithm Diophantine Matrix Exponentiation Fibonacci in O(log(n)) Chinese Remainder Theorem Euler's Totient Function And these are the methods which we would cover only in theory, no questions in the fight: Pollard p-1 Pollard rho algorithm Modulus Arithmetic: Before jumping to the formulas for addition, subtraction, etc., firstly, let's have a look at what is M odular Congruence. Modular Congruences: a and b are modular congruent under n if they give the same remainder on dividing by n. Representation: a  ≡ b(mod n)   What that means is that wherever you are given a%n, you can replace it with b%n and it would have no impact no final answer, for example,  9=13 mod 4 (12+9)%4=21%...

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...

Life is getting Complicated

 Okay, now as my life is getting a bit complicated, I should now straighten things up and simplify them a bit. So, here are the things that are occupying my time: Competitive Coding: Codechef Long Challenge Practicing on Codeforces GFG Course  Web Development Game of Codes Path finding Visualiser Training Zone Topic wise CodeBlast Training Zone level Wise  A new Awesome Idea Voice Recognition Text to speech UI  Learning New Things React Node/MERN IDEAS Impelementation Document Management System Android      Guruji Pranam Game of Codes         Volunteership Coding Contest  College Studies DM DS PS MIII  Wasting Time on youtube  After listing them up, they seem very few and I can manage them quite cleverly. First of all, most time is being eaten by random youtube videos, So a max of one hour per day. For Competitive Coding: Codeforces: - hours per day CodeChef: 3 hours per day(in with codeforces) GFG: 2 hours Web ...