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.
Answer:
D) Inorder : 0001 , 0003 , 0020, 0050 , 0052 , 0080 , 0083, 0090 , 0099 , 0100 , 0125 , 0150 , 152
Post Order : 0001 , 0020 , 0003 , 0052 , 0083 , 0099, 0090 , 0080, 0050 , 0125, 152 , 150 , 0100
Trick for finding preorder , postorder and inorder of a tree : For Pre - order - Traverse the tree from top to bootom and left to right, when you visit the node first time print it.
For Inorder - Whenever you vist the node second time , print it.
For Post Order : When you visit the node 3rd times print it.

Given the following binary tree (where nullptr height == -1): A. What is the height of...
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the depth of the two subtrees of every node never differ by more than 1. Use following Node class, no height is stored in the Node /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; }...
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...
(b) Given the following tree (graph) as shown in Figure 2: Diberi pepohon (graf) seperti yang ditunjukkan dalam Rajah 2: Figure 2 Rajah 2 (i) Find the pre-order traversal of the tree. Cari penyusuran pepohon "pre-order". (8/100) (ii) Find the post-order traversal of the tree. Cari penyusuran pepohon "port-order". (8/100) (iii Using the ordering c, d, e, f, g, h, i, j, k, I, m, a, b, c and the depth-first search algorithm, find a spanning tree for the graph...
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...
A Binary Search Tree is a binary tree where nodes are ordered in the following way: each node contains one key (also known as data) the keys in the left subtree are less than the key in its parent node the keys in the right subtree are greater than the key in its parent node duplicate keys are not allowed Create a Binary Search Tree inserting the following list of numbers in order from left to right. 10, 6, 4, 8, 18, 15, 21 Please type...
Question 39 Binary Trees: Traversal Describe the binary tree shown using depth-first, in order traversal (image t) void print TreeNode * start = nullptr){ // by default, we'll print from the head if (start == nullptr) // if nullptr, then we should start from the head start = head; if ( start->left != nullptr) printTree( start->left ) cout<< start-value << ", "; // print the current node if ( start->right != nullptr) printTree( start->right) } 12 15 10 14 18...
Insert the following values in the given order into a Binary Search Tree and use the resulting BST in the next 5 questions. 15 8 3 6 23 9 11 10 20 13 5 9. What is the height of the resulting Binary Search Tree? 10. What is the depth of the node that stores the value 11? 11. Is there a path from the node storing the value 15 to the node storing the value 5? If so, show...
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...
Assume you are given “preorder” and “inorder” traversal result of a Binary Tree. Write an algorithm (pseudocode) that constructs the Binary Tree. For example, you can start with the Pre-Order and In-Order traversal of the same tree given below. Pre-Order = 80, 50, 10, 70, 100 In-Order = 10, 50, 70, 80, 100
Apply Preorder and Inorder traversal algorithms on the following binary tree and write the output. Remove node 11 from the tree and show the tree after deletion. 0007 0005 0011 0003 0006 0010 0012 0009 0024 0023