Algorithms Topic Wise: Study Order, Notes and Practice Links

Algorithms Topic Wise - CodingHumans

When I started learning algorithms, the hardest part was not any single topic. It was knowing what to study next. This page is the order I would follow if I were starting again, with a short note on each topic and links to the tutorials, solved problems and MCQ sets on CodingHumans that go with it.

You do not need to finish one section perfectly before moving on. Read the note, solve two or three problems, try the MCQs, and come back later. Most of this clicks on the second pass.

1. Analysis of algorithms

Before comparing algorithms, you need a way to measure them. Big-O notation describes how the running time or memory grows as the input grows. An O(n) loop over a million items is fine; an O(n²) pair of nested loops over the same input is a trillion steps and will time out on any judge.

ComplexityExampleRough limit for n in 1 second
O(log n)Binary searchPractically any n
O(n)Linear search, one pass over an arrayAbout 108
O(n log n)Merge sort, heap sortAbout 106 to 107
O(n²)Bubble sort, checking all pairsAbout 104
O(2n)Trying every subsetAbout 25

2. Searching

Linear search checks items one by one and works on any list. Binary search halves the range at every step, so it needs only about 20 comparisons for a million items, but the data must be sorted first. Binary search also shows up in places you would not expect, such as finding the smallest speed or capacity that satisfies a condition.

3. Sorting

Learn bubble, selection and insertion sort to understand the idea of swapping and shifting, then spend real time on merge sort and quick sort, because they teach divide and conquer. In practice you will call the library sort (Arrays.sort, std::sort, sorted()), but interviewers still ask how these work, which ones are stable, and why quick sort can fall to O(n²).

4. Recursion and divide and conquer

A recursive function solves a problem by calling itself on a smaller version of it. Always write the base case first, then make sure every call moves towards it. Divide and conquer is recursion with a plan: split the input, solve each part, then combine. Merge sort, quick sort and binary search all follow this pattern.

5. Greedy algorithms

A greedy algorithm makes the choice that looks best right now and never goes back. It is fast and simple, but it only works when you can prove that the local best choice leads to the overall best answer. Activity selection, Huffman coding, and Kruskal's and Prim's minimum spanning tree algorithms are the classic examples. Coin change with arbitrary coins is the classic case where greedy fails.

6. Dynamic programming

Dynamic programming is for problems where the same smaller problems come up again and again. Instead of solving them repeatedly, you store each answer the first time. The plain recursive Fibonacci makes about 2n calls; with memoisation it makes n. Start with Fibonacci, climbing stairs and coin change, then move to knapsack and longest common subsequence.

7. Graph algorithms

Graphs model anything with connections: roads, friends, web pages, task dependencies. Learn to store a graph as an adjacency list, then BFS (shortest path when every edge has the same weight) and DFS (cycles, connected components, topological sort). After that, Dijkstra for weighted shortest paths and Kruskal or Prim for minimum spanning trees.

8. Backtracking

Backtracking builds a solution step by step and undoes a step as soon as it cannot lead anywhere. N-Queens, Sudoku, generating permutations and subset sum are the standard problems. It is still exponential in the worst case, so the skill is in cutting off bad branches early.

Data structures you will need along the way

Algorithms and data structures go together. A good choice of structure often turns a slow solution into a fast one, for example using a hash set to check membership in O(1) instead of scanning a list.

How to practise

  • After reading a topic, solve problems without looking at the solution for at least 20 to 30 minutes.
  • Write down the time and space complexity of every solution you submit. It becomes a habit quickly.
  • When you look at a solution, close it and write the code again from memory the next day.
  • Use the MCQ sets to check theory before exams like GATE. The GATE CSE algorithms set is a good test once you have covered sections 1 to 6.

For everything else in one place, see the Interview Preparation Hub and the coding problems and solutions hub.

Comments

Answered 0/0Correct 0