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.

MediumTechnical
0 practiced
Implement iterative inorder traversal of a binary tree in Python without recursion, returning the list of values. Use an explicit stack and explain how you manage the current pointer and stack push/pop to visit nodes in-order.
HardTechnical
0 practiced
Find the diameter of a binary tree (longest path between any two nodes) and implement an algorithm in Python that computes it in O(n) time using a single traversal. Return the diameter length (number of edges). Explain why a naive approach is O(n^2).
MediumTechnical
0 practiced
Implement remove_nth_from_end(head, n) in Python to delete the n-th node from the end of a singly linked list in one pass. Return the new head. Consider n equal to the list length (removing head) and invalid n values. Use O(n) time and O(1) space.
EasyTechnical
0 practiced
Write a function in Python to reverse a singly linked list. Provide both an iterative O(n) time O(1) space solution and a recursive solution. For the recursive version, explain the stack usage and the maximum recursion depth for a list of length n. Show the Node class signature you assume.
MediumTechnical
0 practiced
Explain why an unbalanced BST can degenerate to linked-list behavior and the impact that has on operations in production data systems. Give a high-level comparison of balancing approaches: AVL, Red-Black, and B-trees, with pros/cons for in-memory and on-disk indexing for large datasets.

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.