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
Design a lock-free append operation for a singly linked list suitable for concurrent ML data ingestion pipelines. Provide conceptual pseudocode using atomic compare-and-swap (CAS), explain the ABA problem, and recommend memory-reclamation strategies such as hazard pointers or epoch-based reclamation.
MediumTechnical
0 practiced
Implement has_cycle(head) in Python to detect whether a singly linked list contains a cycle using O(1) extra space and O(n) time. If a cycle exists, return the node at the start of the cycle; otherwise return None. Explain Floyd's algorithm and why resetting one pointer to head finds the cycle start.
MediumTechnical
0 practiced
Implement is_balanced(root) in Python to determine if a binary tree is height-balanced (for every node, height difference between left and right is <= 1). Aim for O(n) time by computing heights bottom-up and returning early when imbalance is detected.
EasyTechnical
0 practiced
Write two functions in Python: reverse_iterative(head) and reverse_recursive(head) that reverse a singly linked list in-place and return the new head. Explain time and space complexity for both and compare recursive stack memory limits versus iterative approach for production ML pipelines.
EasyTechnical
0 practiced
Write functions max_depth_recursive(root) and max_depth_bfs(root) in Python to compute the maximum depth (height) of a binary tree. Explain time and space complexity for both implementations and trade-offs when trees are very deep versus very wide in production model evaluation contexts.

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.