Ask Computer Engineering Expert

Assignment: Binary Search Tree Heights

For this project, we will be empirically evaluating a binary search tree and comparing it to our own calculated analysis. To do this, we will use varying types of input values and chart out how the BST responds to the stimuli. We will test the BST with sorted data, perfectly balanced data, and randomly ordered data.

Your implementation needs to conform to a few standards. Notably, the BST MUST use templating to define what kind of data type it holds. The code must also use a Makefile to build, test, run, and clean the program. I have provided a testing object to give you the different data sets we'll be testing with, a working Makefile, and code that should compile (but not do anything useful).

During this course, I will be giving you less and less initial help with the programming assignments. This one has a strong framework for beginning, but the next one will rely more on what you've learned from this project. Make sure to read through the code to see a few key items:

1) How templating works in header files
2) How command line options are passed to the program
3) How I wrote up the makefile so you could add or edit it for your own uses

Binary Search Tree (BST)

The code for this project is written in the expected C++11 language and tested using g++ on the EECS SSH servers. I have provided the interface for the BST, but very little of it is implemented. The code compiles, but there's no output.

You are to implement the BST. The most important features will be:

1) void add( value ) -> Inserts an integer into the tree
2) int height() -> calculates the height of the tree
3) void printPreOrder() -> prints out the tree in pre order to STDOUT for inspection

There might be other functions or pieces you'll need to build, but that's up to your approach to the implementation.

Statistics

Once you have a working BST implementation. You need to run it with several data sets and output the data to a CSV file. If you're not familiar with CSV files, please look up the file format online. It's a very simple one. It stands for Comma Separated Values. Each line in the file is like a row in a spreadsheet, where each cell is separated by the next one using a comma. A properly built CSV file can be loaded into a spreadsheet program (LibreOffice Calc, MS Excel, Google Sheets) and viewed as a spreadsheet, which is probably the easiest way to generate the charts for this assignment.

To get your data, you will need to make 7 BSTs. Each one will hold a different data set. These data sets are available in the provided TestData object in TestData.h. The BSTs will have:

1) Sorted data (in order from 0..N)
2) Perfectly balanced data
3) 5x trees, each holding scrambled (random order) data The TestData object has interfaces to get the data:

int get_next_sorted() int get_next_balanced()
int get_next_scrambled( setNumber )

These all return -1 when they're out of numbers. I suggest looking at the testing mode code to get an idea of how to use the interfaces.

The statistics you'll generate in the CSV file are the heights of the trees at every add (insert) into the tree. Each line in the CSV file will have 9 columns:

1) N: The number of elements in the tree
2) log(N): The calculation of log_2 (N)
3) Height of sorted tree
4) Height of balanced tree
5) Height of scrambled #0
6) Height of scrambled #1
7) Height of scrambled #2
8) Height of scrambled #3
9) Height of scrambled #4

The first line in the single CSV file sets the names of the columns. Here is a quick snapshot of how the CSV file should look opened up in Google Sheets:

Expected Output

Your program should generate one CSV file with the gathered statistics, called OutputData-BST.csv, which includes the statistics of the tree heights (and log_2) for various N values and data orderings.

Based on that CSV file, which you can open in MS Excel, LibreOffice Calc, or Google Docs Sheets, create 2 charts plotting your calculated tree heights against the input size N. The first chart will have all 8 columns (including the sorted tree data), the second chart will be everything but the sorted tree data (since it will make everything look tiny)

? AllTreeHeights.png
? NoSortedTreeHeights.png

Given how much data there will be (over 200k data points), you should probably use very small plot points. The defaults are normally these huge diamonds, x's, or others. You just need the line to show the growth of the tree height as N increases.

Attachment:- BST-hHeight_Charting.zip

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92205905
  • Price:- $350

Priced at Now at $350, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 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

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As