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

  • SEARCH
  • Home
  • 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 6591981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:29:43+00:00 2026-05-25T17:29:43+00:00

So currently i have a DFS with the following pseudocode procedure DFS(Graph,source): create a

  • 0

So currently i have a DFS with the following pseudocode

procedure DFS(Graph,source):
      create a stack S
      push source onto S
      mark source
      while S is not empty:
          pop an item from S into v
          for each edge e incident on v in Graph:
              let w be the other end of e
              if w is not marked:
                 mark w
                 push w onto S

How do I alter this function to accept a third argument that limits the depth of the search?

  • 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-25T17:29:44+00:00Added an answer on May 25, 2026 at 5:29 pm

    Let Node be a structure for each node of the graph, add a field called level, then process the graph as follows:

    procedure DFS(Graph,source, depth):
      create a stack S
      source.level = 0
      push source onto S
      mark source
      while S is not empty:
          pop an item from S into v
          if v.level > depth
            continue
    
          for each edge e incident on v in Graph:
              let w be the other end of e
              if w is not marked:
                 mark w
                 w.level = v.level + 1
                 push w onto S
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a class and I'm trying to create an easy GUI to
Currently have the following expression: @[TMS_Dest] + \\ + @[TMS_Rename] + (DT_WSTR,4)DatePart(yyyy, GetDate()) +
Currently I have the following code for a project that represents some probability trees
I currently have the following keybinding in my .vimrc : nnoremap <Leader>gs :Gstatus<Enter><C-n> I'm
I currently have hostingrails.com. But following their tutorial on deploying rails application with FASTCGI
I currently have the following script: http://jsfiddle.net/oshirowanen/mnXdv/ Which works fine, i.e. if a click
I currently have the following table definition: <table border=1 cellspacing=0 bordercolor=#CEDFEF cellpadding=1> I am
I currently have the below code, but obviously I am not that skilled on
I currently have a tab image that I want to re-create in CSS, but
I currently have the following code: var myArray = []; var myElement = {

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.