CSCE 221: Data Structures and Algorithms

Sections: 507, 508, 509
Fall 2015



Homework 4


Due Date: Sept. 25th (before class)


Assignment

  1. R8.6 (Pg. 361)

    Show the output from the following sequence of priority queue ADT operations. The entries are key-element pairs, where sorting is based on the key value: insert(5,a), insert(4,b), insert(7,i), insert(1,d), removeMin(), insert(3,j), insert(6,c), removeMin(), removeMin(), insert(8,g), removeMin(), insert(2,h), removeMin(), removeMin().

  2. R8.7 (Pg. 361)

    An airport is developing a computer simulation of air-traffic control that handles events such as landings and takeoffs. Each event has a time-stamp that denotes the time when the event occurs. The simulation program needs to efficiently perform the following two fundamental operations:

    • Insert an event with a given time-stamp (that is, add a future event)
    • Extract the event with smallest time-stamp (that is, determine the next event to process)

    Which data structure should be used for the above operations? Why?

  3. R8.12 (Pg. 362)

    At which nodes of a heap can an entry with the largest key be stored?

  4. R8.21 (Pg. 362)

    Bill claims that a preorder traversal of a heap will list its keys in nondecreasing order. Draw an example of a heap that proves him wrong.

  5. C8.17 (Pg. 365)

    Develop an algorithm that computes the kth smallest element of a set of n distinct integers in O(n+ klogn) time. Please include pseudocode, correctness and complexity.


Bonus

    R8.26 (Pg. 363)

    A group of children want to play a game, called Unmonopoly, where in each turn the player with the most money must give half of his/her money to the player with the least amount of money. What data structure(s) should be used to play this game efficiently? Why?


Grading Rubric

Each homework composes 2% of your final grade. Each homework will be graded out of 100 possible points. In any problem asking you to design an algorithm please also provide proper pseudocode (mathematical notation), complexity analysis (both space and time), and brief justification of complexity and correctness.

All assignments must be turned in with a signed coverpage. If no coverpage is provided, the assignment will not be graded.

If there are any discrepancies in grades please see Jory Denny during his office hours (not the TA or Grader).