Question

root

  1. [DSW] Create a balanced binary tree from the tree in figure 1 using DSW algorithm. Show step-by-step process including the process of
    1. creating backbone and   
    2. perfectly balanced tree  
  2. [AVL]
    1. Delete node 9 from tree in figure 1, then determine balance factor for each remaining node, and create a balanced AVL tree from it.   
    2. Delete node 3 from tree in figure 1 by using Delete-by-Copying procedure, determine balance factor for each remaining node, and create a balanced AVL tree from it.
    3. Insert a node with 10 as the key to tree in figure 1, determine balance factor for each node after the insertion, and create a balanced AVL tree from it.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

temp ay DSW. (a) 9x temp Tamp CREATING BACKBONE.

Oñol -6-4-4-a I 2- 2-4-5-6-off 4 -a 1 3 5 7 9 bt ç 3 BALANCING THE BACKBONE.

Balance fotor = Height (Left subs tous). Height (Right cub bul). Balance factor of ③ = 2-4 = -2 Bolame factor of 2-1-0-1 Bala

Node 6 is imbalanced To balance we need R. L rotation. I after RL notation By i all modes have balance factor either 1,0,1 He

THE INORDER SUCCESSOR OF NODE IS NODE IS COPIED ON © and is DELETED HENCE THE TREE BECOMES o Oro Balame factor of © 2-4= -2 ☺

SINCE O IS UNBALANCED BY LLROTATION HENCE THE AVL TREE IS BALANCED.

(ii) BY BINARY SEARCH TREE INSERTION LOGIC. Balame factor of ☺: 2-52-3 0.0 6 = 1-4 = -3 -0 6 0 -3--3 = 0 0:0 G) 1-2--1

© IS UN BALANCED. BY RL ROTATION. 0 0.0 0 ® ILUNBALANCED BY LL ROTATION PLANCED oo 0 a BIS UNBALANCED By RL ROTATION OF

yu BALANC IN © by RR ROTATION BALANCING 4 BY LL ROTATION BALANCIN 4 BY LA ROTATION HENCE THE AVL TREE IS BALANCED.

Add a comment
Know the answer?
Add Answer to:
[DSW] Create a balanced binary tree from the tree in figure 1 using DSW algorithm. Show...
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
  • Given the follow Binary Search Tree (AVL Tree). Show the balance factor for each node. Is...

    Given the follow Binary Search Tree (AVL Tree). Show the balance factor for each node. Is this binary tree balanced? If not which nodes would have to be removed to make it balanced?   

  • PYTHON QUESTION... Building a Binary Tree with extended Binary Search Tree and AVL tree. Create a...

    PYTHON QUESTION... Building a Binary Tree with extended Binary Search Tree and AVL tree. Create a class called MyTree with the methods __init__(x), getLeft(), getRight(), getData(), insert(x) and getHeight(). Each child should itself be a MyTree object. The height of a leaf node should be zero. The insert(x) method should return the node that occupies the original node's position in the tree. Create a class called MyBST that extends MyTree. Override the method insert(x) to meet the definitions of a...

  • 1 Binary Search Trees (25 points) Consider the binary tree as shown in Figure 1. 9...

    1 Binary Search Trees (25 points) Consider the binary tree as shown in Figure 1. 9 5 15 10 17 8 Figure 1: Binary Tree: The letter next to each node (e.g., a, b) denotes the tree node, and the number inside each node is the key. 1.1 Correctness (10 points) Is this binary tree a valid binary search tree? In other words, does it satisfy the binary search tree property? If not, which node(s) violates the binary search tree...

  • a) Show balance factor of every node after each insertion by creating an AVL tree with...

    a) Show balance factor of every node after each insertion by creating an AVL tree with 4,2,2,0,1,4,5,9,7,1,5,3,6 number. Express all operations (single/double rotation) necessary to restore the balance. b) Create min and max heap using the same input as in part (a) by showing all the necessary steps.

  • Using C Please comment Part 1: BST Create a link based Binary Search tree composed of a Node and a Tree struct. You should have a header file, BST.h, with the following: o Node struct containing...

    Using C Please comment Part 1: BST Create a link based Binary Search tree composed of a Node and a Tree struct. You should have a header file, BST.h, with the following: o Node struct containing left, right, and parent pointers, in addition to holding an Data struct value Tree struct containing a pointer to the root of the tree A function declaration for a function that allocates a tree, and initializes the root to NULL o o o A...

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

  • A balanced binary tree is a binary tree structure in which the left and right subtrees of every node differ

    Data structures C++1- A balanced binary tree is a binary tree structure in which the left and right subtrees of every node differ in height by no more than 1 Out of the following choices, which is the minimum set of nodes, if removed, will make the BST balanced?2- Which of the following is true for Red-Black Trees ? Select all choices that apply! Select one or more: a. For each node in the tree, all paths from that node to any leaf nodes contain...

  • Q1: How many levels your binary search tree has (including level 0)? Is the binary search tree you created height balanc...

    Q1: How many levels your binary search tree has (including level 0)? Is the binary search tree you created height balanced? 2.1 Click the animations “Binary Search Tree”. Click “Insert” button to insert the following elements in the sequence, “50, 20, 30, 70, 90, 80, 40, 10, 5, 60, 85, 95”. http://algoanim.ide.sk/index.php?page=showanim&id=44 Q2: What is the insertion process of the binary search tree? The new identical element is inserted as left or right child of the existing same value? 2.3...

  • IN JAVA 2 A Binary Search Tree The goal of this lab is to gain familiarity...

    IN JAVA 2 A Binary Search Tree The goal of this lab is to gain familiarity with simple binary search trees. 1. Begin this lab by implementing a simple class that represents a "node” in a binary search tree, as follows. public class MyTreeNode<t extends Comparable<T>> { public T data; public MyTreeNode<T> leftchild; public MyTreeNode<T> rightChild; public MyTreeNode<T> parent; 2. Have the second member of your pair type in the code for the simple binary search tree interface. public interface...

  • Q1: How many levels your binary search tree has (including level 0)? Is the binary search...

    Q1: How many levels your binary search tree has (including level 0)? Is the binary search tree you created height balanced? 2.1 Click the animations “Binary Search Tree”. Click “Insert” button to insert the following elements in the sequence, “50, 20, 30, 70, 90, 80, 40, 10, 5, 60, 85, 95”. http://algoanim.ide.sk/index.php?page=showanim&id=44 Q2: What is the insertion process of the binary search tree? The new identical element is inserted as left or right child of the existing same value? 2.3...

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