Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

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

Question specify design implement im c a class for a card

Question : Specify, design implement im c++ a class for a card in a deck of playing cards. The object should contain methods for setting and retrieving the suit and rank of the card. Make sure to separate your work on s ...

Answer the following question how do you represent a node

Answer the following Question : How do you represent a node in a deployment diagram? What kinds of information can appear on a node? The response must be typed, single spaced, must be in times new roman font (size 12) an ...

Write a c functionnbspescapechar s char tnbspthat converts

Write a C function escape(char s[], char t[]) that converts the characters newline and tab into two character sequences n and t as it copies the string t to the string s. Use the C switch statement. Also write the revers ...

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 ...

Suppose you are given an undirected graph g with weighted

Suppose you are given an undirected graph G with weighted edges and a minimum spanning tree T of G. • Design an algorithm to update the minimum spanning tree when the weight of a single edge e is increased. • Design an a ...

Question show me how write a program that prompts the user

Question Show me how Write a program that prompts the user for a student grade average (e.g. 86.7) and outputs what the letter grade should be. Ensure that your program notifies the user if he/she enters a non-valid aver ...

Scenario 1 19500 ascii characters are transmitted over a 3

Scenario 1: 19,500 ASCII characters are transmitted over a 3 Mbps circuit. The protocol uses 8-bits to encode each ASCII character, and adds an additional parity bit to help detect errors. Calculate the transmission effi ...

Suppose the following matrix represents the number of saws

Suppose the following matrix represents the number of saws ordered from your company each month over the last year. saws = [1,4,5,3,7,5,3,10,12,8, 7, 4] All the numbers should be zero or positive. (a) Use an if statement ...

Assignment 1 network access controlin a business

Assignment 1: Network Access Control In a business environment, controlling who has access to business information and at what level is critical for facilitating day-to-day business operations. The emphasis of Network Ac ...

Can someone help please i had help but its not working

Can someone help please. I had help but it's not working. PLEASE DO BOTH PARTS! Please make sure to read the entire problem and do both parts PLEASE DO NOT write it out I have a hard time reading people's hand writing pl ...

  • 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