Premium

Find a Node in a DOM Tree (DFS/BFS)

By FrontendAtlas Team · Updated Feb 1, 2026

Implement findNode(root, predicate) to traverse the DOM and return the first matching element. Use DFS/BFS with early exit. Complexity: O(n) time, O(h) recursion stack.

Challenge preview

Find a Node in a DOM Tree (DFS/BFS): Implement findNode(root, predicate) to traverse the DOM and return the first matching element. Use DFS/BFS with early exit. Complexity: O(n) time, O(h) recursion stack. Expect dom and tree decisions under intermediate level constraints.

Premium unlocks

  • Full editor workflow with starter files, tests, and solution context.
  • Edge cases, common mistakes, and complexity notes for the interview discussion.
  • Progress tracking once you unlock and complete the challenge.

Free warm-up options

Upgrade to FrontendAtlas Premium to unlock this challenge. Already upgraded? Sign in to continue.