Data Structures & Algorithms

Must-know CS concepts for technical interviews and beyond.

12 cards Ā· by @demo
Log in to clone
Front

What is Big-O notation?

Back

A mathematical notation describing the upper bound of an algorithm's time or space complexity as input size n grows. E.g. O(1) constant, O(log n) logarithmic, O(n) linear, O(n²) quadratic.

Front

What is a hash table?

Back

A data structure that maps keys to values using a hash function. Average O(1) for insert, lookup, and delete. Collisions handled by chaining or open addressing.

Front

Difference between a stack and a queue?

Back

Stack: LIFO (Last In, First Out) — push/pop from the top. Queue: FIFO (First In, First Out) — enqueue at back, dequeue from front.

Front

What is a binary search tree (BST)?

Back

A binary tree where each node's left subtree contains only values less than the node, and the right subtree contains only greater values. Average O(log n) search.

Front

What is Dijkstra's algorithm?

Back

A greedy algorithm to find the shortest path from a source node to all other nodes in a weighted graph with non-negative edges. Time: O((V+E) log V) with a min-heap.

Front

What is dynamic programming?

Back

An optimisation technique that solves complex problems by breaking them into overlapping subproblems and storing results (memoisation or tabulation) to avoid redundant computation.

Front

What is a linked list?

Back

A sequence of nodes where each node contains data and a pointer to the next node. O(1) insert/delete at known position; O(n) access by index. No contiguous memory needed.

Front

What is the difference between BFS and DFS?

Back

BFS (Breadth-First Search): explores level by level using a queue — good for shortest path in unweighted graphs. DFS (Depth-First Search): explores as far as possible using a stack/recursion — good for connectivity and cycle detection.

Front

What is a heap?

Back

A complete binary tree satisfying the heap property: max-heap (parent ≄ children) or min-heap (parent ≤ children). Used for priority queues. O(log n) insert/extract.

Front

What is the time complexity of merge sort?

Back

O(n log n) in all cases (best, average, worst). Space: O(n). Stable sort that works by dividing the array in half, sorting each half, then merging.

Front

What is a trie?

Back

A tree-like data structure for storing strings where each node represents a character. Enables O(m) search/insert (m = string length). Used in autocomplete and spell checkers.

Front

What is amortised analysis?

Back

A method of averaging the cost of operations over a sequence of operations, even if individual operations can be expensive. E.g. dynamic array append is O(1) amortised despite occasional O(n) resizing.