Chapter There are non-isomorphic rooted trees with four vertices. Ans: 4.

Similar documents
Data Structure [Question Bank]

DATA STRUCTURES USING C

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

GRAPH THEORY LECTURE 4: TREES

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

PES Institute of Technology-BSC QUESTION BANK

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Mathematics for Algorithm and System Analysis

Home Page. Data Structures. Title Page. Page 1 of 24. Go Back. Full Screen. Close. Quit

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

International Journal of Advanced Research in Computer Science and Software Engineering

Decision Mathematics D1 Advanced/Advanced Subsidiary. Tuesday 5 June 2007 Afternoon Time: 1 hour 30 minutes

10CS35: Data Structures Using C

Binary Search Trees CMPSC 122

Answer: (a) Since we cannot repeat men on the committee, and the order we select them in does not matter, ( )

AP Computer Science AB Syllabus 1

Sample Questions Csci 1112 A. Bellaachia

Social Media Mining. Graph Essentials

Binary Trees and Huffman Encoding Binary Search Trees

root node level: internal node edge leaf node Data Structures & Algorithms McQuain

CS311H. Prof: Peter Stone. Department of Computer Science The University of Texas at Austin

Algorithms and Data Structures

Data Structure with C

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Data Structures and Algorithms Written Examination

Converting a Number from Decimal to Binary

ML for the Working Programmer

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

B AB 5 C AC 3 D ABGED 9 E ABGE 7 F ABGEF 8 G ABG 6 A BEDA 3 C BC 1 D BCD 2 E BE 1 F BEF 2 G BG 1

Exam study sheet for CS2711. List of topics

ER E P M A S S I CONSTRUCTING A BINARY TREE EFFICIENTLYFROM ITS TRAVERSALS DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A

Any two nodes which are connected by an edge in a graph are called adjacent node.

Ordered Lists and Binary Trees

AFF 808. Sub. Code 4BIT1C1. B.Sc. DEGREE EXAMINATION, NOVEMBER First Semester. Information Technology

Class One: Degree Sequences


Binary Search Trees (BST)

SOLUTIONS FOR PROBLEM SET 2

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

Data Structures. Level 6 C Module Descriptor

MATHEMATICS Unit Decision 1

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Algorithm Homework and Test Problems

Part 2: Community Detection

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

Chapter 6: Graph Theory

COMPUTER SCIENCE. Paper 1 (THEORY)

Lecture 17 : Equivalence and Order Relations DRAFT

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Examination paper for MA0301 Elementær diskret matematikk

Positional Numbering System

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: )

V. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005

Mining Social Network Graphs

A binary search tree is a binary tree with a special property called the BST-property, which is given as follows:

Analysis of Algorithms, I

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Data Structures and Algorithms

Graphs without proper subgraphs of minimum degree 3 and short cycles

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

SEMITOTAL AND TOTAL BLOCK-CUTVERTEX GRAPH

Graph Theory and Complex Networks: An Introduction. Chapter 06: Network analysis

Binary Heap Algorithms

Large induced subgraphs with all degrees odd

Mathematical Induction. Lecture 10-11

Solutions to Homework 6

Graph Theory Problems and Solutions

The Goldberg Rao Algorithm for the Maximum Flow Problem

CSC 373: Algorithm Design and Analysis Lecture 16

5.1 Midsegment Theorem and Coordinate Proof

Using the ac Method to Factor

CompSci-61B, Data Structures Final Exam

Baltic Way Västerås (Sweden), November 12, Problems and solutions

Just the Factors, Ma am

Full and Complete Binary Trees

Ex. 2.1 (Davide Basilio Bartolini)

ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION /5:15-6:45 REC-200, EVI-350, RCH-106, HH-139

Discrete Mathematics Problems

Properties of Real Numbers

Introduction to Algorithms. Part 3: P, NP Hard Problems

Parallelization: Binary Tree Traversal

Number Sense and Operations

MATHEMATICAL THOUGHT AND PRACTICE. Chapter 7: The Mathematics of Networks The Cost of Being Connected

Base Conversion written by Cathy Saxton

Magic Word. Possible Answers: LOOSER WINNER LOTTOS TICKET. What is the magic word?

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

Algorithms and data structures

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : ,

Sum of Degrees of Vertices Theorem

SHARP BOUNDS FOR THE SUM OF THE SQUARES OF THE DEGREES OF A GRAPH

Lecture 16 : Relations and Functions DRAFT

Graph Theory Lecture 3: Sum of Degrees Formulas, Planar Graphs, and Euler s Theorem Spring 2014 Morgan Schreffler Office: POT 902

MATH 21. College Algebra 1 Lecture Notes

Factoring Trinomials: The ac Method

Lab Manual. Data Structures (Pr): COT-213 Data Structures (P): IT-215

Transcription:

