UGC-NET Jun 2015 · Trees

MCQ · 2 marks · Problem PROG-DSTR-0017

Consider the following statements:(i) Depth-first search is used to traverse a rooted tree.(ii) Pre-order, post-order and in-order are used to list the vertices of an ordered rooted tree.(iii) Huffman's algorithm is used to find an optimal binary tree with given weights.(iv) Topological sorting provides a labelling such that the parents have larger labels than their children.Which of the above statements are true?
  1. A
    (i) and (ii)
  2. B
    (iii) and (iv)
  3. C
    (i), (ii) and (iii)
  4. D
    (i), (ii), (iii) and (iv)

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

Show the worked solution(i) True: depth-first search (pre-order walk) visits every vertex of a rooted tree.(ii) True: these are the three standard traversals for listing the vertices of an ordered rooted tree.(iii) True: Huffman's algorithm builds a binary tree of minimum weighted path length for the given weights.(iv) True: labelling vertices in the order a depth-first search finishes them (the reverse of a topological order) gives every parent a larger label than its children, since a parent finishes after all its descendants.All four are true.Answer: D

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