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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:15:02+00:00 2026-05-25T06:15:02+00:00

Three types of tree traversals are inorder, preorder, and post order. A fourth, less

  • 0

Three types of tree traversals are inorder, preorder, and post order.

A fourth, less often used, traversal is level-order traversal. In a
level-order traveresal, all nodes at depth “d” are processed before
any node at depth d + 1. Level-order traversal differs from the other
traversals in that it is not done recursively; a queue is used,
instead of the implied stack of recursion.

My questions on above text snippet are

  1. Why level order traversals are not done recursively?
  2. How queue is used in level order traversal? Request clarification with Pseudo code will be helpful.

Thanks!

  • 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-25T06:15:03+00:00Added an answer on May 25, 2026 at 6:15 am

    Level order traversal is actually a BFS, which is not recursive by nature. It uses Queue instead of Stack to hold the next vertices that should be opened. The reason for it is in this traversal, you want to open the nodes in a FIFO order, instead of a LIFO order, obtained by recursion

    as I mentioned, the level order is actually a BFS, and its [BFS] pseudo code [taken from wikipedia] is:

    1  procedure BFS(Graph,source):
    2      create a queue Q
    3      enqueue source onto Q
    4      mark source
    5      while Q is not empty:
    6          dequeue an item from Q into v
    7          for each edge e incident on v in Graph:
    8              let w be the other end of e
    9              if w is not marked:
    10                 mark w
    11                 enqueue w onto Q
    

    (*) in a tree, marking the vertices is not needed, since you cannot get to the same node in 2 different paths.

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

Sidebar

Related Questions

The PDF Spec defines standard structure types, used to define a structure tree for
NSXMLParser has three types of init. -> init -> initWith Data -> initWithContents of
Newbie question: There are three types of Asp.Net controls : HTML server controls, Web
i have an IList<Animals> farmAnimals; this list has three types, Cows Sheep Chickens how
The C standard states: ISO/IEC 9899:1999, 6.2.5.15 (p. 49) The three types char, signed
I like to distinguish three different types of conflict from a version control system
Please consider the following three .NET types: I have an interface, an abstract class,
I have a tree-like object structure that consists of two types of objects: object
In my application, I have a tree with various object types (sources, tables, etc).
I am having a tree data structure that can have different types of nodes

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.