Ask Question, Ask an Expert


Ask Programming Language Expert

The purpose of these programming problems is to gain experience using the array implementations of a binary tree.

Programming Problems (to be handed in):

problem 1: Use a random number generator to create 10 numbers between 1 and 1000 and store them in 2 different arrays.  The first array should contain the numbers as they are generated. The second should store the same numbers in a tree implemented as acomputed link array using the strategy described below:

• The first element generated will be the root

• The rest of the elements will be stored in the left subtree if it is smaller than the root (or parent), otherwise it is stored in the right subtree.

• When entering the left subtree, the same strategy must be used to find the proper place in the left subtree (if new element is less than the parent, go into left subtree, otherwise go into right subtree).

• Continue this pattern until an empty spot is found in the array, and store the element there.

Ii is suggested to make your computed link array capable of holding at least 20 items, since there will be wasted space.

Once you’ve created the binary tree, then implement the inorder visit code from the lecture slides and conduct an inorder visit on the tree you created printing out each parent as you visit it.  If you’ve set up the tree correctly, the output numbers should be sorted.

For this problem, output the original data, the data as stored in the computed link array (and draw lines on your output to show the children of each parent), and the output obtained from the inorder visit.

problem 2: The same as problem 1, except that the stored link implementation is to be used to store the numbers as generated.  In this case the array has only 10 storage areas (no wasted space, but be careful how you stop the search to find the correct spot). 



Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M9389

Have any Question? 

Related Questions in Programming Language

Programdemonstrate the ability to create a program that

Program Demonstrate the ability to create a program that utilizes the Observer design pattern. Demonstrate the ability to create abstract classes and implement derived classes. Demonstrate the ability to create and itera ...

Assignmentinstructionsfor formload display use a textbox

Assignment Instructions: For Form_Load display, use a textbox and check its "multiline" checkbox. To display data on Form_Load, use a txtOutput. AppendText() method (i.e. NOT a listbox control). 1. Declare a global array ...

Design a class named pet which should have the following

Design a class named Pet, which should have the following fields: •Name - The name field holds the name of a pet. •Type - The type field holds the type of animal that is the pet. Example values are "Dog", "Cat", and "Bir ...

Rainfall programwrite a rainfall program that stores the

Rainfall Program Write a RainFall program that stores the total rainfall for each of 12 months into an array of doubles. The program should have methods that return the following: * The total rainfall for the year * The ...

Assignmentwrite a console application to meet the following

Assignment Write a console application to meet the following requirements. Create a system for a simple library. The library has a name and a list of books. Each book has a title, author and an int as the id number. Defi ...

Suppose a basic block is formed from the c assignment

Suppose a basic block is formed from the C assignment statements x = a + b + c + d + e + f; y = a + c + e; a) Give the three-address statements (only one addition per statement) for this block. b) Use the associative and ...

Write an abstract superclass encapsulating a vacation a

Write an abstract superclass encapsulating a vacation: A vacation has two attributes: a budget and a destination. It has an abstract method returning by how much the vacation is over or under budget. This class has two n ...

The car classdefine a class called car that implements the

The Car Class Define a class called "Car" that implements the parameterized Comparable interface. Each object of this class represents a type of car. Your class must provide all the methods in the public interface. Be su ...

Assignmenta student had to make a decision on how to be

Assignment A student had to make a decision on how to be paid. The student could accept a straight $10/hour or take 10 cents for the first hour, but have the hourly wage double each hour. That is, the student would make ...

Question 1 batteriesi want to use a galvanic cell to power

Question 1: Batteries I want to use a galvanic cell to power a 60-watt light bulb. Complete the following steps to determine how long the galvanic cell will power the light bulb before running out. a.) The galvanic cell ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

WalMart Identification of theory and critical discussion

Drawing on the prescribed text and/or relevant academic literature, produce a paper which discusses the nature of group

Section onea in an atwood machine suppose two objects of

SECTION ONE (a) In an Atwood Machine, suppose two objects of unequal mass are hung vertically over a frictionless

Part 1you work in hr for a company that operates a factory

Part 1: You work in HR for a company that operates a factory manufacturing fiberglass. There are several hundred empl

Details on advanced accounting paperthis paper is intended

DETAILS ON ADVANCED ACCOUNTING PAPER This paper is intended for students to apply the theoretical knowledge around ac

Create a provider database and related reports and queries

Create a provider database and related reports and queries to capture contact information for potential PC component pro