PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Uber

Simulate views on an n-ary tree

Last updated: May 5, 2026

Quick Overview

This question evaluates proficiency in tree traversal and algorithm design for ordered n-ary trees, focusing on identifying visible boundary nodes given child ordering and reasoning about time and space complexity.

  • Medium
  • Uber
  • Coding & Algorithms
  • Software Engineer

Simulate views on an n-ary tree

Company: Uber

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given a rooted, ordered n-ary tree (each node has a value and an ordered list of children), simulate an observer who starts at the bottom-left, moves upward to the root level while looking to the right, then continues downward to the bottom-right while looking to the left. At each depth during the upward phase, output the leftmost visible node (the first node encountered at that depth when scanning children left-to-right). During the downward phase, at each depth output the rightmost visible node (the first node encountered at that depth when scanning children right-to-left). Concatenate these into one sequence without duplicates (do not repeat the root if already output). Design an algorithm to compute this sequence for any n-ary tree, analyze time and space complexity, provide pseudocode, and discuss edge cases such as a single-node tree and highly unbalanced trees.

Quick Answer: This question evaluates proficiency in tree traversal and algorithm design for ordered n-ary trees, focusing on identifying visible boundary nodes given child ordering and reasoning about time and space complexity.

Related Interview Questions

  • Implement Minesweeper and Word Search - Uber (medium)
  • Implement Store Autocomplete - Uber (medium)
  • Implement Cache Eviction And Seat Assignment - Uber (medium)
  • Schedule Non-Overlapping Meetings Efficiently - Uber (hard)
  • Evaluate an Arithmetic Expression - Uber
Uber logo
Uber
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

Given a rooted, ordered n-ary tree (each node has a value and an ordered list of children), simulate an observer who starts at the bottom-left, moves upward to the root level while looking to the right, then continues downward to the bottom-right while looking to the left. At each depth during the upward phase, output the leftmost visible node (the first node encountered at that depth when scanning children left-to-right). During the downward phase, at each depth output the rightmost visible node (the first node encountered at that depth when scanning children right-to-left). Concatenate these into one sequence without duplicates (do not repeat the root if already output). Design an algorithm to compute this sequence for any n-ary tree, analyze time and space complexity, provide pseudocode, and discuss edge cases such as a single-node tree and highly unbalanced trees.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Uber•More Software Engineer•Uber Software Engineer•Uber Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.