InterviewStack.io LogoInterviewStack.io

Fundamental Algorithms and Techniques Questions

Covers core algorithmic concepts and problem solving patterns commonly assessed in technical interviews. Topics include searching algorithms such as binary search; sorting algorithms such as merge sort and quick sort; graph traversal methods such as breadth first search and depth first search; recursion and divide and conquer techniques; greedy heuristics; and dynamic programming including memoization and tabulation. Also includes implementation patterns such as two pointers, sliding window, prefix sums, and divide and conquer composition, as well as practical considerations like in place versus out of place implementations, stability for sorting, recursion stack and memory usage, and amortized analysis. Candidates should be able to implement these algorithms correctly, explain correctness and trade offs, analyze time and space complexity using Big O notation for best case average case and worst case, select appropriate approaches given input constraints, combine patterns to solve composite problems, and optimize or refactor solutions while handling edge cases.

HardTechnical
0 practiced
Explain quicksort's worst-case behavior and describe the median-of-medians pivot selection algorithm that guarantees linear-time selection and prevents worst-case degeneracy. Discuss implementation trade-offs: why median-of-medians guarantees O(n log n) sorting but has practical overhead compared to randomized pivoting, and when you'd choose one over the other.
MediumTechnical
0 practiced
Implement Disjoint Set Union (Union-Find) in Python with path compression and union by rank/size. Provide functions find(x), union(x,y), and connected(x,y). Explain amortized time per operation (inverse Ackermann), and show an example use in finding connected components in an undirected graph, such as grouping similar image pixels.
MediumTechnical
0 practiced
You're building a model pipeline where certain preprocessing tasks depend on others. Implement in Python a function that takes a list of dependency edges (A -> B means A must run before B) and returns a valid topological ordering or detects a cycle. Use Kahn's algorithm, analyze time and space complexity, and describe how to adapt it to streaming or incremental graph updates.
HardTechnical
0 practiced
Explain divide-and-conquer DP optimization techniques such as divide-and-conquer optimization and Knuth optimization. Provide a concrete DP example where such optimization reduces complexity (for instance, DP partitioning problems with quadrangle inequality) and enumerate the preconditions required for the optimization to be valid. Describe how complexity is reduced and what invariants you must verify.
EasyTechnical
0 practiced
Given two sorted arrays A and B where A has size m+n and contains m valid elements followed by n empty slots, implement an in-place Python function to merge B into A to produce a single sorted array. Explain why merging from the end is efficient, analyze time and space complexity, and describe how you would handle the case where A does not have extra space available.

Unlock Full Question Bank

Get access to hundreds of Fundamental Algorithms and Techniques interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.