K. L. E.
SOCIETY’S
K. L. E. INSTITUTE OF TECHNOLOGY,
K.L.E.S. Opp. Airport, Gokul, Hubballi-580 027
Phone: 0836-2232681 Website: [Link]
A Mini Project Report on
“Song Playlist Sorter”
Electronics and Communication Engineering
Semester IV
Data Structures Lab Using C (BECL456D)
Academic Year 2023-24
Submitted By
DIYA KABIN 2KE22EC026
SHASHANK NARAGUNDMATH 2KE22EC126
DIYA BAFNA 2KE22EC129
Under the Guidance of
Mrs. Vinoda Dibbad
Electronics and Communication Engineering
K. L. E. SOCIETY’S
K. L. E. INSTITUTE OF TECHNOLOGY,
Opp. Airport, Gokul, Hubballi-580 027
Phone: 0836-2232681 Website: [Link]
CERTIFICATE
Certified that the mini project work entitled “Song Playlist Sorter” is a bonafide work
carried out by Ms. Diya Kabin (USN:2KE22EC026), Mr. Shashank
Naragundmath(2KE22EC126) and Ms. Diya Bafna (USN:2KE22EC129) in partial fulfillment
for the award of degree of Bachelor of Engineering in IV Semester, Electronics and
Communication Engineering of Visvesvaraya Technological University, Belagavi, during
the year 2023-24. It is certified that all corrections/suggestions indicated for internal assessment
have been incorporated in the report deposited in the department library.
Signature of the Guide Signature of the HOD Signature of the Principal
(Mrs. Vinoda Dibbad) (Dr. Gopal Bidkar) (Dr. Manu T.M)
ACKNOWLEDGEMENT
The mini project report on “Song Playlist Sorter” is the outcome of guidance, moral
support and devotion bestowed on us throughout our work. For this we acknowledge and
express our profound sense of gratitude and thanks to everybody who have been a source
of inspiration during the project work.
First and foremost we offer our sincere phrases of thanks with innate humility to our
Principal Dr. Manu T.M who has been a constant source of support and encouragement.
We would like to thank our Dean Dr. Yerriswamy for his constant support and guidance.
We feel deeply indebted to our H.O.D. Dr. Gopal Bidkar for the right help provided from
thetime of inception till date. We would take this opportunity to acknowledge our Guide
Mrs. Vinoda Dibbad who not only stood by us as a source of inspiration, but also
dedicated her time for us to enable us to present the project on time.
Last but not least, we would like to thank our parents, friends & well wishers who have
helped us in this work.
Name of the Students
Diya Kabin
Shashank Naragundmath
Diya Bafna
ABSTRACT
This project report presents the development and implementation of a song playlist sorter using
the C programming language, employing fundamental data structures. The primary goal is to
create a system capable of sorting a playlist based on song attributes, specifically duration and
name, to facilitate efficient organization and retrieval of songs.
The project utilizes an array of structures to store song information, which includes the name
and duration of each song. The sorting process is implemented using two variants of the Bubble
Sort algorithm: one for sorting songs by their duration and another for sorting by their names.
This choice of algorithm provides a straightforward and effective means to achieve the desired
sorting functionality within the constraints of the project.
The report details the implementation of the sorter, including the input mechanism for song
details, the sorting functions, and the output of the sorted playlist. Through this project, we
explore the application of sorting algorithms and data structures in C, highlighting the
importance of algorithmic efficiency and data organization in software development.
The results demonstrate the successful sorting of the playlist by both duration and name,
showcasing the practical application of data structures and algorithms in solving real-world
problems. This project serves as an educational tool, enhancing our understanding of data
manipulation and algorithm implementation in C.
CONTENTS
Contents Page No
1. Introduction 1
1.1 Introduction to Data Structures 1
1.2 Introduction to Project 2
1.3 Scope of the Project 3
6
2. Working Principle
6
2.1 Working Principle
7
2.2 Block Diagram
8
3. Algorithm
4. Implementation 10
5. Output Snapshots 14
6. Advantages and Disadvantages 16
7. Applications 18
20
8. Conclusion
21
References
Mini Project report on Song Playlist Sorter
1. INTRODUCTION
1.1 Introduction to Data Structures
Data structures are fundamental to computer science and programming, as they provide a means to manage
and organize data efficiently. Here's an introduction to some common data structures using the C
programming language.
Basic Concepts
1. Data Structure: A way to store and organize data to be used efficiently.
2. Algorithm: A step-by-step procedure to perform a task or solve a problem.
3. Abstract Data Type (ADT): A data type defined by its behaviour (operations) rather than its
implementation.
Common Data Structures
1. Arrays
• A collection of elements identified by index or key.
• Elements are stored in contiguous memory locations.
2. Linked Lists
• A linear data structure where elements are stored in nodes.
• Each node contains a data part and a pointer to the next node.
3. Stacks
• A linear data structure that follows Last In, First Out (LIFO) principle.
• Operations: `push` (add an element), `pop` (remove an element).
4. Queues
• A linear data structure that follows First In, First Out (FIFO) principle.
• Operations: `enqueue` (add an element), `dequeue` (remove an element).
Dept. of ECE, KLEIT, Hubballi Page 2
Mini Project report on Song Playlist Sorter
5. Trees
• A hierarchical data structure with a root node and child nodes forming a tree-like structure.
• Binary Tree: Each node has at most two children (left and right).
6. Graphs
• A collection of nodes (vertices) connected by edges.
Data structures are essential for organizing data efficiently. Understanding arrays, linked lists, stacks,
queues, trees, and graphs in C provides a foundation for solving complex problems and optimizing
algorithms.
1.2 Introduction to Project
In today's digital age, music playlists have become an integral part of our daily lives, providing us with
endless hours of entertainment and motivation. However, managing and organizing these playlists can
sometimes be a cumbersome task, especially when dealing with large collections of songs. To address this
challenge, we have developed a Songs Playlist Sorter using the C programming language.
Song Duration Sorting: The program sorts songs by their duration in ascending order, making it easy for
users to find shorter or longer songs according to their preferences.
Alphabetical Sorting by Song Names: The playlist can also be sorted alphabetically by song names,
allowing for quick access to songs based on their titles.
User-Friendly Input and Output: Users can input their song details directly into the program, and the sorted
playlist is displayed in a clear and readable format.
The Songs Playlist Sorter is a C program designed to help users organize their music playlists by sorting
songs based on duration and names. Using the Bubble Sort algorithm, it arranges songs either by their
duration in ascending order or alphabetically by their titles. The program features a `Song` structure to
represent each song and includes functions for sorting and swapping song positions. Users can input song
details directly, and the program outputs the sorted playlists in a clear format, providing an effective tool
for managing music collections and a practical example for learning sorting algorithms in C.
In the realm of computer science and software development, data structures play a crucial role in efficiently
Dept. of ECE, KLEIT, Hubballi Page 3
Mini Project report on Song Playlist Sorter
managing and manipulating data. This mini-project focuses on creating a song playlist sorter using the C
programming language, leveraging fundamental data structures to achieve optimal performance and
[Link] objective of this project is to design and implement a system that sorts a collection of
songs based on various attributes such as title, artist, album, or duration. By employing data structures
such as arrays, linked lists, and trees, we aim to explore different sorting algorithms and their impact on
the efficiency of the playlist sorting process.
This report provides a comprehensive overview of the project, detailing the problem statement, objectives,
methodology, implementation, and results. It aims to highlight the importance of choosing the appropriate
data structures and algorithms in solving real-world problems, emphasizing their practical applications in
organizing and managing data effectively. Through this project, we seek to enhance our understanding of
data structures and algorithms, improve our programming skills in C, and gain insights.
1.3 Scope of the Project
The Song Playlist Sorter project aims to create a program that manages and sorts a playlist of songs using
various data structures. This project will provide hands-on experience with data structures, including
arrays, linked lists, stacks, queues, and trees. The following sections outline the project's scope, including
its objectives, functionalities, data structures used, and potential extensions.
1.3.1 Objectives
1. Sorting
• Implement sorting algorithms to sort the playlist based on different criteria (title, artist, duration,
genre).
2. User Interaction
• Provide a user-friendly interface for interacting with the playlist.
• Offer menu-driven options for performing various operations on the playlist.
Dept. of ECE, KLEIT, Hubballi Page 4
Mini Project report on Song Playlist Sorter
1.3.2 Functionalities
1. Song Management
• Add a new song to the playlist.
• Display all songs in the playlist.
2. Sorting
• Sort songs by title (alphabetically).
• Sort songs by duration (ascending).
1.3.3 Data Structures Used
1. Array: Use arrays to store the playlist when implementing sorting and searching algorithms.
2. Stack: Implement a stack to manage recently played songs or to provide an undo feature for the playlist
operations.
3. Queue: Use a queue to simulate a play queue, where songs are played in a First In, First Out (FIFO)
order.
The Song Playlist Sorter project offers a comprehensive exercise in using various data structures in C. It
provides a practical way to understand and implement fundamental concepts in data structures, sorting,
and searching algorithms, all within the context of a useful application.
Dept. of ECE, KLEIT, Hubballi Page 5
Mini Project report on Song Playlist Sorter
2. WORKING PRINCIPLE
2.1 Working Principle
The primary objective of this mini-project is to sort a playlist of songs using different attributes
such as song duration and song name. The project employs Bubble Sort, a simple comparison-
based sorting algorithm, to achieve this. The working principle can be broken down into the
following steps:
1. Data Input: The program starts by accepting the number of songs and their details (name and
duration) from the user.
2. Sorting by Duration: The playlist is sorted based on song duration using Bubble Sort. This
involves comparing adjacent elements and swapping them if they are in the wrong order. This
process repeats until the entire playlist is sorted by duration.
3. Printing Sorted Playlist: The sorted playlist by duration is printed to the console.
4. Sorting by Name: The same playlist is then sorted by song name using another Bubble Sort
implementation. Here, song names are compared lexicographically.
5. Printing Sorted Playlist by Name: Finally, the sorted playlist by name is printed to the console.
Dept. of ECE, KLEIT, Hubballi Page 6
Mini Project report on Song Playlist Sorter
2.2 Block Diagram
Here is a block diagram to illustrate the process:
Fig. 2.2: Block diagram of Song Playlist Sorter
Dept. of ECE, KLEIT, Hubballi Page 7
Mini Project report on Song Playlist Sorter
3. ALGORITHM
3.1 Algorithm for Song Playlist Sorter
This algorithm describes the steps to sort a playlist of songs using two criteria: duration and name.
The sorting is performed using the Bubble Sort algorithm.
Step 1: Define Data Structure
i. Song Structure
• Define a structure `Song` to represent each song with the following attributes:
• `name`: a string to hold the name of the song.
• `duration`: an integer to hold the duration of the song in seconds.
Step 2: Initialize Playlist
i. Define Playlist
• Define an array `playlist` of type `Song` with a maximum size of `MAX_SONGS` to store
the songs.
Step 3: Input Songs
i. Input Number of Songs
• Prompt the user to enter the number of songs in the playlist.
ii. Input Song Details
• For each song, prompt the user to enter the name and duration of the song.
• Store the entered details in the corresponding fields of the `Song` structure.
Step 4: Sort Playlist by Duration
i. Bubble Sort by Duration
• Implement the `sortPlaylist` function to sort the `playlist` array based on the duration of
the songs using the Bubble Sort algorithm.
• Compare the duration of adjacent songs and swap them if they are out of order.
• Repeat this process until the entire playlist is sorted by duration.
Dept. of ECE, KLEIT, Hubballi Page 8
Mini Project report on Song Playlist Sorter
Step 5: Print Sorted Playlist by Duration
i. Print Playlist
• Implement the `printPlaylist` function to print the sorted playlist by duration.
Step 6: Sort Playlist by Name
i. Bubble Sort by Name
• Implement the `bubbleSort` function to sort the `playlist` array based on the name of the
songs using the Bubble Sort algorithm.
• Compare the names of adjacent songs and swap them if they are out of order.
• Repeat this process until the entire playlist is sorted by name.
Step 7: Print Sorted Playlist by Name
i. Print Playlist
• Print the sorted playlist by name.
Dept. of ECE, KLEIT, Hubballi Page 9
Mini Project report on Song Playlist Sorter
4. IMPLEMENTATION
#include <stdio.h>
#include <string.h>
#define MAX_SONGS 100
// Structure to represent a song
struct Song {
char name[100];
int duration; // Duration of the song in seconds
};
// Function to swap two songs
void swap(struct Song *a, struct Song *b) {
struct Song temp = *a;
*a = *b;
*b = temp;
}
// Function to perform Bubble Sort on the playlist based on song duration
void sortPlaylist(struct Song playlist[], int numSongs) {
int i, j;
for (i = 0; i < numSongs - 1; i++) {
// Last i elements are already in place
for (j = 0; j < numSongs - i - 1; j++) {
if (playlist[j].duration > playlist[j + 1].duration) {
swap(&playlist[j], &playlist[j + 1]);
}
}
}
Dept. of ECE, KLEIT, Hubballi Page 10
Mini Project report on Song Playlist Sorter
// Function to perform Bubble Sort on the playlist based on song names
void bubbleSort(struct Song playlist[], int n) {
int i, j;
for (i = 0; i < n-1; i++) {
// Last i elements are already in place
for (j = 0; j < n-i-1; j++) {
// Compare adjacent songs by name
if (strcmp(playlist[j].name, playlist[j+1].name) > 0) {
swap(&playlist[j], &playlist[j+1]);
}
}
}
}
// Function to print the sorted playlist
void printPlaylist(struct Song playlist[], int numSongs) {
printf("Sorted Playlist by Song Duration:\n");
printf("--------------------------------\n");
for (int i = 0; i < numSongs; i++) {
printf("%s - %d seconds\n", playlist[i].name, playlist[i].duration);
}
}
int main() {
struct Song playlist[MAX_SONGS];
int numSongs, i;
printf("Enter number of songs in the playlist: ");
scanf("%d", &numSongs);
Dept. of ECE, KLEIT, Hubballi Page 11
Mini Project report on Song Playlist Sorter
// Input the songs
for (int i = 0; i < numSongs; i++) {
printf("Enter name of song %d: ", i + 1);
getchar(); // Consume newline character left by previous scanf
fgets(playlist[i].name, sizeof(playlist[i].name), stdin);
playlist[i].name[strcspn(playlist[i].name, "\n")] = '\0'; // Remove trailing newline
printf("Enter duration of song %d (in seconds): ", i + 1);
scanf("%d", &playlist[i].duration);
}
// Sort the playlist by song duration
sortPlaylist(playlist, numSongs);
// Print the sorted playlist
printPlaylist(playlist, numSongs);
// Sort the playlist using bubble sort
bubbleSort(playlist, numSongs);
// Display the sorted playlist
printf("\nSorted Playlist by name:\n");
for (i = 0; i < numSongs; i++) {
printf("%d. %s\n", i + 1, playlist[i].name);
}
return 0;
}
Dept. of ECE, KLEIT, Hubballi Page 12
Mini Project report on Song Playlist Sorter
Explaination
1. Data Structure: The `Song` structure is defined to hold the name and duration of each song.
2. Swapping Function: The `swap` function swaps two songs in the playlist.
3. Sorting Functions
• `sortPlaylist` sorts the playlist by duration using Bubble Sort.
• `bubbleSort` sorts the playlist by name using Bubble Sort.
4. Input
• The user is prompted to enter the number of songs and their details.
5. Output
• The playlist is sorted by duration and printed.
• The playlist is then sorted by name and printed again.
Dept. of ECE, KLEIT, Hubballi Page 13
Mini Project report on Song Playlist Sorter
5. OUTPUT SNAPSHOTS
Fig. 5.1: Input of song names with duration
Fig. 5.2: Sorted playlist by Duration
Dept. of ECE, KLEIT, Hubballi Page 14
Mini Project report on Song Playlist Sorter
Fig. 5.3: Sorted playlist by Name
Dept. of ECE, KLEIT, Hubballi Page 15
Mini Project report on Song Playlist Sorter
6. ADVANTAGES AND DISADVANTAGES
6.1 Advantages of the Songs Playlist Sorter Program
1. Simplicity: The program uses the Bubble Sort algorithm, which is straightforward and easy to
understand. This makes the code accessible to beginners who are learning sorting algorithms and
C programming.
[Link] Data Representation: Using the `Song` structure allows for organized and clear
handling of song data, encapsulating both the name and duration attributes within a single entity.
[Link] Sorting Criteria: The program provides two sorting options: by duration and by name.
This flexibility allows users to view their playlists in different ways, enhancing usability.
[Link]-Friendly Input/Output: The program interacts with the user through simple prompts and
displays the sorted playlists in a clear, readable format. This makes it easy for users to input data
and understand the results.
[Link]: The code is divided into functions for swapping, sorting by duration, sorting by
name, and printing the playlist. This modularity improves readability and maintainability.
6.2 Disadvantages of the Songs Playlist Sorter Program
[Link] for Large Datasets: Bubble Sort is not the most efficient sorting algorithm,
especially for large datasets. Its time complexity is O(n^2), making it less suitable for sorting large
playlists quickly.
2. Fixed Array Size: The program uses a fixed-size array (`MAX_SONGS`), which can either
limit the number of songs if the array is too small or waste memory if the array is too large and
not fully utilized.
Dept. of ECE, KLEIT, Hubballi Page 16
Mini Project report on Song Playlist Sorter
3. Input Handling: The program uses `fgets` and `scanf` for input, which can lead to issues such
as buffer overflow or incorrect input if not handled carefully. The `getchar` function is used to
consume newline characters, which may not always be foolproof.
4. Lack of Error Handling: The code does not include robust error handling for user inputs. For
instance, it does not check for invalid durations (e.g., negative numbers) or excessively long song
names.
5. Limited Sorting Options: While the program provides sorting by duration and name, it lacks
additional sorting criteria that users might find useful, such as sorting by artist or album.
6. Non-Interactive Sorting Selection: The program sorts the playlist by both criteria sequentially
without giving the user the option to choose which sorting method they prefer first. This could be
more user-friendly if it offered an interactive menu to select the desired sorting method.
Dept. of ECE, KLEIT, Hubballi Page 17
Mini Project report on Song Playlist Sorter
7. APPLICATIONS
1. Personal Music Management
• Organize Playlists: Users can sort their personal music playlists by song duration or name,
making it easier to find specific songs or manage playtime effectively.
• Create Customized Playlists: By sorting songs, users can create playlists that suit specific
moods or activities, such as workout playlists with shorter, upbeat songs.
2. Music Library Management
• Cataloging: For individuals with extensive music libraries, sorting functionality helps
catalogue and systematically organize songs, improving access and retrieval.
• Playlist Curation: Helps in curating playlists for specific events or purposes, such as sorting
songs by duration to create a playlist with a set total time.
3. Music Application Development
• Prototype and Learning: The program serves as a prototype or educational tool for
developers learning about sorting algorithms and user input handling in C.
• Feature Integration: Provides a basis for implementing sorting features in more complex
music management applications or software.
4. Educational Tool
• Learning Sorting Algorithms: Offers a practical example of the Bubble Sort algorithm and
how sorting can be applied to real-world data.
• Programming Practice: Useful for students and beginners to practice and understand array
manipulation, user input handling, and basic sorting techniques in C programming.
Dept. of ECE, KLEIT, Hubballi Page 18
Mini Project report on Song Playlist Sorter
5. Event Planning
• Customized Music for Events: Allows event planners to sort and manage music playlists
for specific events, ensuring that songs are played in the desired order or duration.
6. Music Therapy
• Therapeutic Playlists: Therapists can use the program to sort music by duration to create
therapeutic playlists with specific timing or to arrange songs for different therapy sessions.
7. Music Education
• Learning Tools: Can be used in music education settings to teach students about
organizing and managing music collections, and the principles of sorting algorithms.
8. Music Review and Analysis
• Comparative Analysis: Enables music reviewers or analysts to sort and compare songs
based on their duration or name, aiding in the review and analysis process.
9. Library Management Systems
• Integration into Larger Systems: The sorting functionality can be integrated into larger
library management systems where sorting and organizing resources are essential.
Dept. of ECE, KLEIT, Hubballi Page 19
Mini Project report on Song Playlist Sorter
8. Conclusion
The Songs Playlist Sorter program demonstrates fundamental concepts in data organization and
sorting, offering practical utility for managing music playlists. By leveraging simple yet effective
sorting algorithms, such as Bubble Sort, the program provides a clear example of how to handle
and display data based on user-defined criteria—specifically, song duration and name.
The program's advantages include its simplicity, ease of understanding, and modular design, which
make it a valuable educational tool for learning sorting techniques and C programming. It also
offers practical applications in personal music management, music library organization, and
prototype development for more complex systems. However, the program has limitations, such as
inefficiency with larger datasets due to the Bubble Sort algorithm and fixed-size array constraints.
Additionally, it lacks advanced error handling and sorting options, which could be improved for
broader usability.
Overall, while the Songs Playlist Sorter program serves as a useful example for educational and
practical purposes, there is potential for enhancement. Future improvements could focus on
incorporating more efficient sorting algorithms, dynamic data structures, and additional user-
interactive features to address its current limitations and expand its applicability in various
domains.
Dept. of ECE, KLEIT, Hubballi Page 20
Mini Project report on Song Playlist Sorter
References
To understand and implement the song playlist sorter using data structures in C, the following
resources were consulted:
1. Books:
• "The C Programming Language" by Brian W. Kernighan and Dennis M. Ritchie:
This book provides a thorough foundation in C programming, covering basic concepts and
advanced topics, which were essential for implementing the playlist sorter.
• "Data Structures and Algorithm Analysis in C" by Mark Allen Weiss:
This book covers various data structures and algorithms in C, offering in-depth explanations
and practical examples that helped in understanding and implementing sorting algorithms.
2. Online Tutorials and Documentation:
• GeeksforGeeks:
• [Bubble Sort]([Link] This article explains the
Bubble Sort algorithm with examples and C code implementation.
• [C Structs]([Link] This article provides an
overview of structures in C, which was helpful in defining the `Song` structure.
3. Academic Courses and Lectures:
• MIT OpenCourseWare - Introduction to Algorithms (6.006):
• [Lecture Notes]([Link]
science/6-006-introduction-to-algorithms-fall-2011/lecture-notes/): These lecture notes
cover fundamental algorithms and data structures, including sorting techniques.
• Coursera - Data Structures and Algorithm Specialization by University of California, San
Diego & National Research University Higher School of Economics:
• [CourseMaterials]([Link]
This course provides in-depth coverage of data structures and algorithms, including
sorting algorithms, which were instrumental in the project.
Dept. of ECE, KLEIT, Hubballi Page 21
Mini Project report on Song Playlist Sorter
These resources collectively provided the necessary knowledge and guidance to implement the
song playlist sorter using C. They offer detailed explanations, practical examples, and insights
into best practices for using data structures and sorting algorithms effectively.
Dept. of ECE, KLEIT, Hubballi Page 22