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 8715417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:50:22+00:00 2026-06-13T05:50:22+00:00

I was initially doing it in two ways. One way is by storing visited

  • 0

I was initially doing it in two ways. One way is by storing visited nodes in a list and traversing the list to determine if a node has been visited before. Another was using a boolean array which keeps track of both visited and unvisited nodes. It really interested me, what is the best way?

  • 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-06-13T05:50:23+00:00Added an answer on June 13, 2026 at 5:50 am

    One approach, which can be useful for micro-optimization (better cache behavior, avoids lookup), is storing a flag on each node object. The obvious drawback is that the graph algorithms are not re-entrant. Want to do a different graph traversal to make a decision during traversal? Well, you can’t. You also have to remember to clear all these flags afterwards.

    The other category is maintaining a separate data structure on a per-traversal basis. Both of the approaches you give fall under this, although the list approach is very inefficient — O(n) time for every lookup. The boolean array (possibly compressed into a bitset; this option is extremely space efficient) is simple and efficient in both time and space, but requires that the nodes have consecutive indices/ids. This is not always given, and has consequences for other parts of the graph handling.

    If you don’t have that, and instead refer to graph objects with pointers, you can use a mapping based on that. In higher-level languages, such as Python, this is very simple (and due to highly tuned hash table/set data structures, rather efficient too).

    The obvious advantage is that graph traversals are re-entrant. While this may not sound like much, I can attest that situations where this is useful do arise at times.

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

Sidebar

Related Questions

Can I prefix all the Liferay tables that it initially creates by doing some
Initially I've tried to find possible ways to do HLS segmenting on other non-Mac
I am aware that Dijkstra's algorithm can find the minimum distance between two nodes
My question has two parts regarding haproxy. Question 1: The service that I am
I have a two activity application. One is a HomePage. Another is a DataPage
I need two things that the Membership Provider I'm sure is capable of doing.
I've got a repository i've been working with a little, it has around 805
I have two <select> one is category and the second is subcategory. here is
I'm still new to OOP, and the way I initially perceived it was to
I am doing two things with my user registration with Devise. Two step confirmation

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.