Programming
Modify the Binary Search Tree so as to report the average node depth, defined as D = sum(di , i=1 to n)/n where di is the depth of node i . The depth of the root is defined to be 0. After being sure that your average depth is being calculated correctly, empirically verify that (a) building a binary search tree is O(n log n), and (b) the average depth is O(log n). Note that since a Binary Search Tree cannot hold duplicates, you must fill it with data taken from a random permutation. Otherwise, you will not have n nodes in the tree after n inserts. Use at least 10 values of n, and run each size at least 5 times. The values of n must be large enough to get significant run times, e.g., 0.5 seconds or more, but not so large as to cause paging.
Tabulate and plot your results using a spreadsheet program. Show plots of T(n)/n log n and d(n)/log n. A sample Excel file (results.xls) is available under Downloads on the CS331 Course Web page.