Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Computer Science Assignment: Implementing and Comparing AVL Trees, 2-3 Trees, and Heapsort, Assignments of Algorithms and Programming

A computer science assignment where students are required to implement and empirically verify the performance of avl trees, 2-3 trees, and heapsort. The assignment includes instructions for each exercise, as well as guidelines for adding instrumentation and creating random data sets to test the implementations.

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-grt
koofers-user-grt ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMP157๎˜ƒFall07๎˜ƒAssignment๎˜ƒ6๎˜ƒ
Homework๎˜ƒAssignment๎˜ƒ6:๎˜ƒdue๎˜ƒFriday,๎˜ƒNovember๎˜ƒ2.๎˜ƒ
Do๎˜ƒany๎˜ƒtwo๎˜ƒof๎˜ƒthe๎˜ƒfollowing๎˜ƒthree๎˜ƒexercises:๎˜ƒ
๎˜ƒ
1) Implement๎˜ƒan๎˜ƒAVL๎˜ƒtree.๎˜ƒ๎˜ƒ
Your๎˜ƒimplementation๎˜ƒmust๎˜ƒsupport๎˜ƒinsertion๎˜ƒand๎˜ƒsearch๎˜ƒoperations.๎˜ƒ๎˜ƒ
You๎˜ƒdo๎˜ƒnot๎˜ƒhave๎˜ƒto๎˜ƒimplement๎˜ƒa๎˜ƒdeletion๎˜ƒoperation.๎˜ƒ
Verify๎˜ƒyour๎˜ƒimplementation๎˜ƒempirically๎˜ƒas๎˜ƒfollows:๎˜ƒ
โ€ข Add๎˜ƒinstrumentation๎˜ƒto๎˜ƒyour๎˜ƒsearch๎˜ƒoperation๎˜ƒto๎˜ƒcount๎˜ƒcomparisons.๎˜ƒ
โ€ข Create๎˜ƒrandom๎˜ƒtrees๎˜ƒof๎˜ƒn=100,๎˜ƒn=1000๎˜ƒand๎˜ƒn=10000๎˜ƒnodes๎˜ƒ(at๎˜ƒleast๎˜ƒ10๎˜ƒof๎˜ƒeach).๎˜ƒ
(Be๎˜ƒsure๎˜ƒthat๎˜ƒyou๎˜ƒare๎˜ƒinserting๎˜ƒn๎˜ƒunique๎˜ƒrandom๎˜ƒvalues.)๎˜ƒ
โ€ข For๎˜ƒeach๎˜ƒtree,๎˜ƒrun๎˜ƒat๎˜ƒleast๎˜ƒ100๎˜ƒsearches.๎˜ƒ
โ€ข Compute๎˜ƒaverage๎˜ƒcomparisons๎˜ƒfor๎˜ƒeach๎˜ƒtree๎˜ƒsize๎˜ƒand๎˜ƒcompare๎˜ƒyour๎˜ƒresults๎˜ƒto๎˜ƒ
theoretical๎˜ƒexpectations.๎˜ƒ
๎˜ƒ
2) Implement๎˜ƒa๎˜ƒ2โ€3๎˜ƒtree.๎˜ƒ๎˜ƒ
Your๎˜ƒimplementation๎˜ƒmust๎˜ƒsupport๎˜ƒinsertion๎˜ƒand๎˜ƒsearch๎˜ƒoperations.๎˜ƒ๎˜ƒ
You๎˜ƒdo๎˜ƒnot๎˜ƒhave๎˜ƒto๎˜ƒimplement๎˜ƒa๎˜ƒdeletion๎˜ƒoperation.๎˜ƒ
Verify๎˜ƒyour๎˜ƒimplementation๎˜ƒempirically,๎˜ƒby๎˜ƒthe๎˜ƒsame๎˜ƒprocedure๎˜ƒdescribed๎˜ƒfor๎˜ƒAVL๎˜ƒtrees.๎˜ƒ
๎˜ƒ
3) Implement๎˜ƒHeapsort.๎˜ƒ๎˜ƒ
Verify๎˜ƒyour๎˜ƒimplementation๎˜ƒempirically๎˜ƒas๎˜ƒfollows:๎˜ƒ
โ€ข Add๎˜ƒinstrumentation๎˜ƒto๎˜ƒyour๎˜ƒsort๎˜ƒoperation๎˜ƒto๎˜ƒcount๎˜ƒcomparisons.๎˜ƒ
โ€ข Create๎˜ƒrandom๎˜ƒarrays๎˜ƒof๎˜ƒn=100,๎˜ƒn=1000๎˜ƒand๎˜ƒn=10000๎˜ƒnodes๎˜ƒ(at๎˜ƒleast๎˜ƒ10๎˜ƒof๎˜ƒeach).๎˜ƒ
โ€ข Compute๎˜ƒthe๎˜ƒaverage๎˜ƒsorting๎˜ƒcost๎˜ƒfor๎˜ƒeach๎˜ƒtree๎˜ƒsize๎˜ƒand๎˜ƒcompare๎˜ƒyour๎˜ƒresults๎˜ƒto๎˜ƒ
theoretical๎˜ƒexpectations.๎˜ƒ
๎˜ƒ
๎˜ƒ

Partial preview of the text

Download Computer Science Assignment: Implementing and Comparing AVL Trees, 2-3 Trees, and Heapsort and more Assignments Algorithms and Programming in PDF only on Docsity!

COMP157 Fall07 Assignment 6

Homework Assignment 6 : due Friday, November 2. Do any two of the following three exercises:

  1. Implement an AVL tree. Your implementation must support insertion and search operations. You do not have to implement a deletion operation. Verify your implementation empirically as follows:
  • Add instrumentation to your search operation to count comparisons.
  • Create random trees of n=100, n=1000 and n=10000 nodes (at least 10 of each). (Be sure that you are inserting n unique random values.)
  • For each tree, run at least 100 searches.
  • Compute average comparisons for each tree size and compare your results to theoretical expectations.
  1. Implement a 2 โ€ 3 tree. Your implementation must support insertion and search operations. You do not have to implement a deletion operation. Verify your implementation empirically, by the same procedure described for AVL trees.
  2. Implement Heapsort. Verify your implementation empirically as follows:
  • Add instrumentation to your sort operation to count comparisons.
  • Create random arrays of n=100, n=1000 and n=10000 nodes (at least 10 of each).
  • Compute the average sorting cost for each tree size and compare your results to theoretical expectations.