GATE CS 1997 · Arrays & Matrix Representation

MCQ · 1 mark · Problem PROG-DSTR-0259

A binary search tree contains the value 1,2,3,4,5,6,7,8. The tree is traversed in pre-order and the values are printed out. Which of the following sequences is a valid output?
  1. A
    5 3 1 2 4 7 8 6
  2. B
    5 3 1 2 6 4 8 7
  3. C
    5 3 2 4 1 6 7 8
  4. D
    5 3 1 2 4 7 6 8

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solutionOfficial GATE Answer Key: Option D.See full step-by-step discussion on GateOverflow: https://gateoverflow.in/2246/gate1997-4-5

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com