How command line options are passed to the program

Assignment Help Data Structure & Algorithms
Reference no: EM131396090

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

Reference no: EM131396090

Questions Cloud

Short run but shut down in the long run : A perfectly competitive firm sells 10 units of Good X at a price of $2 per unit. It incurs a fixed cost of $5 and a variable cost of $40 to produce the good. Which of the following is true?
Explain the ethical dilemma : Explain the ethical dilemma in your own words and explain whether or not the story relates to an ethical theory or code identified in the text. Your post should include a link to the news story or event (article, other piece of writing, or video c..
Vivian produce butter and cheese : Suppose both Ross and Vivian produce butter and cheese. When Ross works for 10 hours a day, he produces 6 pounds of butter and 24 pounds of cheese. When Vivian works for the same hours, she produces 20 pounds of cheese and 40 pounds of butter. Ros..
Example of a negative externality : Which of the following is an example of a negative externality? Smith reducing the consumption of imported wine following an increase in the price of imported wine
How command line options are passed to the program : CptS 223- How templating works in header files? How command line options are passed to the program? How I wrote up the makefile so you could add or edit it for your own uses?
Test the goodness of fit of a given model : Suppose that of 140 offspring, 19.3 percent were schizophrenic. Use this information to test the goodness of fit of a 1:3 model. Remember that a x2 analysis is performed on frequency counts.
Company is higher than the private cost : Color Mate Inc., a company that produces interior and wall paints, dumps its chemical waste in a river. Which of the following is likely to be true in this case? The social cost of the company is higher than the private cost, and the equilibrium q..
Analyze how the film treats this moral issue : You will select a film that deals with a moral concern. You will briefly summarize this film (250 words). Then, you will analyze how the film treats this moral issue. Use the text to support your analysis (about 500 words).
Use a chi square test to evaluate mars claim : In a 1.69-ounce package I got 9 blues, 11 oranges, 17 greens, 8 yellows, 5 browns, and 7 reds.- Use a chi square test to evaluate Mars's claim.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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