SRM Institute of Science and Technology
Faculty of Engineering and Technology
School of Computing
Subject Name: Data Structures & Algorithms
Subject Code:21CSC201J
ssignment Issue Date:29-8-2025
Assignment submission:30-8-2025
Assignment
1. Create a structure for student data base with following members (Register number,
Name, Age, CGPA). Write a C program to perform the following operations (i) Get
user input for 5 students record (ii) Find the student’s name with greatest CGPA.
(Note: Find appropriate data structure and develop a C program).
2. Mr. Ram is developing a software application to manage his inventory, which initially can hold a
maximum of ten product packets. He allocates memory for ten packets at the start. However, as the
market demand changes, he needs to dynamically update the allocated memory to store more or fewer
packets without wasting memory or running out of space. Explain the concept of dynamic memory
allocation and how Mr. Ram can effectively manage his inventory size using this concept.
3. Mr. John is playing the game Subway Surfers. The game has a total of five treasures with different
weights, that he needs to collect. Write a C program to count the total number of weights he collected
from the treasures during the game.
4. Given a number ‘n’, write an algorithm and the subsequent ‘C’ program to count the
number of two-digit prime numbers in it when adjacent digits are taken. For example,
if the value of ‘n’ is 114 then the two-digit numbers that can be formed by taking
adjacent digits are 11 and 14. 11 is prime but 14 is not. Therefore print 1.
5. Output of this program#include <stdio.h>
#include<stdlib.h>
void main() {
int *p,x=-1;
p = (int *)malloc(sizeof(int));
*p = 10;
printf("%d", *p+x);
free(p);
}
6. Swapping of two numbers using pointers
7. Perform addition of two number without using arithmetic operator.
8. In a library, a librarian maintains a list of books that are currently available for
borrowing. When a book is borrowed, its entry needs to be removed from the list to
keep the records accurate. Help the librarian by guiding them on how to use a proper
data structure to manage the list of books and delete a book's entry when it is
borrowed. Write a C program that uses an array to store the book titles and
demonstrates how to delete a specific book from the array when it is borrowed.
9. Consider the following code to find time complexity and space complexity
int i, j, k,x=0;
for(i =0; i<=n; i++)
for(j =1; j<=2n; j++)
for(k =1; k< (j/2); k++)
x = x+1;
printf(“%d”,x);
10. What is the output of the following code?
int x = 10;
int *p = &x;
int *q = p;
printf("%d\n", p);
printf("%d\n",q);
printf("%d\n",*q);
printf("%d\n",*p);
printf(“%d\n”, *(p) +2);
printf("%d\n",p+2);
11. Consider the following array and code
Int a[3] [3] = {1,2,3,4,5,6,7,8,9};
int *p
p=&a[0][0] (or)
p=a
(Note: Assume the base address is 1000 and ‘int’ holds 4bytes of instruction)
Write the formula to calculate the address and identify the value for the following
printf(%d”,a[2][3]);
printf(“%p”,a[2][3]);
(ii) printf(%d”,a[1][2]); printf(“%p”,a[1][2]);
12. What is the output of the following code?
int x = 10;
int *p = &x;
int *q = &p;
printf("%d\n", *p);
13. What will the output of the below code, be if the base address of the array is 1600?
int main()
{
int arr[] = { 1, 2, 3, 4, 5 };
printf("%d,%d,%d",arr,&arr,&arr[0]);
return 0;
}
14. Implement a basic linked list management system using arrays in C. The system
should allow users to perform various operations on the list of integers, such as
adding elements, deleting elements, searching key element and displaying the
elements of the list.
15. Perform matrix multiplication using pointers.
16. What is the size (in bytes) of the structure person given below?
struct person {
int id;
char name[20];
int mobilenum;
struct address {
int doorno;
char street[20];
char city[20];
int pincode;
} p[10];};
17. f(n) = 2 n2 +2 n−5
f(n) = 2 n3 +n2 +2 n+25
Consider the above polynomial write Big O notation and theta notation for the same
18. Create a C program to manage a store's product inventory using structures and arrays.
The program should:
(i). Define a Product structure with fields for ID, name, price, and quantity.
(ii). Allow the user to input and store details for multiple products in an array
(minimum of 10) of Product structures.
(iii) Display the product details after receiving all the product information
from the user.
(iv) Display the product details if the product name is equal to 'Laptop' and the
price is greater than 50,000. If no matches found, print appropriate error
message.
19. What does the 'malloc' function in C do?
20. List the operation which is applicable to an abstract data type (ADT)?