USING C++, Implement a TEMPLATED Binary Search Tree (RECURSIVE) class, that is minimal & complete. Provide the following recursive operations: Insert, Delete tree, Search, inOrder traversal, preOrder traversal, postOrder traversal. Methods essential for correct operation of tree in terms of managing memory must be provided. Any additional methods can be added. Use function pointers in the traversal routines. cannot use std::function (or any other similar routine from std namespace. Test BST to make sure all methods work. In particular make sure that you can pass the tree to other routines by value, const reference and reference. Check that data values are as expected on pass/return to/from routines.

icon
Related questions
Question

USING C++, Implement a TEMPLATED Binary Search Tree (RECURSIVE) class, that is minimal & complete. Provide the following recursive operations: Insert, Delete tree, Search, inOrder traversal, preOrder traversal, postOrder traversal. Methods essential for correct operation of tree in terms of managing memory must be provided. Any additional methods can be added. Use function pointers in the traversal routines. cannot use std::function (or any other similar routine from std namespace. Test BST to make sure all methods work. In particular make sure that you can pass the tree to other routines by value, const reference and reference. Check that data values are as expected on pass/return to/from routines. Do not use GUI interaction.

 

Input/Output (user):

Sample output formats shown below use made up data for the year 1905. Menu options are:

  1. The average wind speed and sample standard deviation for this wind speed given a specified month and year. (print on screen only)

Eg:

January 1905:

Average speed: 5.5 km/h Sample stdev: 1.2

Eg no data:

March 1905: No Data

2. Average ambient air temperature and sample standard deviation for each month of a

specified year. (print on screen only)

Eg:

1905

January: average: 25.5 degrees C, stdev: 12.2 February: average; 27.5 degrees C, stdev: 10.1

March: No Data

3. sPCC that calculates sample Pearson Correlation Coefficient using either;

  1. Average Wind Speed (S) and Ambient Air Temperature (T). This is called S_T.
  2. Average Wind Speed (S) and Solar Radiation (R). This is called S_R.
  3. Ambient Air Temperature (T) and Solar Radiation (R). This is called T_R.

4. Average wind speed (km/h), average ambient air temperature and total solar radiation in kWh/m2 for each month of specified year. Standard deviation is printed in ( ) next to the average. (print to a file called “WindTempSolar.csv”)

Output Format:

Year, Month,Average Wind Speed(stdev), Average Ambient Temperature(stdev), sPCC

Eg:

1905 January,5.5(1.2),25.5(12.2),196.4

Values are comma separated

If data is not available for month, do not output month. If entire year’s data is not available, output just the year, “No Data”.

no data  for a particular field, then output field is blank. e.g. temperature data is not available for feb 1905,  output is:

February,4.5(3.1), ,200.3

5. Provide an option, which enables the reloading from the data/data_source.txt file. All previously loaded data is discarded, and heap memory released before reloading. This will enable program to keep running so that different combinations of data files can be used having to exit the program.

6. Exit the program

user specifies year and/or month as numeric values. Program asks in command line and the user types in the numeric values and presses “Enter” key. E.g. user types in 1 and not string January or Jan for first month of year.

user is not asked to enter a file name.

Processing:

The file data source. txt will contain the name of the input file that actually contains the data. it will be placed in a folder called data which also contains the csv files.The file data source.txt is hard coded into the program and this file will contain the name of the actual input data file (csv). Program must load data from the file name found in data source.txt. One data file is smaller than others and column arrangements are different. program should be able to read in any one with a change in file data _source. txt. Code should not require rebuilding if different input data file is needed.program must work with different arrangements of column data and it does not need to be rebuilt to read in a different input data file.

After loading the data into the required data structures (BST and STL Map), your program displays the menu to the user.

DATA STRUCTURES

Think of how you can use your BST with function pointers and the STL map (or STL map variants, which include multimap). Data structures can be used in many ways and so we want to know the thinking behind your choice of usage. Write down what you are thinking and the relevant theory you have used to guide your thinking. Consider the advantages/disadvantages of your approach and other potential approaches.

Hint: There are issues that you must resolve before you incorporate the BST and map data structures. You need to explain what you are trading-off and why.

Although not required, you can use STL data structures like stack, queue, linked list if they are wrapped in your own data structure classes. Only your BST and std::map (or variants) are mandatory data structures

Class declarations and implementations should be separated. Template classes would have the
implementation after the class declaration in the same header file.

You will need the following additional classes which you can implement however you want: Date, wind speed, ambient air temperature, Solar Radiation, and sPCC.

A
1 WAST
2 1/01/2010 9:00
3 1/01/2010 9:10
4 1/01/2010 9:20
5 1/01/2010 9:30
6 1/01/2010 9:40
1/01/2010 9:50
7
8
1/01/2010 10:00
10
9 1/01/2010 10:10
1/01/2010 10:20
11 1/01/2010 10:30
12 1/01/2010 10:40
13 1/01/2010 10:50
14 1/01/2010 11:00
15
1/01/2010 11:10
16 1/01/2010 11:20
17 1/01/2010 11:30
18 1/01/2010 11:40
19 1/01/2010 11:50
B
Speed
7
6
6
6
6
5
6
6
6
6
6
6
55
66
5
6
с
Solar Radiation
813
845
877
906
929
956
987
1009
1022
1044
1059
1083
1099
1099
1110
1113
1131
1126
D
Air Temperature
20.98
21.37
21.96
22.53
23.07
24.06
23.86
24.2
24.81
25.19
25.6
25.63
26.33
26.4
26.22
27.3
27.44
28.19
Transcribed Image Text:A 1 WAST 2 1/01/2010 9:00 3 1/01/2010 9:10 4 1/01/2010 9:20 5 1/01/2010 9:30 6 1/01/2010 9:40 1/01/2010 9:50 7 8 1/01/2010 10:00 10 9 1/01/2010 10:10 1/01/2010 10:20 11 1/01/2010 10:30 12 1/01/2010 10:40 13 1/01/2010 10:50 14 1/01/2010 11:00 15 1/01/2010 11:10 16 1/01/2010 11:20 17 1/01/2010 11:30 18 1/01/2010 11:40 19 1/01/2010 11:50 B Speed 7 6 6 6 6 5 6 6 6 6 6 6 55 66 5 6 с Solar Radiation 813 845 877 906 929 956 987 1009 1022 1044 1059 1083 1099 1099 1110 1113 1131 1126 D Air Temperature 20.98 21.37 21.96 22.53 23.07 24.06 23.86 24.2 24.81 25.19 25.6 25.63 26.33 26.4 26.22 27.3 27.44 28.19
1 WAST
2 1/01/2010 9:00
3 1/01/2010 9:10
4 1/01/2010 9:20
5 1/01/2010 9:30
1/01/2010 9:40
7
1/01/2010 9:50
8 1/01/2010 10:00
9 1/01/2010 10:10
10 1/01/2010 10:20
11 1/01/2010 10:30
12
1/01/2010 10:40
13 1/01/2010 10:50
14 1/01/2010 11:00
15 1/01/2010 11:10
16 1/01/2010 11:20
17 1/01/2010 11:30
18 1/01/2010 11:40
19 1/01/2010 11:50
LO
A
6
B
Air Temperature
20.98
21.37
21.96
22.53
23.07
24.06
23.86
24.2
24.81
25.19
25.6
25.63
26.33
26.4
26.22
27.3
27.44
28.19
с
Speed
7
6
6
6
6
5
6
6
6
6
6
6
5
5
6
6
5
6
D
Solar Radiation
813
845
877
906
929
956
987
1009
1022
1044
1059
1083
1099
1099
1110
1113
1131
1126
Transcribed Image Text:1 WAST 2 1/01/2010 9:00 3 1/01/2010 9:10 4 1/01/2010 9:20 5 1/01/2010 9:30 1/01/2010 9:40 7 1/01/2010 9:50 8 1/01/2010 10:00 9 1/01/2010 10:10 10 1/01/2010 10:20 11 1/01/2010 10:30 12 1/01/2010 10:40 13 1/01/2010 10:50 14 1/01/2010 11:00 15 1/01/2010 11:10 16 1/01/2010 11:20 17 1/01/2010 11:30 18 1/01/2010 11:40 19 1/01/2010 11:50 LO A 6 B Air Temperature 20.98 21.37 21.96 22.53 23.07 24.06 23.86 24.2 24.81 25.19 25.6 25.63 26.33 26.4 26.22 27.3 27.44 28.19 с Speed 7 6 6 6 6 5 6 6 6 6 6 6 5 5 6 6 5 6 D Solar Radiation 813 845 877 906 929 956 987 1009 1022 1044 1059 1083 1099 1099 1110 1113 1131 1126
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer