Reads a set of integers from file

Assignment Help C/C++ Programming
Reference no: EM13166150

The code in file "hw5-stree.cpp" reads a set of integers from file and inserts them into a binary search tree. You are asked to implement two functions max() and depth() that compute the maximum element and the depth of the binary search tree. The function prototypes are given in file "d_stree.h" lines 174-212. You need to complete the implementation of these four functions so that max() return an iterator pointing to the maximum tree node, and depth() returns an integer indicating the depth of the tree. Note that all you need to do is to complete the implementation of the two functions computeDepth() and maxNode(). The max() and depth() functions call these two functions.

The provided code also computes the depth of the complete binary search tree with the same number of nodes. You are asked to run the code with different numbers of tree nodes, summarize your results in a table, and analyze your results based on our classroom discussions.

If you compiled your code with

g++ hw5-stree.cpp -o stree

you can use for example

./stree 1000

to read the first 1000 integers and build the tree.

 

 

Reference no: EM13166150

Questions Cloud

Create a computer class : Create a computer class and assume computers have the following fields: String manufacture, double price, int year
Compute the molar solubility of caco3 : Calculate the molar solubility of CaCO3 ( Ksp = 4.5*10-9) neglecting the acid-base character
Linked list in c++ : If the following C++ code is valid, show the output. If it is invalid, explain why.
State combustion in oxygen to make carbon dioxide gas : Methanol undergoes combustion in oxygen to make Carbon Dioxide Gas & Liquid Water. Find Standard Enthalpy of Reaction?
Reads a set of integers from file : The code in file "hw5-stree.cpp" reads a set of integers from file and inserts them into a binary search tree. You are asked to implement two functions max() and depth() that compute the maximum element and the depth of the binary search tree.
Vanilla versions versus best practices–based software : Compare and contrast customized and packaged software as well as vanilla versions versus best practices–based software.
Implement a client program : Implement a client program with a main method to demonstrate the evolution of the sales tax rates in the 50 US states over the last 10 years. Declare a two-dimensional array of values representing the sales tax rates. Dimension 1 represents the st..
Draw a two-dimensional house seen from the front : Draw a two-dimensional house seen from the front, the way a child would: with a dor, two windows, and a roof with a chimney
Calculates the average of three test scores : Write a program that calculates the average of three test scores. The program should contain three value-returning functions: main, getTestScore, and calcAverage

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Repeat these questions by writing functions

Repeat these questions by writing functions that receive the arrays as constant reference parameters and return the appropriate values through the function name (via return statement). The function header could look like:

  Write a c++ program to draw the five olympic rings

Write a C++ program to draw the five Olympic rings. Make the circles have a thickness of 5 pixel

  Brownian motion is a physical phenomenon

Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.

  The user enter the total rainfall for each of 12 months

Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display:the total rainfall for the year,the average monthly rainfall,and the months w..

  Write a linked-list-based push-down stack implementation

Write a linked-list-based push-down stack implementation that keeps items on the list in order from least recently inserted to most recently inserted. You will need to use a doubly linked list.

  Compute a program that calculates three resistance inputs

C language, compute a program that calculates three RESISTANCE inputs, and gives you the total resistance in OHMS. Like this, the total resistance is _____ ohms. These are three parallel circuits so the formula would be (1/R1 + 1/ R 2 +  1/ R 3 )  -1

  Program that reads in the average monthly

Write a program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months. The program then prints out a nicely formatted table showing the rainfa..

  Input parameters, and returns nothing

Write a function called ten2one(), that takes no input parameters, and returns nothing (void). The body of the function must include a loop that counts from 10 down to 1, printing the count value each time in the loop. The output should look like (no..

  Multidimensional arrays

multidimensional arrays to life, let's consider a specific example: How can you visualize a 4-dimensional array? How can you give meaning to each dimension this array has? What kind of application would such an array be useful for?

  Sort an array of elements using the quick sort algorithm

Sort an array of 10,000 elements using the quick sort algorithm as follows: sort the array using pivot as the middle element of the array

  The mean and standard deviation

How do i write a program in c++ that use functions max, min, the total numbers, the mean and standard deviation to read a file text and return these values from the file text. note the file text has random numbers. note im not suppose to use arrays.

  Throws an exception from a deeply nested

Write a program that throws an exception from a deeply nested function and still has the catch handler following the try block enclosing the initial call in main catch the exception

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