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

  Java application-tests random number generation abilities

Write a Java application which tests the random number generation abilities of Java. Random number generation is explained below.

  Write down a java program that implements a stack of

write a java program which implements a stack of integers. an integer should only be pushed into the stack if it is

  Problem 1 the queue adta queue is a fundamental abstract

problem 1. the queue adta queue is a fundamental abstract data type. it is an ordered collection of items in which the

  File integrity checker - tripwire

Write a program that will perform some of the basic tasks accomplished by a file integrity checker such as Tripwire.

  Outline a test plan for a substantial real-life system

Describe how you would approach the design and testing process to ensure success and quality in the result and where are the risks? How are you going to address them?

  How many employee objects exist in the heap

Assume you have a class called Employee whose constructor takes two arguments: the employee's name and id number

  Prepare a java program to create a bank account

Write a client java program that will use a pre-implemented class BankAccount.java. BankAccount class provides template to create BankAccount objects that represent real world bank accounts

  What is server-side and client-side scripting

What is Server-side and Client-side scripting - Explain the differences between server-side and client - side scripting languages.

  Create an algorithm in java

Create an algorithm in java which will provide the Dijkstras shortest path in a graph provided by the user - The output should display the shortest path.

  Sorted list adt and the binary search tree adt

Explain the differences between our specifications of the Sorted List ADT and the Binary Search Tree ADT.

  1 what makes a program easy to modify2 describe the order

1. what makes a program easy to modify?2. describe the order of magnitude of the following code section using bigo

  Write a program that takes as input student scores

Write a program that takes as input student scores from a file and outputs the average for each student to a file.

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