Draw the result of taking the tree in the diagram

Assignment Help JAVA Programming
Reference no: EM131282581

You must observe the following requirements (for all homework submitted in this course):

All programs should be literate, i.e., easily understandable by a human (say, your grader) and follow the Java Style Guidelines for CS112 posted on the class web site;

All files for this homework should be submitted using WebSubmit, following the instructions on the class web site;

You may not use data structure libraries such as ArrayList, since we are learning to write Java from the ground up and you must learn how these libraries are built; however, you are free to use (unless specifically directed otherwise) the basic libraries String, Character, Scanner, and Math; for this assignment, you may also use Double.parseDouble(....);

You may freely use code from the class web site, the textbook, or lecture (unless specifically directed otherwise) as long as you cite the source in your comments; but you may NEVER use code from the web or other students' programs.

Part A: Analytical Problems

Before getting started on the remaining problems, review the lecture and textbook materials on binary search trees and recursion. The following problems have to do with the BST in this diagram:

1481_Figure.png

In these problems, draw your solution trees in "ASCI art" sideways, so the tree above would be rendered as:

            46
        43
            31
    19
        17
11
            10
        8
    6
 
            5
        4

1. : For this tree, give the (a) size, (b) depth of the node 31, (c) height, (d) length of the path from 11 to 49, and (e) list of all leaf nodes.

2. (a) Draw the result of inserting the keys 15, 7, 16, 12, & 13 into this tree; (b) assuming we can only insert integers, and no duplicates, into the original tree, what keys could possibly be inserted to the left of 31?

3. (a) Draw the result of taking the tree in the diagram and deleting the root three times using the deletion algorithm from lecture and the web (i.e., when deleting a node with two children, move up the least element from the right subtree); (b) suppose we do not wish to unbalance the tree by deleting from the same side each time, and we decide that we will alternately delete from the right, left, right, left, etc. (starting with the right); delete the root of the tree in the diagram 4 times using this new strategy and show the resulting tree.

4. Let us call a tree "perfect" if it is a perfect triangle, i.e.,

1172_Figure2.png

Suppose H is the height of a perfect binary tree, and N the number of nodes; (a) express H as a function of N, and (b) N as a function of H.

5.: Suppose we are going to insert the letters A, B, C, and D, into an initially empty BST. If we insert them in order, we get a pathological tree which is really just a linked list (and whose worst case time to find a node is linear, i.e., Theta(N)). But there are many different worst cases! (a) List 5 more of the the possible worst cases (hint: there are 8 in all!). Now suppose we have the letters A, B, C, D, E, F, and G. We would like to have a perfect tree which has the shape of a perfect triangle: for example, we could insert in the order D, B, F, A, C, E, G. (b) List 5 more of the possible insertion orders that would give you a complete binary search tree.

Reference no: EM131282581

Questions Cloud

Describe the situation facing mensa at the time of the case : Describe the situation facing Mensa at the time of the case. This should include the major issues facing the company and the decisions that need to be made. You are to spend no time on corporate history.
Which of two constellations has minimum average energy : The two signal constellations shown in Figure exhibit the same average probability of symbol error. Justify the validity of this statement.
How would you as the nurse epidemiologist methods : list two different data collection methods that could be initiated in order to further investigate and address this infection control issue in your facility? How would you as the nurse epidemiologist and nurse researcher ensure these methods are r..
Draw an e-mosfet showing the p and n regions : Draw an E-MOSFET showing the p and n regions. Then, explain the off -on action.
Draw the result of taking the tree in the diagram : Draw the result of taking the tree in the diagram and deleting the root three times using the deletion algorithm from lecture and the web
Advantages and disadvantages of bjt and fet amplifiers : Draw any circuit that shows a power FET controlling a large load current. Explain the off -on action. Include RDS(on) in your discussion.
What economic and societal factors affect the demand : How has the emergence of different types of health insurance plans-FFS, health maintenance organizations (HMOs), preferred provider organizations (PPOs), and capitation-affected the trends in healthcare services today?What economic and societal fa..
Show that three symbols constitute a simplex code : Consider a set of three equally likely symbols whose signal constellation consists of the vertices of an equilateral triangle. Show that these three symbols constitute a simplex code.
Discuss the european unions effort at monetary union : Discuss the European Union's effort at monetary union. Which countries are participating? How might that affect these countries? Other countries? Give two examples that support your ideas.

Reviews

len1282581

11/19/2016 6:01:09 AM

Detailed Question: The assignment instruction is on http://www.cs.bu.edu/~snyder/cs112/Homeworks/HW10/hw10.html I only want u to help me to finish B.3 problem. U also can find my class notes on http://www.cs.bu.edu/~snyder/cs112/Home.html There are a bunch of links there I just need the program u give me can pass all the test. U don't need to concern the the verboseness of the code.

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd