0% found this document useful (0 votes)
4 views

DSA Assignment (1)

Uploaded by

ranjanaditya1205
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

DSA Assignment (1)

Uploaded by

ranjanaditya1205
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ACHARYA INSTITUTE OF TECHNOLOGY

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


(Affiliated to Visvesvaraya Technological University, Belagavi, Approved by AICTE, New Delhi and Accredited by NBA & NAAC)
Acharya Dr. Sarvepalli Radhakrishnan Road, Achitnagar Post, Soladevanahalli,
BENGALURU - 560107

Assignment No. 1
Subject Name: Data Structure and Applications Semester: 3rd Section: A / B
Subject Code: BCS304 Deadline for Submission: Thursday 21st Nov 2024
Faculty Name: Vishal Sathawane (Till 4:30 PM)

Assignment Submission Instructions:


1. Submission Requirements:
o Each student must submit both a handwritten and a digital copy of their code.
o The handwritten code should be written in the yellow assignment book, accompanied by a printed
output that includes the student’s name and roll number.
o For the digital submission, upload the .c file to Google Classroom or Alive platform(where you find
this assignment) in the assignment section (using the "Upload Work" option where the assignment
is posted).
2. Question Set Assignments:
o SET A: Students whose roll numbers end in 1, 2, or 3 should complete questions from Set A.
o SET B: Students whose roll numbers end in 4, 5, or 6 should complete questions from Set B.
o SET C: Students whose roll numbers end in 7, 8, 9, or 0 should complete questions from Set C.
3. Deadline and Late Submissions:
o The deadline is strict, and all assignments must be submitted on time. If a student is unable to
submit in person, they must arrange for a friend to submit it on their behalf. No exceptions will be
made for late submissions.

SET A Questions
Q1 Library Management System Using Linked List and Dynamic Memory Allocation
Objective:
Design a library management system that can manage a collection of books using a linked list. Each book
will have attributes such as title, author, and ISBN. This project will help you understand linked lists and
dynamic memory allocation in C programming.
Problem Statement:
Create a C program that allows the user to:
1. Add a new book to the library.
2. Delete a book from the library by ISBN.
3. Search for a book by title or author.
4. Display all books in the library.
Each of these operations will require dynamic memory allocation to create new nodes in a linked list, where
each node represents a book.
Data Structure Design:
Each book can be represented as a node in a singly linked list where each node has:
• title (string): The title of the book.
• author (string): The author's name.
• ISBN (integer): A unique identifier for the book.
• next (pointer): A pointer to the next book node in the list.

Create a menu in the main function to allow the user to:


• Add a book
• Delete a book
• Search for a book by title
• Display all books
Implement error-checking for each function, such as handling memory allocation failure, validating ISBNs,
and checking if the library is empty.
Dynamic Memory Management: Ensure to free all dynamically allocated memory when the program ends.
Q2. Stack-Based Decimal to Binary Conversion
Write a C program to convert a decimal number to binary using a stack. Provide a menu with the following
options:
1. Operations:
o Push Remainder: For each division step, push the remainder onto the stack.
o Pop and Display Binary: Pop each element from the stack to display the binary number.
o Convert Number: Convert a decimal number to binary using the stack and display the
result.
o Exit: End the program.
2. Function Design:
o Write functions for pushing remainders, popping and displaying the binary result, and
converting the decimal number to binary.

SET B Questions
Q1 Event Management System Using Queue and Dynamic Memory Allocation
The Event Management System is designed to manage participants in an event. It uses a Queue data
structure to handle participant registration in a FIFO (First-In, First-Out) order, with dynamic memory
allocation for flexible memory usage. This is ideal for situations like event registration or ticketing where
participants are processed in the order they registered.
Project Requirements
The system will:
1. Register participants by adding them to a queue.
2. Process participants by dequeuing them as they complete their event registration.
3. View the next participant in line.
4. Display all participants in the order they registered.
Each participant will have details such as:
• Name
• Age
• Registration Number
Data Structure Design
Each participant will be represented as a node in a linked list-based queue, where each node has:
• name (string): The participant's name.
• age (integer): The participant's age.
• registrationNumber (integer): Unique ID for each participant.
• next (pointer): A pointer to the next participant node in the queue.
Putting It All Together
1. Initialize Front and Rear Pointers: At the beginning, both front and rear are NULL, indicating an
empty queue.
2. Menu-Driven Interface in main:
o Implement a main function with a menu to allow users to:
▪ Enqueue a participant
▪ Dequeue (process) a participant
▪ Peek at the next participant
▪ Display all participants
3. Dynamic Memory Management: Free all dynamically allocated memory for each participant before
program termination.
Q2 Word Deletion from a Sentence
Write a C program that deletes all occurrences of a specified word from a sentence.
1. Input Requirements:
o Prompt the user to enter a sentence (SENT) and a word (WORD) to delete.
2. Operations:
o Delete Word: Write a function to search for WORD in SENT and remove each occurrence,
shifting the remaining characters in SENT to fill the gap.
o Edge Cases: If WORD does not exist in SENT, display a suitable message.
3. Function Design:
o Use separate functions to:
▪ Read the sentence and word from the user.
▪ Search for and delete all occurrences of WORD in SENT.
▪ Display the modified sentence or a message if no deletions were made.

SET C Questions
Q1 Student Record System with Circular Queue and Linked List
• Objective: Design a student record management system that can efficiently handle enrollments.
• Description: Use a Circular Queue for handling a registration queue, allowing efficient
management of students waiting for enrollment. For storing student information, use a Linked List.
• Key Requirements:
o Add students to the enrollment queue.
o Register students and add them to a linked list of enrolled students.
o Remove students from the registration queue after enrollment.
o Display enrolled students in the order they registered.
• Concepts Covered: Circular Queue, Linked List, Dynamic Memory Allocation, Queue operations,
Linked List operations.

Q2 Fibonacci Sequence Using Recursion in C


Write a C program to generate the Fibonacci sequence up to a given number of terms using recursion.
1. Problem Requirements:
o Define the Fibonacci Sequence: The Fibonacci sequence is defined as follows:
▪ F(0)=0F(0) = 0F(0)=0
▪ F(1)=1F(1) = 1F(1)=1
▪ F(n)=F(n−1)+F(n−2)F(n) = F(n-1) + F(n-2)F(n)=F(n−1)+F(n−2) for n≥2n \geq 2n≥2
o This means each term in the sequence is the sum of the two preceding ones, starting from 0
and 1.
2. Program Specifications:
o Prompt the user to enter the number of terms (n) for which the Fibonacci sequence should
be printed.
o Use a recursive function fibonacci() to calculate each term in the sequence.
o Print each term up to the nthn^{th}nth term as calculated by the recursive function.

You might also like