PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Adobe

Traverse a path and print directory tree

Last updated: Apr 24, 2026

Quick Overview

This question evaluates proficiency with filesystem I/O, path validation, directory traversal, recursion and error handling in Node.js, plus the ability to produce deterministic directory listings in either an indented tree or structured JSON representation.

  • medium
  • Adobe
  • Coding & Algorithms
  • Software Engineer

Traverse a path and print directory tree

Company: Adobe

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem (Node.js) You are given an absolute or relative file-system path `rootPath`. Write a Node.js function/program that: 1. Validates that `rootPath` exists. 2. Reads the contents under `rootPath`. 3. Outputs a directory listing that includes both **files** and **subfolders**. ### Output format Choose one of the following and document it clearly in your answer: - A **tree** format (indented text), e.g. - `root/` - `a.txt` - `sub/` - `b.js` - Or a **structured JSON** representation, e.g. `{ name, type, children }`. ### Requirements / edge cases - If `rootPath` is a file, output just that file. - If `rootPath` is a directory, include all immediate children (optionally recursively—state which you implement). - Handle common errors (non-existent path, permission denied) gracefully. - If you sort entries, make the sort deterministic and specify it (e.g., folders first, then lexicographic by name).

Quick Answer: This question evaluates proficiency with filesystem I/O, path validation, directory traversal, recursion and error handling in Node.js, plus the ability to produce deterministic directory listings in either an indented tree or structured JSON representation.

Related Interview Questions

  • Build a React team builder with role constraints - Adobe (medium)
  • Implement K-means clustering from scratch - Adobe (medium)
  • Design a nested-list iterator - Adobe (Medium)
  • Maximize pay by flipping k rest days - Adobe (Medium)
  • Determine task order with prerequisites - Adobe (Medium)
Adobe logo
Adobe
Feb 11, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
7
0
Loading...

Problem (Node.js)

You are given an absolute or relative file-system path rootPath.

Write a Node.js function/program that:

  1. Validates that rootPath exists.
  2. Reads the contents under rootPath .
  3. Outputs a directory listing that includes both files and subfolders .

Output format

Choose one of the following and document it clearly in your answer:

  • A tree format (indented text), e.g.
    • root/
      • a.txt
      • sub/
        • b.js
  • Or a structured JSON representation, e.g. { name, type, children } .

Requirements / edge cases

  • If rootPath is a file, output just that file.
  • If rootPath is a directory, include all immediate children (optionally recursively—state which you implement).
  • Handle common errors (non-existent path, permission denied) gracefully.
  • If you sort entries, make the sort deterministic and specify it (e.g., folders first, then lexicographic by name).

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 8,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.