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
Implement a singly linked list in Python with methods: append(value), prepend(value), find(value) -> Node|None, and to_list() -> List[int]. Use a Node class with attributes 'val' and 'next'. Ensure prepend is O(1) and append is O(n) unless you maintain a tail pointer. Show example usage and explain how you handle empty-list edge cases and keeping head/tail consistency.
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.
EasyTechnical
0 practiced
Implement a stack data structure using a singly linked list in Python supporting push, pop, peek, and is_empty operations. Discuss complexity and memory characteristics compared to a list/array-backed stack for frequent push/pop workloads.
HardTechnical
0 practiced
You need to merge two large balanced trees (e.g., two BST-based indexes) representing different time ranges into one while maintaining balance. Describe algorithms to perform this merge (in-order traversal to arrays then build balanced tree vs tree-to-tree recursive merges), analyze cost, and suggest which you would pick for minimal downtime and memory use.
MediumTechnical
0 practiced
Given a binary tree and a target sum, implement has_path_sum(root, target) in Python that returns True if there exists a root-to-leaf path where the sum of node values equals target. Use recursion and explain stack depth implications for deep 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.