Use the following to answer questions 1-26: In the questions below fill in the blanks. Chapter 10 1. If T is a tree with 999 vertices, then T has edges. 998. 2. There are non-isomorphic trees with four vertices. 2. 3. There are non-isomorphic rooted trees with four vertices. 4. 4. There are full binary trees with six vertices. 0. 5. The minimum number of weighings with a pan balance scale needed to guarantee that you find the single counterfeit coin and determine whether it is heavier or lighter than the other coins in a group of five coins is. 3. 6. The value of the arithmetic expression whose prefix representation is 5 / 6 2 5 3 is. 1. 7. Write 3n (k + 5) in prefix notation:. 3 n + k 5. 8. C 7 has spanning trees. 7. 9. If each edge of Q 4 has weight 1, then the cost of any spanning tree of minimum cost is. 15. 10. The best comparison-based sorting algorithms for a list of n items have complexity O ( ). n log 2 n. 11. The bubble sort has complexity O ( ). n 2. 12. If T is a binary tree with 100 vertices, its minimum height is. 6. Page 136

13. If T is a full binary tree with 101 vertices, its minimum height is. 6. 14. If T is a full binary tree with 101 vertices, its maximum height is. 50. 15. If T is a full binary tree with 50 leaves, its minimum height is. 6. 16. Every full binary tree with 61 vertices has leaves. 31. 17. Every full binary tree with 50 leaves has vertices. 99. 18. If T is a full binary tree of height h, then the minimum number of leaves in T is and the maximum number of leaves in T is. h + 1, 2 h. 19. Every 3-ary tree with 13 vertices has leaves. 9. 20. If T is a full binary tree with 50 internal vertices, then T has vertices. 101. 21. Every full 3-ary tree of height 2 has at least vertices and at most vertices. 7,13. 22. The largest number of leaves in a binary tree of height 5 is. 32. 23. Every full binary tree with 45 vertices has internal vertices. 22. 24. A full 3-ary tree with 13 internal vertices has vertices. 40. 25. There are full 3-ary trees with 6 vertices. 0. 26. If T is a tree, then its vertex-chromatic number is and its region-chromatic number is. 2, 1. Page 137

Use the following to answer questions 27-36: In the questions below mark the statement TRUE or FALSE. 27. If T is a tree with 17 vertices, then there is a simple path in T of length 17. False 28. Every tree is bipartite. True 29. There is a tree with degrees 3,2,2,2,1,1,1,1,1. False 30. There is a tree with degrees 3,3,2,2,1,1,1,1. True 31. If two trees have the same number of vertices and the same degrees, then the two trees are isomorphic. False 32. If T is a tree with 50 vertices, the largest degree that any vertex can have is 49. True 33. In a rooted binary tree with 16 vertices, there must be a path of length 4. True 34. Every tree is planar. True 35. No tree has a Hamilton path. False 36. If T is a rooted binary tree of height 5, then T has at most 25 leaves. False 37. Draw all nonisomorphic trees with 5 vertices. Page 138

38. Draw all nonisomorphic rooted trees with 4 vertices. 39. Suppose T is a full m-ary tree with i internal vertices. Prove that T has 1 + (m 1)i leaves. mi + 1 = v = i + l. Therefore l = mi + 1 i = 1 + (m 1)i. 40. Prove that if T is a full m-ary tree with l leaves, then T has (ml 1)/(m 1) vertices. mi + 1 = v and i = v l. Therefore m(v l) + 1 = v. Solve for v to obtain the formula. 41. Suppose T is a full m-ary tree with l leaves. Prove that T has (l 1)/(m 1) internal vertices. i + l = v = mi + 1. Therefore i + l = mi + 1. Solve for i to obtain the result. 42. Prove that if T is a full m-ary tree with v vertices, then T has ((m 1)v + 1)/m leaves. i + l = v and mi + 1 = v. Therefore v l = i and i = (v 1)/m. Therefore, v l = (v 1)/m. Solve for l to obtain the result. 43. Suppose that the universal address set address of a vertex v in an ordered rooted tree is 3.2.5.1.5. Find (a) the level of v. (b) the minimum number of siblings of v. (c) the address of the parent of v. (d) the minimum number of vertices in the tree. (a) 5. (b) 4. (c) 3.2.5.1. (d) 17. 44. Suppose you have 50 coins, one of which is counterfeit (either heavier or lighter than the others). You use a pan balance scale to find the bad coin. Prove that 4 weighings is not enough to guarantee that you find the bad coin and determine whether it is heavier or lighter than the other coins. Four weighings yield a 3-ary tree of height 4, which has at most 81 leaves. Fifty coins require a tree with 100 leaves. Page 139

