0% found this document useful (0 votes)
29 views5 pages

Case Study

ppt

Uploaded by

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

Case Study

ppt

Uploaded by

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

PROJECT:

Contact Managing System


PROJECT REPORT

Submitted by:
ANIKET: 23BCS10720

in partial fulfillment for the award of the


degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE & ENGINEERING

Chandigarh University
Case Study: Contact Managing System
Using Data Structures and Algorithms
1. Introduction
Managing contacts efficiently is crucial for individuals and organizations. A Contact
Managing System (CMS) allows users to store, retrieve, update, and delete contact
information like names, phone numbers, and email addresses. The complexity of operations
such as searching for a contact or adding a new contact can be minimized using effective data
structures and algorithms. This case study explores how the design and implementation of a
CMS can be optimized using Data Structures and Algorithms (DSA) concepts, focusing on
key operations like searching, sorting, and CRUD (Create, Read, Update, Delete)
functionalities.

2. Problem Statement
The goal of the Contact Managing System is to maintain a dynamic list of contacts that
supports efficient:

 Addition of new contacts.


 Search functionality based on names, phone numbers, or email addresses.
 Deletion of a contact.
 Updating contact information.
 Sorting contacts in alphabetical order for easier lookup.

Given the volume of data that can grow over time, the challenge lies in designing an efficient
system that minimizes time complexity for these operations while keeping the memory usage
optimal.

3. Design Overview
To develop a robust contact managing system, the following data structures were considered:

 Arrays or Lists for basic storage.


 Linked Lists for dynamic contact management.
 Hash Tables for fast search and retrieval.
 Binary Search Trees (BST) for efficient sorting and searching.

After careful consideration, a Hash Table and a Balanced Binary Search Tree (BST) were
chosen as the main data structures to manage contact information.

Data Structure Chosen: Hash Table and Balanced BST

 Hash Table:
This was selected for fast insertion, deletion, and lookup operations (average time
complexity: O(1)). Each contact entry (name, phone, email) can be used as a unique
key for quick searching.
 Balanced Binary Search Tree (BST):
A self-balancing BST (such as AVL or Red-Black Tree) helps maintain an
alphabetically ordered list of contacts. The insertion and search operation in a BST
takes O(log n) time, ensuring efficient performance even as the number of contacts
grows.

4. Key Operations Using DSA


4.1. Adding a Contact

Algorithm:

 Step 1: Generate a unique key for the contact (e.g., contact’s name).
 Step 2: Insert the contact into the Hash Table using this key.
 Step 3: Also, insert the contact into the BST based on the contact’s name to maintain
the alphabetical order.

Data Structures Used:

 Hash Table for quick access.


 BST for maintaining sorted contacts.

Time Complexity:

 Hash Table Insertion: O(1) (Average case).


 BST Insertion: O(log n) (For a balanced tree).

4.2. Searching for a Contact

Algorithm:

 Step 1: Input the search key (e.g., name or email).


 Step 2: Check the Hash Table for the contact using the search key.
 Step 3: If the contact is not found in the Hash Table, traverse the BST as a backup
search (this ensures redundancy).

Time Complexity:

 Hash Table Search: O(1) (Average case).


 BST Search: O(log n) (For sorted traversal or in case of failure in the hash lookup).

4.3. Deleting a Contact

Algorithm:

 Step 1: Locate the contact in the Hash Table using the contact’s name or email.
 Step 2: If found, delete the contact from both the Hash Table and the BST.
Time Complexity:

 Hash Table Deletion: O(1).


 BST Deletion: O(log n).

4.4. Updating a Contact

Algorithm:

 Step 1: Find the contact in the Hash Table.


 Step 2: Modify the corresponding fields (phone number, email, etc.).
 Step 3: If the name changes, update both the Hash Table and BST.

Time Complexity:

 Hash Table Update: O(1).


 BST Update (if name changes): O(log n).

4.5. Sorting Contacts

Algorithm:

 Step 1: Inorder traversal of the BST to retrieve contacts in alphabetical order.

Time Complexity:

 Sorting: O(n) (for inorder traversal of a BST).

5. Algorithmic Challenges and Solutions


5.1. Hash Collisions in Hash Table

Challenge: Hash collisions can occur when two contacts have the same hash value.
Solution: Use Chaining or Open Addressing to handle collisions. In this CMS, chaining is
employed where a linked list is used to handle multiple contacts mapped to the same hash
key.

5.2. Self-Balancing of BST

Challenge: Without balancing, a BST can become skewed, leading to O(n) search time in the
worst case.
Solution: Using a Red-Black Tree ensures that the tree remains balanced after every
insertion or deletion, keeping search operations efficient (O(log n)).

5.3. Memory Management

Challenge: Managing multiple data structures (Hash Table and BST) for the same set of data
may increase memory usage.
Solution: While this increases memory complexity, it optimizes time performance,
particularly when handling a large volume of contacts.

6. Conclusion
The implementation of the Contact Managing System using Data Structures and Algorithms
demonstrates how different structures can be combined to achieve efficiency. The use of a
Hash Table ensures constant time complexity for basic operations, while a Balanced Binary
Search Tree enables sorted retrievals and search optimization. The trade-offs between time
and memory complexity are addressed by selecting appropriate data structures, allowing the
system to scale effectively as the number of contacts increases.

Summary of Key Concepts:

 Hash Table: Fast lookup and modification (O(1) average time).


 Balanced BST: Efficient sorting and searching (O(log n)).
 Chaining: Handling hash collisions.
 Self-Balancing: Ensures optimal tree height and performance.

You might also like