Uploaded by Ильяс Батырбеков

PA1

advertisement
CSCI2520 Data Structures and Applications 2018-2019 Second Term
The Chinese University of Hong Kong
Assignment 1(Programming)
Expected time spent: 2-4 hours
Aims: To be familiar with the use of stack, queue, and hashtable in programming.
Programming Exercises:
Task1: Implement Queue using Two Stacks
In this task, you are given two stacks with their standard operations (Push, Pop, StackDepth,
StackIsEmpty) (use the stack implementation Version 2.2 described in the lecture note), implement
a queue with its standard operations (Enqueue, Dequeue, QueueLength, QueueIsEmpty).
Task2: Implement Stack using Two Queues
In this task, you are given two queues with their standard operations (Enqueue, Dequeue,
QueueLength, QueueIsEmpty) (use the queue implementation Version 3.0 described in the lecture
note), implement a stack with its standard operations (Push, Pop, StackDepth, StackIsEmpty).
Task3: Hash collisions
In this task, you are asked to implement a Hashtable ADT using (1) linear probing, (2) quadratic
probing, and (3) double hashing, respectively, and write an application program to compute the
number of collisions in a long random sequence of insertions using (1), (2), or (3).
Submission:
 This is a voluntary assignment.
 You should submit a single file <Your ID>_PA1.zip. For different tasks, you should place the
relevant files in their separate directory (preferable naming them as task1, task2, and task3).
Submit the file via “CU Blackboard System”.
 Insert your name, student ID, and e-mail address as comments at the beginning of your source
file.
/* CSCI2520
* Assignment: 1
* Task: Task index
* Student ID: You SID
* Name
: You name
* e-mail adr: You email
*/
Download