Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6775323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:53:36+00:00 2026-05-26T15:53:36+00:00

I have a large filesystem that I need to traverse for errors. Each file

  • 0

I have a large filesystem that I need to traverse for errors. Each file knows whether or not it contains an error, so I simply need to travel to each node and check whether there is an error there. Also, each directory knows the total number of errors that exists within, so a search can be terminated once the given number of errors is found, and a directory need not be traversed if it does not contain errors.

My question is whether the better solution to this would be to use a depth first or a breadth first search. The height of the tree is undefined, which I know usually makes BFS better, but given that we know if a directory will contain an error before traversing it, I am not sure if that advantage is mitigated.

NOTE: This is NOT a homework assignment. It is a requirement for a script that my boss has requested that I write.

EDIT 1: Time efficiency is far more important than space efficiency, as the script will primarily be run overnight, and therefore can essentially use all of the system memory, if necessary.

EDIT 2: Though is seems the popular answer is BFS for my problem, I am having trouble understanding why it would not be a DFS problem. Since (A) all errors need eventually be reached and (B) we know if a directory contains errors, BFS’s protection against rabbit holes does not really apply. With that in mind, the only real difference seems to be space used, which would make DFS better. Can anyone give a good argument as to why this is not the case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:53:37+00:00Added an answer on May 26, 2026 at 3:53 pm

    It depends on a few stuff.

    • Could your directories contain links and would you traverse the links? In that case, is it possible for the links to make a loop? In such a case, BFS makes more sense if you want to ignore the cycle-checking. Otherwise, it makes no difference.

    • How is the distribution of errors? Could it be that one directory contains most errors while others are almost empty of errors? In that case BFS is more likely to end sooner because it searches all directories little by little. In such a case, you would spend a long time with DFS in one huge directory tree that contains say 1 error in the very bottom leaves only to find out the next directory contained all the bugs you need right at level 1. If the errors are distributed more evenly, again, it doesn’t matter what you use.

    • How big is your structure? If you have a tree with branching factor n (n subdirectories per each directory) and the tree has depth d, the BFS could take O(d^n) memory, while DFS could be written in such a way that it takes only O(d) memory (or in a simpler implementation O(d*n)) which in real huge directories could make a difference.

    My general feeling reading your question is BFS, but it is still you who have to decide based on the properties of your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in need of a distributed file system that must scale to very large
I'm developing an iPhone application that's particularly large, and contains loads of videos. (Not
I have large batches of XHTML files that are manually updated. During the review
I'm developing a website in PHP and I have large JS files that I
I have a large codebase that targetted Flash 7, with a lot of AS2
I have an application that stores large amount of files (XML and binary) in
I currently have a game that takes in large images, easily bigger than 1MB,
I have a program that reads and writes very large text files. However, because
I have an application that manages a large number of strings. Strings are in
I have a client node writing a file to a hard disk that is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.