Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Lab 2

assign2w23.pdf

 Actions

•    A sample main to use with your lab2:lab2.cppLinks to an external site.

•     Usingdata2.txt Links to an external site.in lab2.cpp produces this output: lab2outputLinks to an external site.

•    Another sample main to test remove function: TO APPEAR

•    Same data, data2.txt produces this output: TO APPEAR

•    The code to display the binary tree sideways for your output is provided:sideways.cpp Links to an external site.

Put the sideways code in your bintree.cpp file. Don't forget to include the prototypes in the .h file:

void displaySideways() const;           // public interface

 

void sidewaysHelper(Node*, int) const;  // private interface

•    Code for NodeData class:   nodedata.h      Links to an external site.and   nodedata.cppLinks to an external site.

•    You're welcome to use my insert() and remove(), found on the Sample Code    page (although insert() must be slightly changed to handle duplicate items and remove must be changed as described in the assignment).

•    Use the lab2.cpp main to test all but remove(), use lab2 -remove.cpp to test remove(). Files must be called bintree.h and bintree.cpp (lowercase).

•    The class must be called BinTree.

•    Your lab2 must compile on the uw1 -320 linux machines by entering:

g++ -g lab2.cpp bintree.cpp nodedata.cpp

 

g++ -g lab2-remove.cpp bintree.cpp nodedata.cpp

•    The nodedata.h and nodedata.cpp provided will be used (so don't change them). Mac folks - make sure it is .h and not .hpp.

•    In the .cpp file (only), you must  put the recursive helper directly following the calling function (its public counterpart). One comment will suffice for both. For an example, see displaySideways().

•    Same instructions about commenting, function separator lines, 80 columns, and no tabs given in assignment 1 apply.

•    You must comment the class. Include ADT description and                    Assumptions/Limitation/Implementation. See sample code examples.

Hardcopy turn-in: None.

Even though you are not turning in a hard copy of code, code as though you were        printing in portrait mode. Code and comments should not go beyond 80 columns with tabs expanded to spaces (same rules, lose one point for each violation until down a      grade).

Electronic turn-in: One zipped file named just your last name (all lowercase), (duplicate last names use name sent in email), e.g.,

•    To create the zip file do the following, EXACTLY:

1.   Create a folder called your last name (all lowercase, same last names

- do as in assignment 1), e.g.,

2.   Put exactly four files in it (all lowercase names) called

bintree

h   bintree

typescript

(part2 can be .pdf or .jpg)

 

3.   Then zip the folder, not the contents (right-click on folder, 7-zip on windows, compress on mac).

Be sure you create the folder (independent from your IDE). It is        never automatically created. When unzipped, the files will be in a     folder (directory on linux) named your last name. Try it out on linux: unzip filename.zip

•     Using the sample data, produce typecript as in lab1 (showing output from both

mains):

 

script

 g++ -g lab2.cpp bintree.cpp nodedata.cpp

                                                

 g++ -g lab2-remove.cpp bintree.cpp nodedata.cpp 

 valgrind ./a.out