221-13a-A4

• Notes
• 3

This preview shows page 2 - 3 out of 3 pages.

Average search cost is 2 2

Subscribe to view the full document.

3. Download files containing integer data from the course website. (a) The files 1p.dat , 2p.dat , ..., 12p.dat contain 2 1 1, 2 2 1,..., and 2 12 1 integers respectively. The integers make 12 perfect binary trees where all leaves are at the same depth. Calculate and record the average search cost for each perfect binary tree. (b) The files 1r.dat , 2r.dat , ..., 12r.dat contain same number of integers as above. The integers are randomly ordered and make 12 random binary trees . Calculate and record the average search cost for each tree. (c) The files 1l.dat , 2l.dat , ..., 12l.dat contain same number of integers as above. The integers are in increasing order and make 12 linear binary trees . Calculate and record the average search cost for each tree. (d) Make a plot showing the average search cost (y-axis) versus the number of tree nodes (x-axis) of all perfect binary trees, random binary trees and linear binary trees. (e) Provide the output in the text format. The nodes will be printed according to their depth level. Missing nodes will be represented by the symbol X . A possible solution is to fill the missing nodes with fake nodes in the data structure when printing the tree. Example: 5 3 9 X X 7 X 4. Extra credit. (a) (10 points) Use the in-order traversal and any graphic programming library like FLTK for binary tree drawing. See the textbook, page 301 for the algorithm. (b) (10 points) Implement a balanced binary search tree using one of the balancing technique like AVL, Red-Black or 2-4 tree.
• Fall '09
• search cost, average search cost

{[ snackBarMessage ]}

###### "Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern