Find Jobs
Hire Freelancers

Binary Search Tree Exploration

$30-5000 USD

Completed
Posted over 21 years ago

$30-5000 USD

Paid on delivery
Implement code to do basic binary search tree manipulations,including insert, traverse, delete, and so on. You may use what the author (Weiss) has in Chapter 4; in fact, be sure to adapt what Weiss has (as closely as you can) for Remove on page 138. Now, Weiss mentions that the code for Remove is inefficient,in that when removing a node with 2 children, it first finds the minimum node in the subtree to the right, then uses Remove to delete that node (which first 'finds' it again). Replace that section with a call to RemoveMin (which you must write) that does the job with just one trip down the tree. Part I: To test your code (on a tree of integers), first insert the values 42 10 74 5 16 100 12 14 15 30 32 in that order. After that, do the following pseudo-code: while the tree is not empty { remove next node (that is, keep a list of the nodes that are left, and delete them one by one) traverse the tree print a line of **************** (so we can keep things separate) } However, make sure that the FIRST node you remove is 10. This is a node with 2 children, which forces RemoveMin to get [login to view URL] of this is to show that your code actually works! Part II: Add a height function, that computes the height of a BST. Now, as we know a binary search tree can behave badly in terms of height; in the worst case it can have height = number of nodes and be just a linked list! Here, we want to explore what is the average height of a randomly generated BST. To this end, generate 100 BST's with 4,096 randomly generated integer values each and print the average height of all 100 trees. Note the following: the usual recursive tree height function will take a LONG time to compute the height of these trees. You should consider an alternative approach for computing the height that will be much faster. Part III: If we insert an array of integers into a BST and then traverse the tree in order, we will have sorted the array. Setup a randomly generated array of 262,144 integers and insert them into a previously empty BST. CPU time this process (see how below). Also sort the array using qsort and time that as well. Print out both elapsed times and label the output. You need not print the sorted array or traverse the tree (but you might do so for yourself prior to turning it in). Note: qsort can be tricky to use correctly if you haven't done it before;(continue on next avaiable window)...... ## Deliverables 1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request. 3) Complete ownership and distribution copyrights to all work purchased. ## Platform (continue from DESCRIPTION page)look it up and test it out on a small array to make sure you understand it. Note: if you are working under Windows, and you want yourbarray of size 262144 to be local rather than global, you will need to set up a pointer to it and allocate it on the heap; otherwise just put int u[262144]; as global. The problem is that Win32 sets up a default stack of 1 megabyte. So a local declaration of int u[262144] in main() overflows the stack immediately and your program crashes. Another superiority of Linux :-) CPU Timing (for C and C++): You will need to include stdlib.h and time.h to use this. (That's cstdlib and ctime in newer C++ compilers) ... double start, elap; start = clock(); (task to be timed goes here) elap = (clock() - start) / CLOCKS_PER_SEC; Now, elap will be the elapsed time (in seconds) -- I would normally print this out to 2 decimal places. Note: PLEASE WRITE THIS PROGRAM IN C++ . I use the Visual C++ 6.0 to run it ## Deadline information please send the codes ontime
Project ID: 2869827

About the project

16 proposals
Remote project
Active 22 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
See private message.
$12 USD in 14 days
5.0 (33 reviews)
4.0
4.0
16 freelancers are bidding on average $21 USD for this job
User Avatar
See private message.
$34 USD in 14 days
4.4 (72 reviews)
5.5
5.5
User Avatar
See private message.
$29.75 USD in 14 days
5.0 (78 reviews)
5.2
5.2
User Avatar
See private message.
$19.55 USD in 14 days
5.0 (47 reviews)
4.5
4.5
User Avatar
See private message.
$21.25 USD in 14 days
4.6 (60 reviews)
4.5
4.5
User Avatar
See private message.
$11.05 USD in 14 days
4.8 (62 reviews)
4.2
4.2
User Avatar
See private message.
$11.90 USD in 14 days
4.9 (17 reviews)
3.3
3.3
User Avatar
See private message.
$21.25 USD in 14 days
5.0 (53 reviews)
3.3
3.3
User Avatar
See private message.
$42.50 USD in 14 days
5.0 (2 reviews)
2.9
2.9
User Avatar
See private message.
$17 USD in 14 days
5.0 (7 reviews)
2.6
2.6
User Avatar
See private message.
$7.65 USD in 14 days
4.9 (5 reviews)
1.8
1.8
User Avatar
See private message.
$21.25 USD in 14 days
5.0 (3 reviews)
1.8
1.8
User Avatar
See private message.
$21.25 USD in 14 days
4.9 (6 reviews)
1.1
1.1
User Avatar
See private message.
$8.50 USD in 14 days
5.0 (2 reviews)
0.9
0.9
User Avatar
See private message.
$42.50 USD in 14 days
0.0 (0 reviews)
0.0
0.0
User Avatar
See private message.
$8.50 USD in 14 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of UNITED STATES
United States
5.0
25
Member since Sep 16, 2001

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.