Solve the following problems: 1. (Carrano, 2012) Chapter 15 Solve Questions 1-8 p. 428. 2. (Rossen)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Solve the following problems: 1. (Carrano, 2012) Chapter 15 Solve Questions 1-8 p. 428. 2. (Rossen) Problem 16, 17,18,19. p. 784 16. a) Represent the expression (y-(3+x)) -5 using a binary tree. Write this expression in b) prefix notation. c) postfix notation. d) infix notation. 17. a) Represent the expressions (x + xy) + (x/y) and x + ((xy + x)/y) using binary trees. Write these expressions in b) prefix notation. c) postfix notation. d) infix notation. ((x+2) 3) * 18. a) Represent the compound propositions (p ^ q) (pv-g) and (p^ (gp)) Vg using or- dered rooted trees. Write these expressions in b) prefix notation. c) postfix notation. d) infix notation. 19. a) Represent (AB)-(AU (B-A)) using an or- dered rooted tree. Write this expression in b) prefix notation. c) postfix notation. d) infix notation. a. Represent the arithmetic expression with a Binary Tree. b. Apply the preorder, inorder, and postorder transversals at each binary tree obtained. It would help if you got the infix, prefix, and postfix expressions. c. Verify each prefix and postfix expression (b) with the grammar defined in your textbook 1.5.2.2 Prefi x Expressions 166 11.5.2.3 Postfix Expressions 170 3. Design a binary tree in code C++ for each arithmetic expression. Show preorder, inorder, and postorder traversals only for problems 16 and 17 (2). 4. The solution must contain the following: a. C ++ Code. b. Code execution. c. The problems must show the Question, Binary tree diagram, and Answer. 5.2.2 Prefix Expressions A grammar that defines the language of all prefix expressions is = | = + |-|* |/ = a b...z 5.2.3 Postfix Expressions A grammar that defines the language of all postfix expressions is = | = + |-|*|/ = a b... z EXERCISES 1. Consider the tree in Figure 15-18. What node or nodes are a. The tree's root? b. Parents? c. Children of the parents in part b? d. Siblings? e. Ancestors of 50? f. Descendants of 20? g. Leaves? 2. What is the height of the tree in Figure 15-18? 3. Write preconditions and postconditions for the ADT binary search tree operations. FIGURE 15-18 A tree for Exercises 1, 2, 6, 7, 11, and 23 (10 (30) (50) 4. What are the preorder, inorder, and postorder traversals of the binary tree in Figure 15-19? 5. Consider a method is Leaf that returns true if a binary tree is a one-node tree that is, if it consists of only a leaf and returns false otherwise. a. Specify the method is Leaf. b. If isLeaf were not a method of a class of binary trees, would a client of the class be able to implement isLeaf? Explain. 6. Starting with an empty binary search tree, in what order should you insert items to get the binary search tree in Figure 15-18? 7. Using the binary search tree in Figure 15-18, trace the search algorithm when it searches for a. 30 b. 15 In each case, list the nodes in the order in which the search visits them. 8. Is the tree in Figure 15-19 a binary search tree? Explain. Solve the following problems: 1. (Carrano, 2012) Chapter 15 Solve Questions 1-8 p. 428. 2. (Rossen) Problem 16, 17,18,19. p. 784 16. a) Represent the expression (y-(3+x)) -5 using a binary tree. Write this expression in b) prefix notation. c) postfix notation. d) infix notation. 17. a) Represent the expressions (x + xy) + (x/y) and x + ((xy + x)/y) using binary trees. Write these expressions in b) prefix notation. c) postfix notation. d) infix notation. ((x+2) 3) * 18. a) Represent the compound propositions (p ^ q) (pv-g) and (p^ (gp)) Vg using or- dered rooted trees. Write these expressions in b) prefix notation. c) postfix notation. d) infix notation. 19. a) Represent (AB)-(AU (B-A)) using an or- dered rooted tree. Write this expression in b) prefix notation. c) postfix notation. d) infix notation. a. Represent the arithmetic expression with a Binary Tree. b. Apply the preorder, inorder, and postorder transversals at each binary tree obtained. It would help if you got the infix, prefix, and postfix expressions. c. Verify each prefix and postfix expression (b) with the grammar defined in your textbook 1.5.2.2 Prefi x Expressions 166 11.5.2.3 Postfix Expressions 170 3. Design a binary tree in code C++ for each arithmetic expression. Show preorder, inorder, and postorder traversals only for problems 16 and 17 (2). 4. The solution must contain the following: a. C ++ Code. b. Code execution. c. The problems must show the Question, Binary tree diagram, and Answer. 5.2.2 Prefix Expressions A grammar that defines the language of all prefix expressions is = | = + |-|* |/ = a b...z 5.2.3 Postfix Expressions A grammar that defines the language of all postfix expressions is = | = + |-|*|/ = a b... z EXERCISES 1. Consider the tree in Figure 15-18. What node or nodes are a. The tree's root? b. Parents? c. Children of the parents in part b? d. Siblings? e. Ancestors of 50? f. Descendants of 20? g. Leaves? 2. What is the height of the tree in Figure 15-18? 3. Write preconditions and postconditions for the ADT binary search tree operations. FIGURE 15-18 A tree for Exercises 1, 2, 6, 7, 11, and 23 (10 (30) (50) 4. What are the preorder, inorder, and postorder traversals of the binary tree in Figure 15-19? 5. Consider a method is Leaf that returns true if a binary tree is a one-node tree that is, if it consists of only a leaf and returns false otherwise. a. Specify the method is Leaf. b. If isLeaf were not a method of a class of binary trees, would a client of the class be able to implement isLeaf? Explain. 6. Starting with an empty binary search tree, in what order should you insert items to get the binary search tree in Figure 15-18? 7. Using the binary search tree in Figure 15-18, trace the search algorithm when it searches for a. 30 b. 15 In each case, list the nodes in the order in which the search visits them. 8. Is the tree in Figure 15-19 a binary search tree? Explain.
Expert Answer:
Related Book For
Business Statistics For Contemporary Decision Making
ISBN: 978-1118749647
8th edition
Authors: Black Ken
Posted Date:
Students also viewed these algorithms questions
-
Each level of the tree is called a ply. Since the same state may be reachable by different sequences of moves, the state space may in general be a graph. It may be treated as a tree for simplicity,...
-
In 1976, Mohamed EI-Iladad earned an undergraduate accounting degree in his native Egypt. Before he began his accounting career, El-Hadad completed his compulsory service in the Egyptian military...
-
How can industries develop an online presence that incorporates engagement with the consumer and feedback to enhance its product/service line?
-
A sample of gas is taken through cycle abca shown in the p-V diagram of Figure. The net work done is + 1.2J. Along path ab, the change in the internal energy is + 3.0 J and the magnitude of the work...
-
Heat flows from cold substance to hot substance with the aid of external work. This statement is given by: (a) Kelvin (c) Gay Lussac (b) Joule (d) Clausius
-
a.In the Maine Megabucks game, you win the jackpot by selecting five different whole numbers from 1 through 41 and getting the same five numbers (in any order) that are later drawn. What is the...
-
Barco Kyan Company Company Barco Company Kyan Company Data from the current year-end balance sheets Assets Cash $18,500 $ 32,000 Accounts receivable, net 36,400 Merchandise inventory 84,940 Prepaid...
-
Outline a plan with two (2) methods of providing feedback to employees. Include the frequency with which the feedback will be provided. Propose two (2) actions company leaders should take to...
-
Middle East Analyze the political, economic, legal and cultural environment of the region (Middle East) and outline the challenges and opportunities of conducting business in that region. Possible...
-
Scenario 1: Joey is a 15 year old who is ready to work, but his parents want him to have more responsibility with money first. His parents have already set up checking and savings accounts for him at...
-
Explain how the relative prices of rugs and robots in autarky compare with the relative prices when Canada and India start to trade? In your answer explain which country will export/import which...
-
A single nuclear reactor produces 2.6GW of electrical power, and has a generator voltage of 22kV.What percentage of power would be lost from our nuclear reactor in three-line transmission that goes...
-
16. Brenda's Balloon Shop is a price taker, and the table below shows its costs of production. Use it to answer the following questions: Output (balloons Total Cost (dollar per hour) per hour) 0 4 1...
-
Let, f (a) = a* + 2a? x 3 x* + 2x? x 3 91 (x) = (*+ 3 4 2 x + 3 2. 92 (a) x2 + 2 3x4 + 2x? + 3 93 (x) 4x3 + 4x 1 (b) Perform 4 iterations (upto 4, if possible) with ao = land the recursion...
-
d. The characteristic equation of a control system is given by s+2s+8s+12s+20s+16+16=0. Determine the number of the roots of the equation which lie on the imaginary axis of s-plane
-
The 2010 U.S. Census also asked for each persons age. Suppose that a sample of 40 households taken from the census data showed the age of the first person recorded on the census form to be as...
-
Work the following binomial distribution problems by using the normal distribution. Check your answers by using Table A.2 to solve for the probabilities. a. P(x = 12 | n = 25 and p = .60) b. P(x > 5...
-
Use the following contingency table to test whether variable 1 is independent of variable 2.Let a α =.01. Variable 2 203 326 68 110 Variable 1
-
Tell us about any past critical situation in which you had to make an immediate decision.
-
If air resistance is neglected, the motion of an object projected at an angle consists of a uniform downward acceleration combined with (a) an equal horizontal acceleration, (b) a uniform horizontal...
-
A unit vector has (a) magnitude, (b) direction, (c) neither of these, (d) both of these.
Study smarter with the SolutionInn App