Question

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 heap-sort.

Build an expression tree for the following expressions.
2 + 5
2 * 5 - 3
(2 + 5) * 3
(2 - 5) - (3 + 4) * 5 + 1

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

Solution:

Binary tree is a tree which has atmost 2 children.

Preorder traversal is a traversal through rootnode, leftnode and rightnode

Postorder traversal is a traversal through leftnode, rightnode and rootnode

Inorder traversal is a traversal through leftnode, rootnode and rightnode.

Height of the tree is the longest number of edges from the rootnode to the leaf node.

Binary search tree is a binary tree where left node is smaller than the root node and right node is greater than the root node.

0 Given, Binary tree: 0 1 2 3 4 5 6 7 8 9 A C E G B PDX FH Now, Constructing wy tree based on given index. -values Pre-Orderpost-order Traversal, - Left node, right node, root node. there we consider the teft node right node and last node at the fir4 Height of the tree ! the tree ! 06 No of edges from hen, we have 3 the root edger node from to the leaf. root to the leaf.step. y Step 5 54 Ro right 4. Step 6 938, so right Step & 223, so left of 3.step- 8 14mm for ఈ00000 This is the resulting Buary bearch tree

Add a comment
Know the answer?
Add Answer to:
Data structures Exercises: For the following binary tree (Index-Value): 0 1 2 3 4 5 6...
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
  • 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...

  • Prob. 3. Given the following data 50 40 23 36 19 20 9 a) Is this...

    Prob. 3. Given the following data 50 40 23 36 19 20 9 a) Is this a max heap, draw the tree and check if this is a max heap. b) Illustrate how you would add a new data 46 to the existing maxheap. c) From the answer obtained in part b, illustrate how you would delete the data 40 d) Now illustrate heap sort with the existing data after step c. Give steps, and find runtime. Runtime|Explanation of Algorithm...

  • 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...

  • Trees and Heaps 1. Show that the maximum number of nodes in a binary tree of...

    Trees and Heaps 1. Show that the maximum number of nodes in a binary tree of height h is 2h+1 − 1. 2. A full node is a node with two children. Prove that the number of full nodes plus one is equal to the number of leaves in a nonempty binary tree. 3. What is the minimum number of nodes in an AVL tree of height 15? 4. Show the result of inserting 14, 12, 18, 20, 27, 16,...

  • Answer the following questions regarding the following data structures: i. 11 ii. 4 iii. 2 iv....

    Answer the following questions regarding the following data structures: i. 11 ii. 4 iii. 2 iv. 5 v. 7 vi. 5 / \ / /|\ / \ /|\ \ 17 22 2 3 4 5 3 7 3 4 8 7 /\ /\ \ \| / \ / \ /|\ \ / \ 6 2 9 33 3 9 2 5 8 1 2 5 9 6 9 Which are valid trees? List all correct answers. Which are valid binary...

  • a) Create a binary search tree with the 4 2 2 0 1 4 5 9...

    a) Create a binary search tree with the 4 2 2 0 1 4 5 9 7 1 5 3 6 number. b) Provide the Preorder, Inorder and Postorder traversal of tree obtained in part (a). Show all the steps.

  • Tree & Hash Table & Heap Use the following integer keys 73, 58, 91, 42, 60,...

    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...

  • anvas A Question 7 5 pts A binary heap's structure is an AVL tree a particular...

    anvas A Question 7 5 pts A binary heap's structure is an AVL tree a particular case of binary search tree a complete binary tree a sparse tree Question 8 5 pts The time taken to find an element in an AVL tree of depth dis Old) Ollogd Old2) Odlog d) Question 9 5 pts Deleting the minimum element in a min-heap of Nelements takes in average case Ollog N ON 011 OIN log N

  • anvas A Question 7 5 pts A binary heap's structure is an AVL tree a particular...

    anvas A Question 7 5 pts A binary heap's structure is an AVL tree a particular case of binary search tree a complete binary tree a sparse tree Question 8 5 pts The time taken to find an element in an AVL tree of depth dis Old) Ollogd Old2) Odlog d) Question 9 5 pts Deleting the minimum element in a min-heap of Nelements takes in average case Ollog N ON 011 OIN log N

  • 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...

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