Implementation of Selection Sort
A Course End Project Report – Data Structures Laboratory (A8507)
Submitted in the Partial Fulfilment of the
Requirements
for the Award of the Degree of
BACHELOR OF TECHNOLOGY
IN
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Submitted
By
Name of the Student: B. Praveen 23881A0512
Under the Esteemed Guidance of
Dr. Shanthi Makka
Professor
CSE
Department of Computer Science and Engineering
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
(AUTONOMOUS)
Affiliated to JNTUH, Approved by AICTE, Accredited by NAAC with A++ Grade, ISO 9001:2015
Certified
1
Kacharam, Shamshabad, Hyderabad – 501218, Telangana, India
June, 2024
2
Customer Service Call Centre
A Course End Project Report – Data Structures Laboratory (A8507)
Submitted in the Partial Fulfilment of the
Requirements
for the Award of the Degree of
BACHELOR OF TECHNOLOGY
IN
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Submitted
By
Name of the Student: B. Praveen 23881A0512
Under the Esteemed Guidance of
Dr. Shanthi Makka
Professor
CSE
Department of Computer Science and Engineering
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
(AUTONOMOUS)
Affiliated to JNTUH, Approved by AICTE, Accredited by NAAC with A++ Grade, ISO 9001:2015
Certified
Kacharam, Shamshabad, Hyderabad – 501218, Telangana, India
3
June, 2024
VARDHAMAN COLLEGE OF ENGINEERING,
HYDERABAD
An autonomous institute affiliated to JNTUH
Department of Computer Science and Engineering
CERTIFICATE
This is to certify that the Course End Project titled “Implementation of Selection Sort and Customer
Service Call Centre” is carried out by Mr. B. Praveen, Roll Number 23881A0512 towards A8507 –
Data Structures Laboratory course and submitted to Department of Computer Science and
Engineering, in partial fulfilment of the requirements for the award of degree of Bachelor of
Technology in Department of Computer Science and Engineering during the Academic year
2023-24.
Name & Signature of the Instructor Name & Signature of the HOD
Dr. Shanthi Makka
Dr. Ramesh Karnati
Professor, CSE
HOD, CSE
4
ACKNOWLEDGEMENT
The satisfaction that accompanies the successful completion of the task would be put incomplete
without the mention of the people who made it possible, whose constant guidance and
encouragement crown all the efforts with success.
We wish to express our deep sense of gratitude to Dr. Shanthi Makka, Professor, Department of
Computer Science and Engineering, Vardhaman College of Engineering, for her able guidance and
useful suggestions, which helped us in completing the design part of potential project in time.
We particularly thankful to Dr. Ramesh Karnati, Associate Professor & Head, Department of
Computer Science and Engineering for his guidance, intense support and encouragement, which
helped us to mould our project into a successful one.
We show gratitude to our honorable Principal [Link], for having provided all the
facilities and support.
We avail this opportunity to express our deep sense of gratitude and heartfelt thanks to Dr.
Teegala Vijender Reddy, Chairman and Sri Teegala Upender Reddy, Secretary of VCE, for
providing a congenial atmosphere to complete this project successfully.
We also thank all the staff members of Computer Science and Engineering for their valuable
support and generous advice. Finally, thanks to all our friends and family members for their
continuous support and enthusiastic help.
B. Praveen – 23881A0512
5
INDEX
1. Introduction…………………………………………………………………………………..6
2. Objective of the Project……………………………………………………………………....7
3. Problem statement……………………………………………………………………………7
4. Software and hardware requirements………………………………………………………...8
5. Project Description…………………………………………………………………………...8
6. Steps/Algorithm/Procedure…………………………………………………………………..9
7. Code………………………………………………………………………………………9-11
8. Result(s)……………………………………………………………………………….……12
9. Conclusion and Future work…………………………………………………………..…....12
10. References……………………………………………………………………………..…....13
Customer Service Call Centre
11. Introduction…………………………………………………………………………………14
12. Objective of the Project……………………………………………………………………..14
13. Problem statement…………………………………………………………………………15
14. Software and hardware requirements……………………………………………………….15
15. Project Description………………………………………………………………………….15
16. Steps/Algorithm/Procedure…………………………………………………………………16
17. Code……………………………………………………………………………………17-20
18. Result(s)……………………………………………………………………………….20-21
19. Conclusion and Future work…………………………………………………………..…....22
20. References……………………………………………………………………………..…....23
6
Introduction
Selection sort is a simple and efficient sorting algorithm that works by
repeatedly selecting the smallest (or largest) element from the unsorted
portion of the list and moving it to the sorted portion of the list.
The algorithm repeatedly selects the smallest (or largest) element from the
unsorted portion of the list and swaps it with the first element of the unsorted
part. This process is repeated for the remaining unsorted portion until the
entire list is sorted.
In computer science, selection sort is an in-place comparison sorting algorithm.
It has an O(n2) time complexity, which makes it inefficient on large lists, and generally
performs worse than the similar insertion sort. Selection sort is noted for its simplicity and
has performance advantages over more complicated algorithms in certain situations,
particularly where auxiliary memory is limited.
The algorithm divides the input list into two parts: a sorted sublist of items which is built up
from left to right at the front (left) of the list and a sublist of the remaining unsorted items
that occupy the rest of the list. Initially, the sorted sublist is empty and the unsorted sublist
is the entire input list. The algorithm proceeds by finding the smallest (or largest,
depending on sorting order) element in the unsorted sublist, exchanging (swapping) it with
the leftmost unsorted element (putting it in sorted order), and moving the sublist
boundaries one element to the right.
7
Objective
The objective of the selection sort algorithm is to sort a list of elements into either ascending or
descending order by iteratively selecting the minimum (or maximum) element from the unsorted
part of the list and swapping it with the first unsorted element. This process continues until the
entire list is sorted. The main goal is to arrange the elements in the desired order efficiently.
In selection sort, the algorithm divides the input list into two parts: the sorted part at the
beginning and the unsorted part at the end. It repeatedly selects the smallest element from the
unsorted part and swaps it with the element at the beginning of the unsorted part. This process
continues until the entire list is sorted. Selection sort is not very efficient for large lists due to its
time complexity of O(n^2), but it is simple and easy to implement.
Problem statement
"Given an array of elements, sort the array in either ascending or descending order using the
selection sort algorithm. Implement a program that iterates through the array, selecting the
minimum (or maximum) element from the unsorted part and swapping it with the first unsorted
element. Repeat this process until the entire array is sorted. Provide the sorted array as the
output."
8
Software and hardware requirements
To implement the selection sort algorithm, you don't need any specific software requirements
beyond a basic programming environment that supports the language you are using, such as
Python, Java, C++, etc. You can write and run the selection sort code in a simple text editor or an
integrated development environment (IDE) like Visual Studio Code, PyCharm, or Eclipse.
As for hardware requirements, selection sort is not computationally intensive, so it can run on any
standard computer or laptop without any special hardware requirements. A basic laptop or
desktop with a standard processor and memory should be sufficient to run selection sort
efficiently.
Project Description
For the project description involving selection sort, you could create a program that sorts a list of
elements in either ascending or descending order using the selection sort algorithm. The project
could include functionalities such as taking input from the user, displaying the unsorted list,
sorting the list using selection sort, and then displaying the sorted list. Additionally, you could
implement error handling for invalid inputs and provide options for the user to choose the sorting
order (ascending or descending).
9
Steps/Algorithm/Procedure
steps for the selection sort algorithm:
1. Start with the first element of the array as the minimum (or maximum) element.
2. Compare this element with the rest of the elements in the array to find the smallest (or
largest) element.
3. Swap the minimum (or maximum) element with the first element of the unsorted part of
the array.
4. Move the boundary between the sorted and unsorted parts one element to the right.
5. Repeat steps 2-4 for the remaining unsorted part of the array until the entire array is
sorted.
These steps outline the process of selection sort in sorting an array of elements. If you have any
questions or need further clarification on any of the steps.
Code
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void selectionSort(int arr[], int n)
{
int i, j, min_idx;
for (i = 0; i < n-1; i++)
{
min_idx = i;
for (j = i+1; j < n; j++)
{
if (arr[j] < arr[min_idx])
{
min_idx = j;
}
}
10
// Swap the found minimum element with the first element
int temp = arr[min_idx];
arr[min_idx] = arr[i];
arr[i] = temp;
}
void generateRandomArray(int arr[], int size, int lower_bound, int upper_bound)
{
srand(time(NULL)); // Seed for random number generation
for (int i = 0; i < size; i++)
{
arr[i] = rand() % (upper_bound - lower_bound + 1) + lower_bound;
}
int main()
{
int choice;
printf("Do you want to input your own array (1) or generate a random array (2)? ");
scanf("%d", &choice);
int size, lower_bound, upper_bound;
if (choice == 1)
{
printf("Enter the size of the array: ");
scanf("%d", &size);
int arr[size];
printf("Enter the array elements separated by space: ");
for (int i = 0; i < size; i++)
{
scanf("%d", &arr[i]);
}
selectionSort(arr, size);
printf("Sorted array: ");
for (int i = 0; i < size; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
11
else if (choice == 2)
{
printf("Enter the size of the array: ");
scanf("%d", &size);
printf("Enter the lower bound of the array elements: ");
scanf("%d", &lower_bound);
printf("Enter the upper bound of the array elements: ");
scanf("%d", &upper_bound);
int arr[size];
generateRandomArray(arr, size, lower_bound, upper_bound);
printf("Generated random array: ");
for (int i = 0; i < size; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
selectionSort(arr, size);
printf("Sorted array: ");
for (int i = 0; i < size; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
else
{
printf("Invalid choice.\n");
}
return 0;
}
12
Results
Do you want to input your own array (1) or generate a random array (2)? 1
Enter the size of the array: 5
Enter the array elements separated by space: 25 2 87 34 0
Sorted array: 0 2 25 34 87
Do you want to input your own array (1) or generate a random array (2)? 1
Enter the size of the array: 8
Enter the array elements separated by space: -4 21 58 27 1 0 -53 12
Sorted array: -53 -4 0 1 12 21 27 58
Conclusion and Future work
For future work on the selection sort implementation, you could consider optimizing the
algorithm for larger arrays by incorporating techniques like early stopping if the array is already
sorted or minimizing unnecessary comparisons during the selection process. Additionally, you
could explore parallelizing the selection sort algorithm to leverage multiple processors for faster
sorting of large arrays. These optimizations can help improve the efficiency and performance of
the selection sort algorithm in practical scenarios. If you have any more questions or need further
guidance on enhancing the selection sort implementation
13
References
Professor
Books
Online
Friends
Brother
14
Introduction
In the realm of customer service, managing incoming calls efficiently is paramount to maintaining
customer satisfaction and operational productivity. A call center simulation serves as a vital tool for
understanding and optimizing the flow of calls and agent availability. This project focuses on
creating a simulation of a customer service call center where incoming calls are managed using a
circular queue, and available agents handle these calls in real-time.
The circular queue, also known as a ring buffer, is a data structure that uses a fixed-size buffer as if
it were connected end-to-end. This structure is particularly advantageous for scenarios involving
continuous data streams or cyclical operations, as it efficiently manages memory and prevents
overflow. By implementing a circular queue, the simulation ensures that incoming calls are
enqueued in a manner that utilizes the available buffer space optimally and maintains the order of
calls.
Agents in the call center are the lifeline of the customer service operation. The simulation allocates
calls to available agents based on their availability, ensuring that calls are attended to promptly.
This dynamic allocation mimics real-world scenarios where agents must handle calls as they come
in, maintaining a balance between handling current calls and being ready for new ones.
Objective
Modeling Call Flow: Accurately simulate the arrival and handling of customer calls using a circular
queue to manage the sequence and availability of buffer space.
Agent Utilization: Efficiently allocate calls to available agents, ensuring minimal wait times and
optimal use of resources.
Performance Analysis: Provide insights into call handling efficiency, average wait times, and agent
utilization rates to identify areas for improvement.
This simulation not only provides a practical implementation of a circular queue in a real-world
scenario but also serves as a foundation for more complex studies on call center dynamics and
resource management. By understanding the flow and management of calls, businesses can
improve their customer service operations, ultimately leading to enhanced customer satisfaction
and operational efficiency
15
Problem statement
Create a simulation of a customer service call center where incoming calls are added to a circular
queue and handled by available agents
Software and hardware requirements
Software Requirements:
1. Programming Language: You can use languages like Java, Python, C++, or any other language
you are comfortable with for coding the simulation.
2. Data Structures: Implement a circular queue data structure to manage incoming calls.
Hardware Requirements:
1. Computer: A desktop or laptop to run the simulation software.
2. Processor and RAM: A decent processor with enough RAM to handle the simulation
Smoothly.
3. Storage: Sufficient storage space to store the simulation code and related files.
Project Description
Create a simulation that models the operation of a customer service call center. The simulation
will use a circular queue to manage incoming calls and assign them to available agents. The aim is
to provide insights into call handling efficiency, agent utilization, and overall call center
performance and Develop a simulation of a customer service call center where incoming calls are
managed using a circular queue and assigned to available agents. The goal is to model the call
handling process to improve understanding and efficiency of call management and agent
utilization.
16
Steps/Algorithm/Procedure
To create a simulation of a customer service call center where incoming calls are added to a
circular queue and handled by available agents, you can follow these steps:
1. Implement a Circular Queue Data Structure:
- Define a circular queue to manage the incoming calls. Include functions for enqueue (adding a
call) and dequeue (removing a call).
2. Create Agent Objects:
- Define an agent class with attributes like availability status, ID, etc.
3. Manage Agent Availability:
- Keep track of available agents. When an agent finishes handling a call, make them available
again.
4. Simulate Incoming Calls:
- Generate incoming calls at random intervals or based on a predefined pattern.
5. Assign Calls to Available Agents:
- Check for available agents in the queue. If an agent is available, assign the call to them.
6. Handle Call:
- Simulate the call handling process. This can involve resolving customer issues, recording call
details, etc.
7. Update Queue and Agent Status:
- Update the circular queue after call handling. If an agent is busy, mark them as unavailable
until they finish the call.
8. Repeat Simulation:
- Continuously simulate incoming calls and agent availability to mimic a real call center
environment.
By following these steps and implementing the necessary logic in your chosen programming
language, you can create a functional simulation of a customer service call center.
17
Code
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <unistd.h>
#define QUEUE_SIZE 10
#define NUM_AGENTS 3
#define CALL_HANDLE_TIME 5 // in seconds
typedef struct
{
int id;
time_t arrival_time;
} Call;
typedef struct
{
Call calls[QUEUE_SIZE];
int front;
int rear;
int size;
} CircularQueue;
typedef struct
{
bool is_busy;
Call current_call;
time_t end_time;
} Agent;
void initializeQueue(CircularQueue* q)
{
q->front = 0;
q->rear = -1;
q->size = 0;
}
18
bool isQueueFull(CircularQueue* q)
{
return q->size == QUEUE_SIZE;
}
bool isQueueEmpty(CircularQueue* q)
{
return q->size == 0;
}
bool enqueue(CircularQueue* q, Call call)
{
if (isQueueFull(q))
{
return false;
}
q->rear = (q->rear + 1) % QUEUE_SIZE;
q->calls[q->rear] = call;
q->size++;
return true;
}
bool dequeue(CircularQueue* q, Call* call) {
if (isQueueEmpty(q)) {
return false;
}
*call = q->calls[q->front];
q->front = (q->front + 1) % QUEUE_SIZE;
q->size--;
return true;
}
void handleCall(Agent* agent, Call call)
{
agent->is_busy = true;
agent->current_call = call;
agent->end_time = time(NULL) + CALL_HANDLE_TIME;
printf("Agent handling call %d\n", [Link]);
}
void checkAgents(Agent* agents, CircularQueue* queue)
{
19
for (int i = 0; i < NUM_AGENTS; i++)
{
if (agents[i].is_busy && time(NULL) >= agents[i].end_time)
{
agents[i].is_busy = false;
printf("Agent finished call %d\n", agents[i].current_call.id);
}
if (!agents[i].is_busy)
{
Call next_call;
if (dequeue(queue, &next_call))
{
handleCall(&agents[i], next_call);
}
}
}
}
int main() {
CircularQueue queue;
Agent agents[NUM_AGENTS] = {0};
int call_id = 1;
initializeQueue(&queue);
srand(time(NULL));
for (int t = 0; t < 30; t++) // Simulate 30 seconds of operation
{
if (rand() % 2 == 0) // Randomly decide if a new call arrives
{
Call new_call = {call_id++, time(NULL)};
if (enqueue(&queue, new_call))
{
printf("New call %d added to the queue\n", new_call.id);
}
else
{
printf("Queue full! Call %d dropped\n", new_call.id);
}
20
checkAgents(agents, &queue);
sleep(1); // Simulate each second
return 0;
}
Results
New call 1 added to the queue
Agent handling call 1
New call 2 added to the queue
Agent handling call 2
New call 3 added to the queue
Agent handling call 3
New call 4 added to the queue
Agent finished call 1
Agent handling call 4
New call 5 added to the queue
Agent finished call 2
Agent handling call 5
Agent finished call 3
New call 6 added to the queue
Agent handling call 6
Agent finished call 4
New call 7 added to the queue
Agent handling call 7
Agent finished call 5
New call 8 added to the queue
Agent handling call 8
Agent finished call 6
New call 9 added to the queue
Agent handling call 9
Agent finished call 7
New call 10 added to the queue
Agent handling call 10
New call 11 added to the queue
New call 12 added to the queue
Agent finished call 8
Agent handling call 11
Agent finished call 9
21
Agent handling call 12
Agent finished call 10
New call 13 added to the queue
Agent handling call 13
Agent finished call 11
New call 14 added to the queue
Agent handling call 14
Agent finished call 12
New call 15 added to the queue
Agent handling call 15
Agent finished call 13
22
Conclusion and Future work
The simulation of a customer service call center using a circular queue and dynamic agent
assignment has provided significant insights into the operational efficiency of call handling
processes. By modeling the arrival and management of calls, the simulation effectively
demonstrates how a circular queue can optimize buffer usage and maintain the order of incoming
calls. The real-time assignment of calls to available agents ensures that customer inquiries are
addressed promptly, minimizing wait times and enhancing overall customer satisfaction.
Efficient Call Management: The circular queue structure proved effective in managing incoming
calls, preventing buffer overflow, and maintaining an orderly sequence of call handling.
Future Work
While the current simulation offers a robust framework for understanding call center dynamics,
several enhancements and extensions can be pursued to further refine and expand its capabilities:
Advanced Queue Management:
Priority Queuing: Implement priority levels for different types of calls, ensuring that high-priority
calls are handled more quickly.
Agent Skills Differentiation:
Skill-Based Routing: Assign calls to agents based on their skill sets and expertise, improving the
quality and speed of call resolution.
Training Simulation: Incorporate agent training modules to simulate the impact of agent skill
development on overall performance.
Scalability and Performance Testing:
Large-Scale Simulation: Expand the simulation to model larger call centers with more agents and
higher call volumes, testing the scalability and robustness of the system.
Performance Optimization: Analyze and optimize the performance of the simulation code to
handle more complex scenarios and larger data sets.
Real-Time Analytics and Monitoring:
API Integration: Explore integration with actual call center software and customer relationship
management (CRM) systems to validate the simulation results against real-world data.
Feedback Loop: Create a feedback loop where the simulation can be used to test and refine real-
world call center policies and strategies.
23
References
Professor
Books
Online
Friends
24