Question

C++ For the followin gequations draw the binary tree and show the output through the required...

C++

For the followin gequations draw the binary tree and show the output through the required traversal methods.

1. a+b[pre-order]

2. a-(b*c)[in-order]

3) (a<b) or (c<d) [post-order]

4) x: =(-b+(b^2-4*a*c)^0.5)/(2*a) [in-order]

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

  • In Preorder, first, the root is visited, then the left subtree is traversed and then the right subtree. So, "a" should be the left subtree and "b" should be the right subtree and "+" will be the root.


2.

  • In order traversal, first, the left subtree is traversed, then the root is traversed and then the right subtree is traversed.
  • So, in this "a" should be in the left subtree and "b*c" should be in the right subtree and after the computation of "b*c", it will be subtracted from the left subtree.

3.

  • In post order, first, the left subtree is computed, then the right subtree is computed and after that with the help of root, the left and right results are computed.
  • So, in this case, "a <b" becomes the left subtree and "c<d" becomes the right subtree of "or".

4.

  • In order traversal, first, the left subtree is traversed, then the root is traversed and then the right subtree is traversed.

Friend, this was a really nice question to answer. If you find my answer helpful, please like it. Thanks.

Add a comment
Know the answer?
Add Answer to:
C++ For the followin gequations draw the binary tree and show the output through the required...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Data structures Exercises: For the following binary tree (Index-Value): 0 1 2 3 4 5 6...

    Data structures Exercises: For the following binary tree (Index-Value): 0 1 2 3 4 5 6 7 8 9 A C E G B P D X F H Give the pre-order traversal. Give the post-order traversal. Give the in-order traversal. Determine the height of the tree. Using these values: 8 6 4 3 5 9 2 1 6 Build a binary search tree. Build an AVL Tree. Build a 2-3 Tree. Build a min-heap. Build a max-heap. Apply a...

  • PROBLEM 6: Suppose we insert keys below into an initially empty Vanilla binary search tree in...

    PROBLEM 6: Suppose we insert keys below into an initially empty Vanilla binary search tree in the given order: 6, 9, 2, 1, 5, 7, 10, 8, 3, 4 (a) Draw the resulting binary search tree. (b) List the keys according to: A pre-order traversal An in-order traversal A post-order traversal (c) Now we perform some deletions using the “deletion by copying” strategy in which promoted keys are always drawn from a node’s right subtree (so that there is only...

  • PROBLEM 6: Suppose we insert keys below into an initially empty binary search tree in the...

    PROBLEM 6: Suppose we insert keys below into an initially empty binary search tree in the given order 6, 9, 2, 1, 5, 7, 10, 8, 3,4 (a) Draw the resulting binary search tree. (b) List the keys according to: A pre-order traversal An in-order traversal A post-order traversal (c) Now we perform some deletions using the "deletion by copying" strategy in which promoted keys are always drawn from a node's right subtree (so that there is only one correct...

  • Given the following binary tree (where nullptr height == -1): A. What is the height of...

    Given the following binary tree (where nullptr height == -1): A. What is the height of the tree? B. What is the depth of node 90? C. What is the height of node 90? D. Give the pre-order, in-order, and post-order traversal of this tree. 0100 0050 0150 0125) 0152 0003 0080 000100200052 00830009

  • I need question 9-10 answered. Thank you Question 1 iShow the resulting binary search tree if...

    I need question 9-10 answered. Thank you Question 1 iShow the resulting binary search tree if we are to insert following elements into the tree in given order, [34, 12, 23, 27,31,9,11,45, 20, 37. i) Show the resulting balanced binary search tree if we are to insert following sorted elements into the tree, [9,12,21, 23, 29, 31, 34, 45, 48, 52, 55] iii What is the pre-order traversal of the balanced binary search tree? v) What is the post-order traversal...

  • Consider the given binary search tree (BST). 1. What is the maximum size of the array...

    Consider the given binary search tree (BST). 1. What is the maximum size of the array required to implement the above BST? 2. Draw the array-based binary tree that represents the given BST (use the Table tool above to draw the array or just write it on one line and explain it) 3. Print the given BST using the in-order traversal pattern (don't write code, just show the output) HTML Editor BIVA -A- IEE311 X, EE Do NVX 12pt Paragraph...

  • Can someone help with these two problems? The following binary tree contains the characters 'A' through...

    Can someone help with these two problems? The following binary tree contains the characters 'A' through 'G' in its nodes. List the nodes in the order that they are visited by: A preorder traversal. An inorder traversal. A postorder traversal. The binary tree in Problem 2 is a Binary Search Tree since for every node, all elements stored in the left subtree of the node are smaller than the element in the node and all elements stored in the right...

  • Tree & Hash Table & Heap Use the following integer keys 73, 58, 91, 42, 60, 130, 64, 87 to perform the followings: a) Binary Search Tree - Draw a binary search tree - Retrieve the integers ke...

    Tree & Hash Table & Heap Use the following integer keys 73, 58, 91, 42, 60, 130, 64, 87 to perform the followings: a) Binary Search Tree - Draw a binary search tree - Retrieve the integers keys in post-order - Retrieve the integers keys in pre-order - Draw a binary search tree after node 58 is deleted b) Create a Hash Table using the methods described below. Show the final array after all integer keys are inserted. Assumes that...

  • Consider the AVL Tree built by inserting the following sequence of integers, one at a time:...

    Consider the AVL Tree built by inserting the following sequence of integers, one at a time: 5, 2, 8, 7,9 Then we insert 11. After we insert 11, before we perform any necessary rotations, is the tree balanced? And if not, which is the root of the lowest imbalanced subtree? (a) None, since the tree is already balanced after inserting 11. (b) The node containing 5. (c) The node containing 8. (d) The node containing 11. (e) The node containing...

  • 3. (8 points) Using the implementation of binary search tree operations we discussed in class, draw...

    3. (8 points) Using the implementation of binary search tree operations we discussed in class, draw the trees that result from the following operations: (a) Inserting 142, 400, 205, 127, 100, 320, 160, 141, and 110 into an initially-empty tree (in that order). (b) Deleting 142 from the tree you drew for part (a). 4. (8 points) Draw the unique binary tree that has a preorder traversal of 4, 1, 6, 3, 7, 5, 9, 2, 8 and an inorder...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT