The Zoo Gallery
Manage your zoo animals in a command-line program written in C!
For my Data Structures & Algorithms course, our team was tasked to create a record management system using different data structures and algorithms. Since our team showed an affinity towards animals, we decided to create an animal management system that allows users such as zoo keepers to easily keep track of their animals.
Aside from a linked list, we also used a queue to keep track of available animal IDs. Whenever the user deletes an existing record, that record’s animal ID is enqueued into the queue. This allows the application to reuse past IDs, instead of continuing from the very last animal ID. So, the next time the user enters a new animal, it will prioritize the available animal ID in the queue and dequeue that as the record’s ID. However, if the queue is empty, then the record’s ID will be a continuation of the very last record ID used.
In The Zoo Gallery, the user can choose to search, delete and edit existing animal records, as well as insert new animals into the system. Logically, if the user tries to add a new animal that already has the same name, sex, and location as another animal record, our application would simply relocate that animal to a new location. The user actions available are displayed in the image on the right.
In order to store the records of animals into the system, we created a circular doubly linked list that dynamically sorts by the record’s animal ID. When the program loads for the first time, the linked list has an average time complexity of
O(1) when it is being initialized with the animal records. Since the CSV file that contains the animal records are already sorted, these records have a constant time of being inserted into the linked list. For searching, we used a binary search algorithm, since our linked list is already sorted by default. This allows our application to an average case of
O(log n) for searching through animal records.