You are on page 1of 15

Data Structure

and Algorithm
Lab
Code – CSS 52
II SEMESTER ALL SECTIONS

CLASS 2023 - 2024


Marks Distribution

Attendanc
e Viva

Lab
Performanc Exam
e Copy

Lab Copy / Execution


Assignments (Exam)

CLASS 2023 - 2024


• Machine ID: student/ugstudent

• Machine Password: student/ugstudent

• Program writing command: gedit filename.c

• Program compilation command: gcc filename.c

• Program run command: ./a.out

CLASS 2023
Assignment - 1
1. Write a program in C to insert an element at a given location in a non-empty array.

2. Write a C program to remove the duplicate elements from an array.

3. Write a program in C to merge two arrays for the following two cases-
a.) Arrays are sorted.
b.) Arrays are unsorted.

4. Write a C program to count the number of occurrences of a specific element for a given
integer array of fixed length.
a.) without dynamic memory allocation
b.) with dynamic memory allocation

5. Write a C program to read a one dimensional array, print sum of all elements along with
inputted array elements using Dynamic Memory Allocation.

6. Write a program to find out the largest number using Dynamic Memory Allocation.

CLASS 2023 - 2024


Assignment - 2
1. Write a program in C to convert 10 decimal numbers to binary numbers. Take user inputs.

2. Given an integer array, reshuf fle the array where all odd elements will come before the even elements in
sorted order. Example is given below -

Input Array Output Array


3 10 2 9 14 7 3 7 9 2 10 14

3. Write a program to reverse the sequence of an array elements after a given location to the end of the
array. Example is given below –

Input Array = [10 20 30 40 50 60 70 80] Rotated left by 2 positions:


Positions to rotate = 2 Output Array = [10 20 80 70 60 50 40 30]

4. Write a C program to read and print the N student details using structure and Dynamic Memory Allocation.

5. Create a structure named "Point" with members for x-coordinate (integer) and y-coordinate (integer).
Write a program to store information for ten points using an array of "Point" structures and f ind the point
closest to the origin (0, 0).

CLASS 2023 - 2024


Assignment - 3
1. Write a program in C to implement Bubble sort. Show each iteration Row Column Value

2. Write a program in C to asymmetric sparse matrix. 3 4 3

Original Matrix
1 0 0 0
using Dynamic Memory Allocation.
0 0 1
0 0 2 0 1 2 2
3. Write a C program to find the Transpose of a matrix. 2 1 3
0 anti-diagonal
4. Write a program in C to calculate the sum of elements on the 3 0 0 of a square matrix.
Input Matrix
Diagonal
1 2 3 1,5,9

Anti-Diagonal
4 5 6 3,5,7

5. Write a program in C to print the boundary elements of a given matrix in a clockwise or counterclockwise direction.
7 8 9
6. Write a program in C to find the saddle point in a matrix.
1 2 3
 A saddle point of a matrix is an element which is both the largest
element in its column and the smallest element in its row. Here 7 is a saddle point. 4 5 6

7 8 9
CLASS 2023 - 2024
Assignment - 4
1. Write C-programs for Binary Search for both recursive and non-recursive versions. Show each iterations.

2. Write a C program to implement Tridiagonal sparse matrix.


a.) using row-major operations
b.) using column-major operations

3. Write a C program to implement Upper Triangular matrix.


a.) using row-major operations
b.) using column-major operations

4. Write a C program to implement Lower Triangular matrix.


a.) using row-major operations
b.) using column-major operations

CLASS 2023 - 2024


Assignment - 5
1. Write a program in C to create a singly linked list and display.

2. Write a menu driven program in C to perform following operations on a singly linked list:
a) insert an element at the beginning of the linked list
b) insert an element at the end of the linked list
c) insert an element in a given location of the linked list.
d) insert an element after a specific element.
e) display the elements from the beginning to end.
f) display the elements from the end to beginning.

CLASS 2023 - 2024


Assignment - 6

1. Write a menu driven program in C to perform following operations on a singly linked list:
a) create a linked list
b) display the linked list
c) delete an element at the beginning of the linked list.
d) delete an element at the end of the linked list.
e) delete an element at the i-th position of the linked list.
f) delete an element after a specific element.

2. Write a C Program to read and display a polynomial using linked list.

3. Write a C program for adding two polynomials using Linked List.

CLASS 2023 - 2024


Assignment - 7
1. Write a C Program to read and display a polynomial using linked list.

2. Write a C program for adding two polynomials using Linked List.

3. Write a menu driven program in C to perform following data structure operations on stack using array.
a) CREATE
b) PUSH
c) POP
d) PEEK [Extract the information from top of the stack]
e) UPDATE [Update ith information from the top of the stack]
f) DISPLAY [Display all the elements stored in a stack]

4. Write a menu driven program in C to perform following data structure operations on stack using linked list.
a) CREATE
b) PUSH
c) POP
d) PEEK [Extract the information from top of the stack]
e) UPDATE [Update ith information from the top of the stack]
f) DISPLAY [Display all the elements stored in a stack]

CLASS 2023 - 2024


Assignment – 8
1. Write a C program for evaluating a postfix expression.

2. Write a C program for transforming an infix expression to a postfix expression.

3. Write a C program to check if a given expression containing parentheses (e.g., "{([])}") is balanced
using STACK.

CLASS 2023 - 2024


Assignment – 9
1. Write a menu driven program in C to perform following data structure operations on linear queue using array.
a) ENQUEUE
b) DEQUEUE
c) queueFRONT [Extract the information from FRONT of the queue]
d) queueREAR [Extract the information from REAR of the queue]
e) queueCOUNT [Return the number of elements in the queue]
f) DISPLAY [Display all the elements stored in a queue]

2. Write a menu driven program in C to perform following data structure operations on circular queue using array.
a) ENQUEUE
b) DEQUEUE
c) queueFRONT [Extract the information from FRONT of the queue]
d) queueREAR [Extract the information from REAR of the queue]
e) queueCOUNT [Return the number of elements in the queue]
f) DISPLAY [Display all the elements stored in a queue]

3. Write a menu driven program in C to perform following data structure operations on linear queue using linked-list.
a) CREATE LINKEDLIST
b) ENQUEUE
c) DEQUEUE
d) queueFRONT [Extract the information from FRONT of the queue]
e) queueREAR [Extract the information from REAR of the queue]
f) queueCOUNT [Return the number of elements in the queue]
g) DISPLAY [Display all the elements stored in a queue]

CLASS 2023 – 2024


Assignment – 10
1. Write a program to group a list of numbers while maintaining their original order in each group. Grouping
of numbers should be done like this-
Group 1: Less than 10
Group 2: between 10 and 19
Group 3: between 20 and 29
Group 4: 30 and greater
[This program is an application of multiple queue.]

2. Write a menu-driven program in C to implement the following sorting operations –


i). Bubble sort
ii). Selection sort

3. Write a C program to merge two sorted Linked Lists into a single sorted Linked List.

4. Write a program in C to test if a string is palindrome using STACK.

CLASS 2023 - 2024


Assignment – 11

1. Write a program in C to sort an array using INSERTION sort algorithm.

2. Write a program in C to sort an array using MERGE sort algorithm.

3. Write a program in C to sort an array using QUICK sort algorithm.

4. Write a program in C to sort an array using RADIX sort algorithm.

CLASS 2023 2024


Assignment – 12

1. Write a menu-driven program in C to implement a binary tree using a linked list and traverse the
following techniques:
i) Inorder
ii) Preorder
iii) Postorder

2. Implement a binary search tree.

CLASS 2023 - 2024

You might also like