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 deleteNode(root, key) for a BST handling three cases: deleting a leaf, deleting a node with one child, and deleting a node with two children (replace with inorder successor or predecessor). Return the new root. Explain trade-offs for choosing successor vs predecessor and analyze complexity.
MediumTechnical
0 practiced
Implement inorderTraversal(root) iteratively using an explicit stack (no recursion) in Python/Java/C++. Explain why a stack is necessary, show sample input/output, and discuss worst-case stack depth relative to tree height. Also mention how to yield results lazily for an iterator pattern.
EasyTechnical
0 practiced
Explain trade-offs between linked lists and arrays for common operations: indexing, insertion/deletion at head/tail/middle, memory usage, cache performance, and random access. Provide concrete examples where linked lists are preferable and where arrays (or dynamic arrays) outperform linked lists in real applications.
EasyTechnical
0 practiced
Implement reverseList(head) in Python, Java, or C++ that reverses a singly linked list iteratively and returns the new head. Provide example: input [1,2,3,4] → output [4,3,2,1]. Explain why this operation is in-place and analyze time and space complexity. Mention pointer-update order to avoid losing the remainder of the list.
MediumTechnical
0 practiced
Write a function maxWidth(root) that returns the maximum number of nodes at any level in a binary tree. Implement using BFS/queue and compute width at each level. Provide example and analyze the time and space complexity. Mention how width behaves for skewed vs balanced trees.

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.