Data Structures and Algorithms Last-Minute Revision
Quickly revise the questions you picked. Add questions from the interview-questions lists with Save to → Last-Minute Revision.
30 quick revision notes for Data Structures and Algorithms
- Big-O gives an upper bound on growth; drop constants and lower terms, so 3n squared plus 5n is O(n squared).
- About 10 to the power 8 simple operations run per second, so for n up to 10 to the power 5 aim for O(n log n).
- Amortised O(1) append in dynamic arrays comes from doubling capacity, so total copying over n appends stays under 2n.
- Every recursive function needs a correct base case; deep recursion can overflow the stack in Java and Python.
- Master Theorem: merge sort T(n) = 2T(n/2) + n is O(n log n), and binary search T(n) = T(n/2) + 1 is O(log n).
- Two pointers and sliding window turn many O(n squared) array and string problems into O(n) solutions.
- Prefix sums answer range sum queries in O(1) after O(n) preprocessing; a hash map of prefix sums counts subarrays with sum k.
- Hash maps give average O(1) operations, but poor hash functions or many collisions can degrade them toward O(n).
- Kadane's algorithm finds the maximum subarray sum in O(n) by choosing to extend or restart at each element.
- Floyd's slow and fast pointers detect a linked list cycle in O(n) time and O(1) space.
- A dummy node before the head removes special cases when the head of a linked list may change.
- Monotonic stacks solve next greater element and histogram problems in O(n) because each element is pushed and popped once.
- A queue built from two stacks gives amortised O(1) dequeue because each element moves between stacks only once.
- Inorder traversal of a binary search tree returns keys in sorted order.
- BST operations cost O(h); balanced trees keep h near log n, while sorted inserts into a plain BST make it skewed.
- Validate a BST by passing lower and upper bounds down the recursion, not by comparing only with children.
- Tries search a word of length L in O(L), independent of the number of stored words.
- Building a heap from n elements takes O(n), while each insert or extract costs O(log n).
- Use a min-heap of size k to find the k largest elements in O(n log k) time.
- Greedy works only with the greedy choice property; test small counterexamples before trusting a greedy rule.
- BFS finds shortest paths in unweighted graphs; Dijkstra handles non-negative weights; Bellman-Ford handles negative weights.
- Topological sort exists only for DAGs; if Kahn's algorithm outputs fewer vertices than the graph has, there is a cycle.
- Union-Find with path compression and union by size gives nearly constant time per operation.
- Kruskal's MST sorts edges and uses Union-Find, while Prim's grows the tree with a min-heap.
- Dynamic programming needs overlapping subproblems and optimal substructure; define state, transition, base case and order.
- 0/1 knapsack in one array iterates capacity downwards; unbounded knapsack iterates capacity upwards.
- LCS and edit distance use an m by n table and can be reduced to O(n) space using two rows.
- Comparison sorts need at least n log n comparisons; counting and radix sort beat this for small integer ranges.
- Use low plus (high minus low) divided by 2 for mid in Java to avoid integer overflow in binary search.
- Binary search on the answer works whenever feasibility is monotonic, such as minimum capacity to finish within D days.
Night-before checklist
- Revise your saved questions on this page once, aloud.
- Read the quick notes and mark any you cannot explain in one line.
- Rehearse a two-minute self-introduction and two project stories.
- Keep CV, ID, laptop charger and interview link ready; sleep on time.
Frequently asked questions
How does Last-Minute Revision work?
On any question page, open Save to → Last-Minute Revision. Saved questions appear here with their answers, so the night before an interview you revise only what you found hard.
Is my list saved?
Yes, in this browser. Guests can save 5 questions; free accounts can save 20 for revision and 100 for the 7-day plan.
What should I revise last before a Data Structures and Algorithms interview?
Your saved misses first, then the quick notes on this page, then one or two project stories. Avoid learning brand-new topics the night before.
Find questions to save
Company-wise Data Structures and Algorithms questionsExperience-wise Data Structures and Algorithms questionsRole-wise Data Structures and Algorithms questionsCity-wise Data Structures and Algorithms questionsMost asked Data Structures and Algorithms questionsScenario-based questionsPractical / hands-on questionsHR & behavioural questionsData Structures and Algorithms mock interviewOnline assessment questionsTechnical round questionsManagerial round questionsData Structures and Algorithms topic sheets