DSAIntermediateReady

Trees Assessment

This assessment verifies the Trees module. Passing it contributes up to 7 points in the 49-55 score band.

Questions

8

Limit

90m

Pass

85%

Score

+7

Question 1scenarioIntermediate

12 pts

Choosing DFS versus BFS from product behavior

A product navigation system stores Workspace -> Project -> Dashboard -> Alert menus as a tree. One feature renders the menu with parents before children. Another feature finds the nearest visible item matching a permission rule. Choose traversal strategies for both and explain why.

Question 2codingIntermediate

13 pts

Breadth-first traversal implementation

Implement level-order traversal for an n-ary tree and return a list of levels. Include complexity and queue memory behavior.

Question 3code-reviewIntermediate

13 pts

Binary-tree postorder aggregation

A candidate computes binary-tree diameter by calling `height(left) + height(right)` at every node, but each `height` call recursively recomputes subtree heights from scratch. Review the performance risk and propose the stronger approach.

Question 4multiple-choiceIntermediate

8 pts

Binary-tree recursion correctness

Which statement is the strongest assessment-grade answer for binary-tree recursion?

Question 5codingIntermediate

14 pts

BST invariant and inherited bounds

Validate whether a binary tree is a binary search tree. Explain why checking only `left.value < node.value < right.value` is insufficient.

Question 6scenarioIntermediate

13 pts

BST range pruning and complexity precision

A marketplace keeps an in-memory balanced BST of products by price. Implementing a price range filter currently traverses every node and filters after traversal. Explain how to use the BST invariant to reduce unnecessary work and state the complexity carefully.

Question 7scenarioIntermediate

14 pts

Heap and priority-queue production design

A background scheduler receives jobs with `runAt`, `priority`, and `createdAt`. It needs to repeatedly run the next eligible job. Compare sorting on every insert with a priority queue and define a deterministic ordering policy.

Question 8scenarioIntermediate

13 pts

Applying heaps to top-k and k-way merge

You must support two features: top 20 most frequent alert signatures from a huge stream, and merging 50 already-sorted alert feeds. Choose heap-based approaches where appropriate and compare them with full sorting.