← Questions

Data structure fundamentals: arrays, linked lists, hash tables and trees

0
NvidiaCodingLast asked Feb 2026

A coding interview question asked in Nvidia's technical phone screen, last asked Feb 2026. It tests data structures, complexity and fundamentals.

A fundamentals screen of quick computer-science questions. Answer each one precisely, with the reasoning behind every complexity.

Questions

  1. What are the best, average and worst time complexities of bubble sort, insertion sort, selection sort, merge sort, quicksort and heap sort? Which are stable and which sort in place?
  2. Compare arrays and linked lists: the cost of accessing the ith element, inserting at the head and inserting in the middle (with and without already holding a pointer to the spot).
  3. Walk through, step by step, what a dynamic array (std::vector, ArrayList, a Python list) does when you insert at the front, including what happens when it is full and has to grow, and the amortized cost of appends.
  4. What is a hash table? Describe the underlying structure, the hash function's role, how collisions are handled (chaining, open addressing) and when it resizes.
  5. What is the difference between a "hash table" and a "hash map", conceptually and in a language such as Java (Hashtable versus HashMap)?
  6. What is the difference between a binary tree and a binary search tree, and what does each guarantee about lookups?

What a strong answer covers

  • Correct complexities with the reason (for example quicksort's O(n^2) worst case from bad pivots, heap sort's O(n log n) in all cases), and stability.
  • The array/linked-list trade-off, including cache locality, not only big-O.
  • The exact sequence for a front insert into a dynamic array: shift every element right (or allocate a larger buffer, copy, free the old one), so O(n) per front insert, while appends are amortized O(1) thanks to geometric growth.
  • Hash tables: buckets, load factor, resize and rehash, worst-case O(n) with bad hashing; Java's Hashtable being synchronized and rejecting nulls, HashMap not synchronized and allowing one null key.
  • The BST ordering invariant, O(h) lookups, and why balancing (AVL, red-black) keeps h = O(log n).

Follow-ups

  • Which structure would you use for a queue that needs fast inserts at both ends?
  • How does a hash map that degrades to long chains get fixed (Java converts long chains to trees)?
  • Why might quicksort beat merge sort in practice despite its worst case?

Where it's asked

What it tests

data structures · complexity · fundamentals

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding