InterviewStack.io LogoInterviewStack.io

Linked Lists and Trees Questions

Dynamic and pointer based data structures including linked lists and tree structures commonly tested in interviews. For linked lists cover node based representation, traversal, insertion at head and tail, deletion, searching, reversing a list, detecting cycles, and tradeoffs versus array based lists. For trees cover basic concepts such as binary trees and binary search trees, tree node representation, insertion and deletion in search trees, recursion patterns, and traversal algorithms including depth first search with in order pre order and post order variants and breadth first search. Also include problem solving patterns such as recursion and iterative stack or queue based approaches, analysis of time and space complexity in plain terms, and common interview tasks such as lowest common ancestor, tree balancing awareness, and converting between representations. Practice includes implementing algorithms, writing traversal routines, and reasoning about correctness and performance.

EasyTechnical
72 practiced
Explain the binary search tree (BST) invariant and why an inorder traversal of a BST yields node values in sorted order. Provide a short example tree and state average and worst-case time complexity for search, insert, and delete, explaining how imbalance affects performance.
EasyTechnical
85 practiced
Implement find_middle(head) in Python to return the middle node of a singly linked list in a single pass using the two-pointer (fast/slow) technique. Specify how you choose the middle for even-length lists (first or second middle) and discuss time/space complexity and potential ML batching use-cases.
EasyTechnical
72 practiced
Explain trade-offs between using a linked list vs a dynamic array (resizable array) to implement a dynamic list in ML feature pipelines. Discuss memory locality, CPU cache behavior, random access, insertion/deletion costs, resizing overhead, vectorized/batched operations, and give concrete examples when you would choose each in an ML system.
MediumTechnical
72 practiced
Implement merge_two_sorted_lists(l1, l2) in Python to merge two sorted singly linked lists into a single sorted list in-place (do not create new nodes). Return the head of the merged list and analyze time/space complexity and pointer invariants for correctness.
MediumTechnical
71 practiced
You maintain a large, frequently-read, occasionally-changed tree representing feature hierarchies used at runtime. Propose data structures, caching, and update strategies to support low-latency lookups and occasional insert/delete operations without heavy rebalancing. Explain how you would validate and safely deploy updates.

Unlock Full Question Bank

Get access to hundreds of Linked Lists and Trees interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.