45. Suppose you have 5 coins, one of which is counterfeit (either heavier or lighter than the other four). You use a pan balance scale to find the bad coin and determine whether it is heavier or lighter. (a) Prove that 2 weighings are not enough to guarantee that you find the bad coin and determine whether it is heavier or lighter. (b) Draw a decision tree for weighing the coins to determine the bad coin (and whether it is heavier or lighter) in the minimum number of weighings. (a) Two weighings yield a 3-ary tree of height 2, which has at most 9 leaves, but 5 coins require a tree with 10 leaves. (b) Use the weighing 1 and 2 against 3 and 4 as the root. If the four coins have the same weight, weigh 1 against 5 to determine whether 5 is heavy or light. If 1 and 2 are lighter or heavier than 3 and 4, weigh 1 against 2. If 1 and 2 balance, weight 3 against 4 to find out which of these coins is heavier or lighter; if 1 and 2 do not balance, then immediate information is obtained regarding coins 1 or 2. 46. Suppose you have 5 coins, one of which is heavier than the other four. Draw the decision tree for using a pan balance scale to find the heavy coin. Weigh 1 and 2 against 3 and 4. If they balance, 5 is the bad coin. If 1 and 2 weigh less than 3 and 4, weigh 3 against 4 to find which of 3 or 4 is bad. If 1 and 2 weigh more than 3 and 4, weigh 1 against 2 to find out which of 1 or 2 is bad. Page 140

47. (a) Set up a binary tree for the following list, in the given order, using alphabetical ordering: STOP, LET, THERE, TAPE, NONE, YOU, ANT, NINE, OAT, NUT. (b) Explain step by step how you would search for the word TEST in your tree. (c) What is the height of the shortest binary search tree that can hold all 10 words? (d) Write the preorder traversal of the tree. (e) Write the postorder traversal of the tree. (f) Write the inorder traversal of the tree. (a) (b) In sequence, TEST would be compared with STOP, THERE, TAPE, and inserted as the right child of TAPE. (c) 3. (d) STOP, LET, ANT, NONE, NINE, OAT, NUT, THERE, TAPE, YOU. (e) ANT, NINE, NUT, OAT, NONE. LET, TAPE, YOU, THERE, STOP. (f) ANT, LET, NINE, NONE, NUT, OAT, STOP, TAPE, THERE, YOU. Page 141

48. (a) Set up a binary tree for the following list, in the given order, using alphabetical ordering: SHE, SELLS, SEA, SHELLS, BY, THE, SEASHORE. (b) How many comparisons with words in the tree are needed to determine if the word SHARK is in the tree? (c) How many comparisons with words in the tree are needed to determine if the word SEAWEED is in the tree? (d) How many comparisons with words in the tree are needed to determine if the word CONCH is in the tree? (a) (b) 2. (c) 4. (d) 4. 49. Draw a parsing tree for (a (3 + 2b))/(c 2 + d). 50. Find the preorder traversal of the parsing tree for 8xy5 7 4z3 5 (8 x y) 7 4z 3. Page 142

5 51. Find the postorder traversal of the parsing tree for (8x y) 7 4z 3. 8x y 5 4z 3 52. Find the inorder traversal of the parsing tree for 8 x y 5 7 4 z 3. 5 (8 x y) 7 4z 3. Use the following to answer questions 53-55: In the questions below refer to the given tree. 53. Find the preorder traversal. dbacefghiljmknop 54. Find the inorder traversal. abcfegdihjlkmnop 55. Find the postorder traversal. acfgebijknmoplhd 56. The algebraic expression / a 7c34 3b is written in prefix notation. Write the expression in postfix notation. a7c 3 4 3b / 57. Write the compound proposition ( p) (q (r s)) in postfix notation. p q r s 58. Write the compound proposition ( p) (q (r s)) in prefix notation. p q r s Page 143

59. Write the compound proposition ( p) (q (r s)) in infix notation. p q r s 60. The string 2 3 a x + 4 + 7 is postfix notation for an algebraic expression. Write the expression in prefix notation. + 2 + 3 a x 4 7 61. The string 2 3 a x + 4 + 7 is postfix notation for an algebraic expression. Write the expression in infix notation. 2 + 3 a + x 4 7 62. The string 2 x a + 4 y is prefix notation for an algebraic expression. Write the expression in postfix notation. 2 x a 4 y + 63. The string 2 x a + 4 y is prefix notation for an algebraic expression. Write the expression in infix notation. 2 x a 4 + y 64. The string p r q q p is postfix notation for a logic expression, however there is a misprint. The triangle should be one of these three: r,, or. Determine which of these three it must be and explain your reasoning. The triangle should be. Using either r or makes the parsing tree impossible to draw. 65. Find the value of x 5 t / 4 7 c (in prefix notation) if c = 5, x = 2, and t = 1. 30. Use the following to answer questions 66-73: In the questions below refer to this graph. Page 144

