Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python: Recursively find maximum depth of directory tree, that is the deepest level of nesting that occurs within the folder structure. For example: a USB

Python: Recursively find maximum depth of directory tree, that is the deepest level of nesting that occurs within the folder structure.

For example: a USB drive has four levels of folders at its largest depth due to the folder F:\Folder 1\Folder 2\Folder 3.

Folder 3 has depth one since it only contains files, the folder F:\Folder 1\Folder2 has depth 2 since it contains a folder of depth 1. Then F:\Folder 1 has depth 3 since it contains a folder of depth 2 and no other folder which is deeper. So the depth of a folder is one more than the depth of the deepest folder it contains. A folder which is empty or only contains files, has depth 1. If the path is to a file, the depth is 0

Without using os.walk, write a function that takes a file path (as string) as an argument that recursively travels the directory to find the maximum depth of the tree.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

Explain the impact of organizational culture on employees.

Answered: 1 week ago