CSci 2101 Data Structures: Takehome exam I.

Due Wednesday, October 13th, at 8pm. Please submit the paper-and-pencil part to Elena's office (slide it under the door if the door is closed). The program part is to be submitted by e-mail to Elena. Absolutely no late submissions are accepted, the deadline is firm. Don't try to submit at the last minute, allow extra time for bounced e-mail and similar things. Double-check to make sure that you are submitting the right files (only .java files need to be submitted).

You may use any printed and online materials and your own problem sets. You are allowed to talk to each other about general approaches to the problems. You may also discuss particular compilation issues, but you may not reproduce any part of another person's code or a solution of a paper-and-pencil problem. You may get help from me or from Andy Korth. You may not get any help on the assignment from anyone else outside of the class.

Problem 1 (7 points)

Write a program to do the following: Make sure to test your program well and submit all the test cases. The program must work for any array with at least one element.

Problem 2 (8 points)

For this program you will need the class files IntQueue.class, QueueException.class and the Node and LinkedList. Copy/paste the code for Node and LinkedLists into files Nodes.java and LinkedList.java. You don't need to copy the code for the Packages class.

You need to write a program to do the following:

Test your program carefully, submit all test cases.

Problem 3, paper-and-pencil (5 points)

In a heap representation of a priority queue does the order of elements in the array depend on the order in which the elements were inserted into the queue? In other words, is it possible to insert the same group of elements on the queue, but to get two different orderings of elements in the array if the order of elements in the two groups was different?

If it's possible, please give an example and show the resulting arrays. Otherwise please explain your answer.

Problem 4 (20 points)

Your boss wants you to implement a priority queue to store integers between 1 and 10 as a linked list. He says that since the range of the elements is known, it would be more efficient to implement the queue as a doubly linked list and insert the elements which are greater than 5 from the front of the list, and those smaller or equal to 5 from the back of list. This will cut down on the number of nodes accessed when an element is inserted. Your task is:

Extra credit (up to 3 points) Analyze this testing strategy. Can you see any flaws in it? Can you suggest better tests? You don't need to implement them, just describe them in detail.


This is a takehome exam from CSci 2101 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.