Question

Show how we visualize the binary search tree with root referenced by rootA (page 490) after each of the following changes. Al
rootA 0 K T D M R Y B J Р W N. only part C D E F
(write the sequence of method as well)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

c. Node cannot be inserted, no duplicate keys allowed in binary search tree.

d. As M has only the right sub tree, it can be substituted in the place of M, so the resulting tree will be as fillowsM U QS k

e. To remove Q: Q has both left and right subtrees, so we can remove Q by replacing it with the largest element of the left subtee(i.e., p) or with the smallest value of the right subtree(i.e., r). By doing so the property of the binary search tree can be maintained. We choosing the first option. So the resulting tree will take the following form:

k n w

f. As R is a leaf node, it can be simply removed, this will not violate the property of the binary search tree.

k M

Add a comment
Know the answer?
Add Answer to:
only part C D E F (write the sequence of method as well) Show how we...
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
  • part (C, F ) only. With the java code (write the sequence of method calls as...

    part (C, F ) only. With the java code (write the sequence of method calls as well) Trees and java code please provide me your email, ill send the code there Show how we visualize the binary search tree with root referenced by rootA (page 490) after each of the following changes. Also list the sequence of Binary- SearchTree method calls, both public and private, that would be made when executing the change. Use the original tree to answer each...

  • SHOW HOW WE VISUALIZE THE BINARY SEARCH TREE WITH ROOT REFERENCED BY ROOT A. AFTER EACH...

    SHOW HOW WE VISUALIZE THE BINARY SEARCH TREE WITH ROOT REFERENCED BY ROOT A. AFTER EACH OF THE FOLLOWING CHANGES, ALSO LIST THE SEQUENCE OF BINARY SEARCH TREE METHOD CALLS, BOTH PUBLIC AND PRIVATE, THAT WOULD BE MADE WHEN EXECUTING THE CHANGE. USE THE ORIGINAL TREE TO ANSWER EACH PART OF THIS QUESTION. a) ADD NODE Q. (write the sequence of method call as well). b) REMOVE NODE R. (write the sequence of method call as well). rootA M R...

  • SHOW HOW WE VISUALIZE THE BINARY SEARCH TREE WITH ROOT REFERENCED BY ROOT A. AFTER EACH...

    SHOW HOW WE VISUALIZE THE BINARY SEARCH TREE WITH ROOT REFERENCED BY ROOT A. AFTER EACH OF THE FOLLOWING CHANGES, ALSO LIST THE SEQUENCE OF BINARY SEARCH TREE METHOD CALLS, BOTH PUBLIC AND PRIVATE, THAT WOULD BE MADE WHEN EXECUTING THE CHANGE. USE THE ORIGINAL TREE TO ANSWER EACH PART OF THIS QUESTION. A) ADD NODE Q. B) REMOVE NODE R. DO THE QUESTION ABOVE WITH REFERENCE TO ROOT A GIVEN ABOVE. AND ALSO LIST THE SEQUENCE OF BINARY SEARCHTREE...

  • Java eclipse question. Given a binary search tree -------------M ---------G ---------N ------D----- H ---B----F How woul...

    Java eclipse question. Given a binary search tree -------------M ---------G ---------N ------D----- H ---B----F How would you find the farthest from the root and most right side of the node? So, in this case, farthest nodes are B and F with height of 4 But the most right side of the node is F Therefore answer is F. I have //Will call helper method. public T findRightmostLowest(){ int lv = height();//This is the maxium height of the tree(4 in this...

  • CAN SOMEONE PLEASE SOLVE THIS? THANK YOU. FINALTREE.JAVA: import java.util.LinkedList; public class FinalTree<E extends Comparable<? super...

    CAN SOMEONE PLEASE SOLVE THIS? THANK YOU. FINALTREE.JAVA: import java.util.LinkedList; public class FinalTree<E extends Comparable<? super E>> { private Node<E> root; private int size; public FinalTree() { root = null; size = 0; } public boolean isEmpty() { return size == 0; } public void add(E newItem) { if (isEmpty()) { root = new Node<E>(newItem); } else { Node<E> parent = null; Node<E> temp = root; int result = 0; while (temp != null) { parent = temp; result =...

  • Java help! Please help complete the min method below in bold. import java.util.Arrays; import java.util.ArrayList; import...

    Java help! Please help complete the min method below in bold. import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; /** * Provides an implementation of a binary search tree * with no balance constraints, implemented with linked nodes. * * * */ public class Bst<T extends Comparable<T>> implements Iterable<T> { ////////////////////////////////////////////////////////////////// // I M P L E M E N T T H E M I N M E T H O D B E L O W...

  • I need to do a tree sort method but the treesortMethod is not working /****Binarytree class****\...

    I need to do a tree sort method but the treesortMethod is not working /****Binarytree class****\ package Tree; public class BinaryTree { private TreeNode root; // head of the list    //constructor - create an empty binary tree public BinaryTree() { root = null;    }    //isEmpty() - return true if tree is empty, false otherwise public boolean isEmpty() { return (root == null); }    //deleteTree() - remove all items from tree public void deleteList() { root =...

  • C++ Write a public member function incrementNodes for a BinaryTree class that will add 1 to...

    C++ Write a public member function incrementNodes for a BinaryTree class that will add 1 to each item in the binary tree. If this function calls any other function, you must write the code for that function as well. Note that the class BinaryTree has a private member variable root which is a Node pointer.

  • BST JAVA FILE import java.util.*; public class BST <E extends Comparable <E>> {    private TreeNode<E>...

    BST JAVA FILE import java.util.*; public class BST <E extends Comparable <E>> {    private TreeNode<E> overallRoot;    public BST() {        overallRoot = null;    }    // ************ ADD ************ //    public void add(E addThis) {        if (overallRoot == null) {            overallRoot = new TreeNode<>(addThis);        } else {            add(overallRoot, addThis);        }    }    private TreeNode<E> add(TreeNode<E> node, E addThis) {        if...

  • C++ Binary Search Tree question. I heed help with the level 2 question please, as level...

    C++ Binary Search Tree question. I heed help with the level 2 question please, as level 1 is already completed. I will rate the answer a 100% thumbs up. I really appreciate the help!. Thank you! searching.cpp #include <getopt.h> #include <iostream> #include <sstream> #include <stdlib.h> #include <unistd.h> using namespace std; // global variable for tree operations // use to control tree maintenance operations enum Mode { simple, randomised, avl } mode; // tree type // returns size of tree //...

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