Interview Q&A / Data Structures & Algorithms

INTERVIEW Q&A · 55 QUESTIONS

Data Structures & Algorithms interview questions

Arrays, linked lists, hashing, trees and patterns, with line-by-line code and complexity.

  1. How does a hash map handle collisions?

    A collision happens when two keys hash to the same bucket. Chaining stores colliding entries in a list inside the bucket; open addressing probes for the next free slot. Both keep lookups near O(1) on average if the table stays sparse.

    BeginnerQuick answer1 min read
  2. What is the difference between a stack and a queue, with real examples?

    A stack is last in, first out (LIFO): you add and remove at the same end. A queue is first in, first out (FIFO): you add at the back and remove from the front.

    BeginnerQuick answer1 min read
  3. What is the difference between an array and a linked list, and when would you choose each?

    An array stores items contiguously, so indexing is O(1) but inserting in the middle is O(n). A linked list stores nodes connected by pointers, so insertion at a known node is O(1) but reaching the kth item is O(n).

    BeginnerQuick answer1 min read