CMSC 132 Quiz 4 Worksheet: MaxHeap Implementation, Quizzes of Computer Science

Information about quiz 4 in cmsc 132, including the quiz date, format, and covered material. Students are expected to complete exercises from the textbook and implement methods for the maxheap class. No solutions will be provided, but students can discuss their approaches with tas and instructors during office hours.

Typology: Quizzes

Pre 2010

Uploaded on 02/13/2009

koofers-user-1ag
koofers-user-1ag 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CMSC 132 Quiz 4 Worksheet
The next quiz of the course will be on Monday, May 1during your lab (discussion) session. The following
list provides more information about the quiz:
The quiz will be a written quiz (no computer).
Closed book, closed notes quiz.
Answers must be neat and legible. We recommend that you use pencil and eraser.
The following exercises cover the material to be included in this quiz. Solutions to these exercises will not
be provided, but you are welcome to discuss your solutions with TAs and instructors during office hours.
Exercises
1.
Quick-Check Exercises 6, 7, 8 from Page 457 of the class Textbook (Koffman/Wolfgang).
2.
Check the heap videos available at:
http://www.cs.umd.edu/class/spring2006/cmsc132/documents.shtml
3.
The MaxHeap class represents a max-heap. In a max-heap every element has to have a greater
key value than either of its children. The class definition associated with the MaxHeap class is:
public class MaxHeap<E extends Comparable<E>> {
ArrayList<E> data = new ArrayList<E>();
}
Complete the implementation of the MaxHeap class, by providing the following methods:
a. insert – Inserts an element in the heap.
b. remove – Removes the largest element from the heap and returns that element.
c. size – Returns the size of the heap.

Partial preview of the text

Download CMSC 132 Quiz 4 Worksheet: MaxHeap Implementation and more Quizzes Computer Science in PDF only on Docsity!

CMSC 132 Quiz 4 Worksheet

The next quiz of the course will be on Monday, May 1during your lab (discussion) session. The following list provides more information about the quiz:

  • The quiz will be a written quiz (no computer).
  • Closed book, closed notes quiz.
  • Answers must be neat and legible. We recommend that you use pencil and eraser.

The following exercises cover the material to be included in this quiz. Solutions to these exercises will not be provided, but you are welcome to discuss your solutions with TAs and instructors during office hours.

Exercises

1. Quick-Check Exercises 6, 7, 8 from Page 457 of the class Textbook (Koffman/Wolfgang).

2. Check the heap videos available at:

http://www.cs.umd.edu/class/spring2006/cmsc132/documents.shtml

3. The MaxHeap class represents a max-heap. In a max-heap every element has to have a greater

key value than either of its children. The class definition associated with the MaxHeap class is:

public class MaxHeap<E extends Comparable> { ArrayList data = new ArrayList();

Complete the implementation of the MaxHeap class, by providing the following methods:

a. insert – Inserts an element in the heap. b. remove – Removes the largest element from the heap and returns that element. c. size – Returns the size of the heap.