Answer to Question #198642 in Algorithms for Frederick

Question #198642

A project that requires participants to provide algorithms for searching files in a given structure is taking place. As the lead engineer for your team, propose a model and its corresponding algorithm to efficiently traverse the presented folder structure. The algorithm should list each step in the process and the corresponding final order 


1
Expert's answer
2021-05-26T23:28:41-0400

The example of non-linear data structures are file directory structure. In which graph and various types of trees are used as the model and non-linear structures.

Here the traversal of the data can not be done in the linear order. Such kind of data structure are known as the non-linear data structures.

We use the two main algorithm in the traversal of the file and directory. Which is DFS (Depth first search) and BFS (Breadth first search). DFS works recursively while BFS search iteratively.

The algorithm for the traversal into the folder are given below -

BFS(Breadth first search)

create empty queue file and enqueue root directory.
Loop till queue becomes empty
pop front file fromt he queue

If poped file is directory,
Then, get the list of directory present in it, add each directory to the queue
 and print every file.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS