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
0 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.
MediumTechnical
0 practiced
Given preorder and inorder traversal arrays of a binary tree (assume no duplicate values), implement build_tree(preorder, inorder) in Python to reconstruct the original tree. Explain time/space complexity and optimization using a hash map to index inorder positions.
MediumTechnical
0 practiced
Given heads of two singly linked lists that may intersect (share a tail by reference), implement get_intersection_node(headA, headB) in Python returning the intersecting node or None. Aim for O(1) extra space and O(n) time handling differing list lengths gracefully.
HardTechnical
0 practiced
Given a binary tree where each node has left, right, and parent pointers, implement successor(node) in Python that returns the inorder successor of a given node in O(h) time and O(1) extra space without accessing the root. Handle edge cases and justify correctness.
HardTechnical
0 practiced
Implement Morris inorder traversal for a binary tree in Python without recursion and using O(1) extra space. Explain how it temporarily modifies tree pointers (threading to predecessor), how you restore the original tree, and reason about correctness and edge cases.

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.