Multiple choice

Given a traversal result abcdfge and following statements -

  1. Above traversal is PreOrder Traversal
  2. Above traversal is PostOrder Traversal
  3. Above traversal is InOrder Traversal
  4. For the given tree, a is the root of the tree
  5. For the given tree, e is the root of the tree Which of the above statements is/are correct?

    Given an algorithm to traverse a tree Traverse(Node v){ visit(v); for each child w of v Traverse(w); }

  1. 1 and 5

  2. 2 and 5

  3. 3 and 4

  4. 2 and 4

  5. 1 and 4

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

This is correct, as in the given algorithm , first v node is visited and then child nodes, it is preorder traversal. So in the beginning of traversal root will be traversed