66. Using alphabetical ordering, find a spanning tree for this graph by using a depth-first search. 67. Using alphabetical ordering, find a spanning tree for this graph by using a breadth-first search. 68. Using the ordering C, D, E, F, G, H, I, J, A, B, C find a spanning tree for this graph by using a depth-first search. 69. Using the ordering C, D, E, F, G, H, I, J, A, B, C find a spanning tree for this graph by using a breadth-first search. Page 145

70. Using reverse alphabetical ordering, find a spanning tree for the graph by using a depthfirst search. 71. Using reverse alphabetical ordering, find a spanning tree for the graph by using a breadth-first search. 72. Using the ordering B, G, J, A, C, I, F, H, D, E, find a spanning tree for this graph by using a depth-first search. 73. Using the ordering B, G, J, A, C, I, F, H, D, E, find a spanning tree for this graph by using a breadth-first search. Page 146

Use the following to answer questions 74-81: In the questions below refer to this graph. 74. Using alphabetical ordering, find a spanning tree for this graph by using a depth-first search. 75. Using alphabetical ordering, find a spanning tree for this graph by using a breadth-first search. 76. Using the ordering C, D, E, F, G, H, I, J, A, B, C find a spanning tree for this graph by using a depth-first search. Page 147

77. Using the ordering C, D, E, F, G, H, I, J, A, B, C find a spanning tree for this graph by using a breadth-first search. 78. Using reverse alphabetical ordering, find a spanning tree for the graph by using a depthfirst search. 79. Using reverse alphabetical ordering, find a spanning tree for the graph by using a breadth-first search. 80. Using the ordering B, G, J, A, C, I, F, H, D, E, find a spanning tree for this graph by using a depth-first search. Page 148

81. Using the ordering B, G, J, A, C, I, F, H, D, E, find a spanning tree for this graph by using a breadth-first search. 82. Find a spanning tree for the graph K 3,4 using a depth-first search. (Assume that the vertices are labeled u 1,u 2,u 3 in one set and v 1,v 2,v 3,v 4 in the other set, and that alphabetical ordering is used in the search, with numerical ordering on the subscripts used to break ties.) 83. Find a spanning tree for the graph K 3,4 using a breadth-first search. (Assume that the vertices are labeled u 1,u 2,u 3 in one set and v 1,v 2,v 3,v 4 in the other set, and that alphabetical ordering is used in the search, with numerical ordering on the subscripts used to break ties.) 84. Is the following code a prefix code: A:11, B:10, C:0? Yes Page 149

85. Use the bubble sort to sort the list 5,2,3,1,4 in increasing order. 2,5,3,1,4, 2,3,5,1,4, 2,3,1,5,4, 2,3,1,4,5; 2,3,1,4,5, 2,1,3,4,5, 2,1,3,4,5; 1,2,3,4,5, 1,2,3,4,5; 1,2,3,4,5. 86. Use the merge sort to sort the list 4,8,6,1,5,7,3,2 in increasing order. After splitting the list into eight lists of 1 element each, the lists are merged into four sorted lists of 2 elements each: 4,8; 1,6; 5,7; 2,3. These are merged into two sorted lists of 4 elements: 1,4,6,8 and 2,3,5,7. Finally, these are merged into the final sorted list 1,2,3,4,5,6,7,8. 87. Use the bubble sort to sort the list 5,4,3,2,1 in increasing order. 5,4,3,2,1, 4,5,3,2,1, 4,3,5,2,1, 4,3,2,5,1, 4,3,2,1,5; 3,4,2,1,5, 3,2,4,1,5, 3,2,1,4,5; 2,3,1,4,5, 2,1,3,4,5; 1,2,3,4,5. 88. Use the merge sort to sort the list 3,8,12,4,1,5,9,6 in increasing order. 3,8; 4,12; 1,5; 6,9. 3,4,8,12; 1,5,6,9. 1,3,4,5,6,8,9,12. 89. Use backtracking to find a sum of integers in the set {18,19,23,25,31} that equals 44. The following tree is obtained using backtracking; it yields 44 = 19 + 25. Page 150

90. Find a minimal spanning tree for this weighted graph using Prim's algorithm. In order, the following edges are added: {d,e}, {e,h}, {e,f}, {d,g}, {g,a}, {a,b}, {b,c}, {c,i}. The weight of the minimal spanning tree is 17. 91. Use Prim's algorithm to find a minimal spanning tree for this weighted graph. Use alphabetical order to break ties. In order, the following edges are added: {a,b}. {a,c}, {c,e}, {d,e}. {d,f}. The weight is 9. Page 151

92. Find a spanning tree of minimum cost for this graph. The minimum weight is 24. One example of a tree is 93. Describe the difference between Prim's algorithm and Kruskal's algorithm for finding a spanning tree of minimum cost. Using Prim's algorithm, at each stage the edges selected will form a tree, whereas in Kruskal's algorithm this need not happen. Page 152