2 - Cover page for CSC263 Homework #2 (fill and attach...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Cover page for CSC263 Homework #2 (fill and attach this page to your homework) SUBMITTED BY: (1) Family Name: (2) Family Name: Given Name: Given Name: Student Number: Student Number: Graded Homework should be returned in Tutorial: (tutorial room number) By Virtue of submitting this homework I/we acknowledge that I am/we are aware of the policy on homework collaboration for this course. Computer Science CSC263H February 1, 2007 St. George Campus University of Toronto Homework Assignment #2 Due: February 15, 2007, by 5:30 pm (in the drop box for this course in Bahen 2220) 1. On the cover page of your assignment, in addition to your name(s), you must write the location of the tutorial where you want the graded homework to be returned. . If you do not know the answer to a question, and you write “I (We) do not know the answer to this question”, you will receive 20% of the marks of that question. If you just leave a question blank with no such statement, you get 0 marks for that question. . Your paper will be marked based on the correctness and completeness of your answers, and the clarity, precision and conciseness of your presentation. Question 1. (10 marks) In this question, you must use the insertion and deletion algorithms as described in the “Balanced Search Trees: AVL trees77 handout posted on the course web site. Insert into an initially empty AVL tree each of the following keys, in the order in which they appear in the sequence: 17, 7, 8, 14, 19, 6, 10, 21, 15, 12, 9, 11. Show the resulting AVL tree T. (Only the final tree should be shown; any intermediate trees shown will be disregarded, and not given partial credit.) From AVL tree T, delete 14, and show the resulting tree. In the two trees you must show the key and balance factor of each node. Question 2. (30 marks) A seaport has a number of ships awaiting cargo. Each ship is moored at a pier p and has a remaining loading capacity of 0 tonnes. You must design a data structure D that stores the ships (including their pier location and remaining capacity) and supports efficient implementation of the four operations listed below. When cargo arrives at the seaport to be loaded on a ship, you will need to decide which ship to load it on. We assume that all ships are sailing to the same destination. We don’t want a single shipment to get split up, so a shipment of 3 tonnes must be loaded completely onto one ship whose remaining capacity is at least 3. Of course, there may be several ships with sufficient capacity: you must choose to load on a ship with the smallest possible pier number (since our “better customers” get the lower pier numbers). Thus your data structure D must support the following four operations: INSERT(D,:1:): If :1: is a pointer to a new ship that is docking, insert the ship pointed to by :1: into D. DELETE(D, 90): If an is a pointer to a ship in D that’s about to set sail, remove that ship from D. FIND(D, 3): Return a pointer to a ship in D such that: (a) its capacity is at least 3 and (b) its pier number is minimum over all ships in D with capacity of at least .5. If no ship in D has a remaining capacity of at least 3 tonnes, then return NIL. LOAD(D,$, 5): If :1: is a pointer to a ship in D, load 5 tonnes on it. If the capacity remaining on this ship was c, it is thus decreased to c — s. In this question, you must explain how to implement D as an augmented AVL tree and explain how each of the above operations is executed. The worst—case run time of each of the above operations should be O(log n) where n is the number of ships in the data structure D. Since this implementation of D is based on a data structure and algorithms described in class and in the AVL handout, you should focus on the extensions and modifications needed here (you do not have to reproduce code or details provided in class or in the handout). Note that you cannot assume that pier locations are distinct: there may be several ships that have the same location (and may have different capacities). a. (6 marks) Give a precise and full description of your data structure. Illustrate this data structure by giving an example of it on some collection of docked ships of your own choice. b. (24 marks) Explain how to implement each of the above four operations in O(log n) time and explain Why, in each case7 your algorithm achieves this time complexity. Question 3. (20 marks) This question is a programming assignment. To see its description follow the “Programming question of Homework #2” link given in the “Handout and Homeworks” section of the course web page. ...
View Full Document

This note was uploaded on 04/30/2010 for the course CSC 263H taught by Professor Samt. during the Winter '10 term at University of Toronto- Toronto.

Page1 / 3

2 - Cover page for CSC263 Homework #2 (fill and attach...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online