UNIT-8 Trees And Graphs Q.1 The _________ of a tree is the number of levels in it. (a) Height (b) Depth (c) Height or Depth Q.2 The _________ of an element is the number of children it has (a) Height (b) Depth (c) Degree Q.3 The degree of a leaf is (a) 0 (b) 2 (c) 1 (d) 3 Q.4 A binary tree cannot be empty (a) True (b) False Q.5 A tree cannot be empty (a) True (b) False Q.6 Each element in a tree can have any number of sub trees (a) True (b) False Q.7 The drawing of every binary tree with n elements, n > 0, has exactlyâ€Ś edges. (a) n (b) n - 1 (c) n - 2 Q.8 A binary tree of height h, h >= 0 has at least_________ elements in it (a) h (b) h - 1 (c) h - 2 Q.9 A binary tree of height h, h>=0 has at most_________ elements in it (a) 2 ^ h (b) 2 ^ h - 3 (c) 2 ^ h- 1 Q.10 The height of a binary tree that contains n, n >= 0, elements is at most (a) n - 1 (b) n (c) n + 1 Q.11. The height of a binary tree that contains n, n>=0, elements is at least (a) log n (b) log(n - 1) (c) log(n + 1) Q.12 A binary tree of height h that contains exactly 2^h-1 elements is called a (a) Complete binary tree (b) Full binary tree (c) Compound binary tree Q.13 The height of a complete binary tree that contains n elements is (a) log (n + 1) (b) log n (c) log (n - 1)

Q.14 There are _________ common ways to traverse a binary tree. (a) 1 (b) 3 (c) 4 (d) 2 Q.15 The _________ form of an expression is the form in which we normally write an expression. (a) prefix (b) pos fix (c) infix Q.16 In _________ form each operator comes immediately before its operands. (a) prefix (b) postfix (c) infix Q.17 In _________form each operator comes immediately after its operands (a) prefix (b) post fix (c) infix Q.18 An edge with an orientation is called_________ edge. (a) directed (b) undirected (c) Bibirectional Q.19 An edge with no orientation is called_________edge. (a) directed (b) undirected (c) Bibirectional Q.20 A directed graph is also called (a) bigraph (b) digraph (c) Directing graph Q.21 A self-edge is also called (a) directed edge (b) undirected edge (c) loop Q.22 A simple path is a path in which all vertices except possibly the first and last are (a) different (b) same (c) may not be different Q.23 A subgraph of a graph 'G' that contains all the vertices of G and is a tree is a (a) Bipartite graphs (b) spanning tree (c) both Q.24 The_________ of a vertex of an unidirected graph is the no of edges incident on vertex (a) degree (b) order (c) height Q.25 A n-vertex undirected graph with n*(n-1)/2 edges is a_________ graph (a) subgraph (b) full graph (c) complete graph 113

Q.26 The _________ of a vertex is the number of edges incident to vertex ‘i’ (a) in degree (b) out degree (c) subdegree Q.27 The _________of a vertex is the number of edges incident from vertex ‘i’ (a) in degree (b) out degree (c) subdegree Q.28 A complete digraph on n vertices contains exactly _________directed edges. (a) n (b) 0 n*(n - 1)/2 (c) n*(n - 1) Q.29 How many graph search methods are there? (a) 1 (b) 3 (c) 2 Q.30. Which graph search method is used more frequently? (a) Breadth first search (b) depth first search (c) both Q.31 The method of starting at a vertex and identifying all vertices reachable from it is called (a) Depth first search (b) breadth first search (c) Horizontal search Q.32_________ is quite similar to pre-order traversal of a binary tree. (a) Breadth-first search (b) Depth-first search (c) Horizontal search Q.33 Of the following tree structures, which is more efficient considering space and time complexities? (a) Incomplete Binary Tree (b) Complete BinaryTree (c) Full Binary Tree d) none Q.34 What is the order of complexity for binary search tree? (a) log n2 (b) n log n (c) log n (d)none Answers 1. 5. 9. 13. 17. 21. 25. 29. 33.

(c) (a) (c) (a) (b) (c) (c) (c) (b)

2. 6. 10. 14. 18. 22. 26. 30. 34.

(c) (a) (b) (c) (a) (a) (a) (b) (a)

3. 7. 11. 15. 19. 23. 27. 31. 114

(a) (b) (c) (c) (b) (b) (a) (b)

4. 8. 12. 16. 20. 24. 28. 32.

(b) (a) (a) (a) (b) (a) (c) (b)

Data Structures Q. How to distinguish between a binary tree and a tree? Ans: A node in a tree can have any number of branches, while a binary tree is a tree structure in which any node can have at most two branches. For binary trees, we distinguish between the subtree on the left and subtree on the right, whereas for trees the order of the subtrees is irrelevant. Consider the following figure... Fig. This above figure shows two binary trees, but these binary trees are different. The first has an empty right subtree while the second has an empty left subtree. If the above are regarded as trees (not the binary trees), then they are same despite the fact that they are drawn differently. Also, an empty binary tree can exist, but there is no tree having zero nodes.

115

Read more

Similar to

Popular now

Just for you