Case Study
Case Study
Submitted by:
ANIKET: 23BCS10720
BACHELOR OF ENGINEERING
IN
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:
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:
After careful consideration, a Hash Table and a Balanced Binary Search Tree (BST) were
chosen as the main data structures to manage contact information.
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.
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.
Time Complexity:
Algorithm:
Time Complexity:
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:
Algorithm:
Time Complexity:
Algorithm:
Time Complexity:
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.
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)).
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.