Description
You can choose any two of the three applications below for implementation.
Application 1:
Application 2:
Application 3:
2. Implementation
• Create your data set. For application 1 and 2, you can assume the maximum number of students is 3000 and pass this value as a parameter when creating your data set.
• Generate 1000 student records with random ages ranging from 18 to 30. Follow the steps below to generate random unique student IDs.
a. Implement a random integer generator, which randomly generates an integer number as either 1 or 2.
b. The first student ID can be determined as the return value of the random integer generator (i.e. either 1 or 2).
c. For each of the remaining student records, the ID field is determined by the previous student’s ID plus the return value of the random integer generator. For example, assuming that the 3rd student ID is 5, and that 2 is returned as a result of the random integer generator, the 4th student ID can be then determined as 5 + 2 = 7.
• Each time when a new student record is generated, insert it into your data set.
• For application 2 and 3, randomly generate a student ID (ranging from 0001 ~ 2000). Delete the record from your data set if it is found. For application 1, randomly generate a student age. Delete all the records with the given age in your data set.
• For application 1 and 3, call the maxAgeGap interface and print out the return value.
• Destroy your data set.
(2) Printf statement
• Add printf in searchAge, searchID, deletion functions, which prints (1) the Age and ID for the student record that needs to be searched or deleted; and (2) whether the delete has been done successfully or whether the item has been found.
• Add printf within maxAge function, which prints the maximum age gap for the current elements.
(3) Implementing your dataset ADT (dataset.c)
For each of the two applications that you choose, identify the most appropriate data structures so that the Big-O run time for frequent operations is optimized. Implement the interfaces required by the specific application in dataset.c.
(4) Some extra notes for hash table
If you use hash table for your implementation, please use a prime number for the table length. For example, 1009 is the smallest prime number greater than 1000. For simplicity reason, you can just use linear probing to resolve collisions, and an example hash function can be ℎ(𝑘𝑘) = (𝑘𝑘 + 𝑖𝑖)%𝑚𝑚 .
3. Submission
Your implementation will be graded in terms of correctness, clarity of implementation, and commenting and style. Your implementation must compile and run on the workstations in the lab. The algorithmic complexity of each function must be documented.
Reviews
There are no reviews yet.