Back to Interview Prep

Data Structures Interview Questions - Data Structures Interview Prep

50 Questions Available

Comprehensive collection of 50 essential Data Structures interview questions covering arrays, linked lists, trees, graphs, hash tables, and algorithm complexity.

All Questions & Answers

Show per page:
1

What is a data structure?

A

Data structure is way of organizing and storing data in computer memory for efficient access and modification. Examples: arrays, linked lists, stacks, queues, trees, graphs, hash tables. Choice affects algorithm performance.

2

What is the difference between array and linked list?

A

Array: contiguous memory, fixed/dynamic size, O(1) access, O(n) insert/delete. Linked list: non-contiguous, dynamic size, O(n) access, O(1) insert/delete. Array: better cache locality, random access. Linked list: efficient insertion/deletion, no size limit.

3

What is time complexity?

A

Time complexity describes how algorithm runtime grows with input size. Big O notation: O(1) constant, O(log n) logarithmic, O(n) linear, O(n log n) linearithmic, O(n²) quadratic, O(2ⁿ) exponential. Worst-case analysis.

4

What is space complexity?

A

Space complexity describes how algorithm memory usage grows with input size. Includes input space and auxiliary space. O(1) constant, O(n) linear, O(n²) quadratic. Important for memory-constrained systems.

5

What is a stack?

A

Stack is LIFO (Last In First Out) data structure. Operations: push (add top), pop (remove top), peek (view top), isEmpty. O(1) for all operations. Uses: function calls, expression evaluation, undo/redo, backtracking.

6

What is a queue?

A

Queue is FIFO (First In First Out) data structure. Operations: enqueue (add rear), dequeue (remove front), front, isEmpty. O(1) for all operations. Uses: task scheduling, BFS, print queues, request handling.

7

What is a binary tree?

A

Binary tree is tree where each node has at most 2 children (left, right). Root at top, leaves at bottom. Height: longest path from root to leaf. Full: all nodes have 0 or 2 children. Complete: all levels filled except last.

8

What is a binary search tree (BST)?

A

BST is binary tree where left subtree < node < right subtree. Enables O(log n) search, insert, delete (balanced). Inorder traversal gives sorted order. Worst case O(n) if unbalanced. Self-balancing: AVL, Red-Black trees.

9

What are tree traversals?

A

Tree traversals visit all nodes: Inorder (left, root, right) - sorted for BST. Preorder (root, left, right) - copy tree. Postorder (left, right, root) - delete tree. Level-order (BFS) - level by level. All O(n) time.

10

What is a hash table?

A

Hash table stores key-value pairs using hash function. O(1) average insert, search, delete. Hash function maps key to index. Collision handling: chaining (linked list), open addressing (linear/quadratic probing). Load factor affects performance.

Showing 1 to 10 of 50 questions
...