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

Homework Eight on Extending Trees | COMP 385, Assignments of Data Structures and Algorithms

Material Type: Assignment; Class: DATA STRUCTURES II; Subject: Computer Science; University: Wentworth Institute of Technology; Term: Fall 2007;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-vaz
koofers-user-vaz 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP385 Section 71 - Data Structures II - Fall, 2007
Homework 8 – Extending Trees
Instructor: Bob Goldstein (617) 912-2512
bobg@vision.eri.harvard.edu
robert.goldstein@schepens.harvard.edu
http://home.comcast.net/~goldsteinr/Courses/index.html
http://goldstein.eri.harvard.edu/courses/index.html
http://myweb.wit.edu/goldsteinr/Courses/index.html
Due Date: November 13, 2007
Hand In: Printout of program code and dialogue of how it runs.
Purpose:
Extend, time, compare and use STree, AVLTree and RBTree.
This homework is based on Ford and Topp, problem 17 on page 559 and also on problem 21 on page 863 of your
text.
Description:
Start with the three classes, STreePlus, RBTreePlus and AVLTreePlus that we did in class. Since these classes
extend the corresponding Ford and Topp classes, you need to import them and modify them as shown in class (make
selected variables protected rather than private).
1. Implement the method addAll(T[]) to the three tree classes. This method takes an array of arbitrary datatype and
adds all the elements of the array to the tree. Time the performance of each of the three trees for objects of the type
PlayingCard (on the class website). Time it for arrays of 10,100,1000,10000 randomly generated Playing Cards.
2. Implement the recursive method heightEqual() to the three classes. This method traverses the tree and counts
the number of nodes that have the same height for the left and right subtrees. The method should NOT include any
leaf nodes in the count. Run it after inserting the same 10,100,1000,10000 random items used in part (1)
Extra Credit:
This is based on problem 23b on page 864 of your text. Implement the method pathHeight(T item) to all
three classes. This method returns -1 if the item is not in the tree. If the item is in the tree, the return value is
the depth from the root of the tree to the node containing the item.
/app/work/qkd1le-429159-2765073-homework8-doc.doc 1 11/27/2020 11/27/2020

Partial preview of the text

Download Homework Eight on Extending Trees | COMP 385 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP385 Section 71 - Data Structures II - Fall, 2007

Homework 8 – Extending Trees

Instructor: Bob Goldstein (617) 912- bobg@vision.eri.harvard.edu robert.goldstein@schepens.harvard.edu http://home.comcast.net/~goldsteinr/Courses/index.html http://goldstein.eri.harvard.edu/courses/index.html http://myweb.wit.edu/goldsteinr/Courses/index.html Due Date: November 13, 2007 Hand In: Printout of program code and dialogue of how it runs. Purpose: Extend, time, compare and use STree, AVLTree and RBTree. This homework is based on Ford and Topp, problem 17 on page 559 and also on problem 21 on page 863 of your text. Description: Start with the three classes, STreePlus, RBTreePlus and AVLTreePlus that we did in class. Since these classes extend the corresponding Ford and Topp classes, you need to import them and modify them as shown in class (make selected variables protected rather than private).

  1. Implement the method addAll(T[]) to the three tree classes. This method takes an array of arbitrary datatype and adds all the elements of the array to the tree. Time the performance of each of the three trees for objects of the type PlayingCard (on the class website). Time it for arrays of 10,100,1000,10000 randomly generated Playing Cards.
  2. Implement the recursive method heightEqual() to the three classes. This method traverses the tree and counts the number of nodes that have the same height for the left and right subtrees. The method should NOT include any leaf nodes in the count. Run it after inserting the same 10,100,1000,10000 random items used in part (1) Extra Credit: This is based on problem 23b on page 864 of your text. Implement the method pathHeight(T item) to all three classes. This method returns -1 if the item is not in the tree. If the item is in the tree, the return value is the depth from the root of the tree to the node containing the item. /app/work/qkd1le-429159-2765073-homework8-doc.doc 1 11/27/2020 11/27/