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.

HardTechnical
0 practiced
Given a binary tree, find the subtree with maximum sum of node values. Implement a Python function that returns the root of the maximum-sum subtree and the sum. Use a single-pass recursion and explain how you avoid recomputing subtree sums.
MediumSystem Design
0 practiced
Design an LRU cache suitable for a data-engineer process that caches metadata entries (up to N items) with O(1) get and put. Describe data structures (hashmap + doubly linked list), concurrency considerations across multiple worker threads, and eviction strategy including TTL and size-based eviction. Assume Python or Java environment.
HardTechnical
0 practiced
Flatten a binary tree to a singly linked list in-place following preorder traversal (for each node, left child becomes None and right child points to next node in preorder). Implement flatten(root) in Python with O(n) time and O(1) extra space if possible. Explain your approach.
HardSystem Design
0 practiced
You manage a metadata service for a data lake and must design a scalable index for file paths that supports prefix searches, insertion, deletion, and efficient storage for billions of keys. Compare using tries, prefix trees, and B-trees for this workload; propose an architecture (storage, caching, sharding) and justify your choices for latency and space.
MediumTechnical
0 practiced
Implement a function to convert a binary tree into its preorder serialized list and back using iterative methods only (explicit stack), avoiding recursion. Provide Python code and discuss how iterative methods help in environments with limited recursion depth.

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.