0% found this document useful (0 votes)
6 views3 pages

Data Structures Assignment

The document outlines a contacts management system utilizing data structures such as linked lists, hash tables, and stacks for efficient contact management. It details functionalities for adding, updating, deleting, and sorting contacts, as well as searching for them using hashing. The implementation includes classes for contacts and nodes, and emphasizes efficient retrieval and modification of contact information.

Uploaded by

lamiyachulu06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Data Structures Assignment

The document outlines a contacts management system utilizing data structures such as linked lists, hash tables, and stacks for efficient contact management. It details functionalities for adding, updating, deleting, and sorting contacts, as well as searching for them using hashing. The implementation includes classes for contacts and nodes, and emphasizes efficient retrieval and modification of contact information.

Uploaded by

lamiyachulu06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Data Structures Assignment

Data Structures Implementation:


1. Utilize linked lists to manage a dynamic list of contacts.
- The code implements a linked list (`LinkedList` class) to manage the list of contacts. Each
node in the linked list contains a `Contact` object.
- Operations like insertion, deletion, and searching are performed efficiently using linked
lists.

2. Implement a stack to track the history of contact modifications.


- The code does not explicitly implement a stack for tracking history. However, you could
extend the functionality by adding a stack data structure and pushing contact modifications
onto the stack whenever a contact is added, updated, or deleted.

3. Incorporate a hash table to optimize search operations based on contact attributes.


- The code implements a hash table (`HashTable` class) to optimize search operations.
Contacts are hashed using a hash function, and each bucket in the hash table contains a
linked list of contacts with the same hash value.
- This allows for efficient search operations based on contact attributes like name.

Functionality:
1. Design functionalities for adding, updating, and deleting contacts.
- The code provides methods for adding (`insert`), updating (`update_contact`), and
deleting (`delete`) contacts from the system.
- Users can create new contacts, update existing contact information, and delete contacts
by name.

2. Implement a feature to display the contact list in various sorted orders.


- The code offers sorting functionality for displaying the contact list in sorted orders based
on different attributes such as name, phone number, and email.
- Users can choose to sort contacts by name, phone number, or email using the menu
options.

3. Include a search mechanism that leverages hashing for efficient lookups.


- The code implements a search mechanism (`search` method) that leverages hashing for
efficient lookups.
- Contacts are stored in a hash table, allowing for quick retrieval based on the contact's
name.

Sorting and Searching:


1. Employ sorting algorithms for ordered display of contacts based on different
attributes.
- The code utilizes sorting algorithms (e.g., `sort_contacts_by_name`,
`sort_contacts_by_phone_number`, `sort_contacts_by_email`) to display contacts in
ordered lists based on different attributes.

2. Implement searching algorithms to locate specific contacts efficiently.


- The code implements searching functionality (`search` method) that efficiently locates
specific contacts based on their name using hashing for quick lookups.

Summary

1. Classes:
- `Contact`: Represents a single contact with attributes `name`, `phone_number`, and
`email`.
- `Node`: Represents a node in a linked list. Each node holds a `Contact` object and a
reference to the next node.
- `LinkedList`: Represents a linked list of contacts. It has methods to insert, delete, and
search for contacts.
- `HashTable`: Implements a hash table to store contacts efficiently. It uses separate
chaining to handle collisions.

2. Functionality:
- View Contacts: Displays all contacts stored in the system.
- Create Contacts: Allows users to add new contacts.
- Search Contacts: Allows users to search for contacts by name.
- Delete Contacts: Allows users to delete contacts by name.
- Update Contacts: Allows users to update existing contact information.
- Sort Contacts: Allows users to sort contacts by name, phone number, or email.
- Save and Load Contacts: Contacts are saved to and loaded from a CSV file.

3. Questions and Answers:


- What is the purpose of the `Node` class?
The `Node` class represents a single node in a linked list. It contains a reference to a
`Contact` object and a reference to the next node in the list.

- How does the `HashTable` class handle collisions?


The `HashTable` class uses separate chaining to handle collisions. Each slot in the hash
table is initialized with a linked list. If two contacts hash to the same index, they are stored in
the same linked list.
- How are contacts stored in the system?
Contacts are stored in a hash table for efficient retrieval. Each contact is hashed using a
hash function, and the resulting index is used to store the contact in the hash table.

- How does the system update contact information?


The `update_contact` method in the `HashTable` class allows the system to update
contact information. It searches for the contact by name, updates the contact's attributes if
specified (name, phone number, email), and rehashes the contact if the name is changed.

- What is the purpose of the `clear_console` function?


The `clear_console` function clears the console screen, providing a clean interface for the
user to interact with the menu options.

Overall, the code effectively implements the required functionalities and data structures to
manage a contacts management system efficiently.

Made by Madalitso MUTIYA


Contact: madalitsomutiya@outlook.com

You might also like