DATA STRUCTURES LAB NOTES JNTUK R23 SYLLABUS, Lecture notes of Data Structures and Algorithms

DATA STRUCTURES USING C LAB NOTES JNTUK R23 SYLLABUS

Typology: Lecture notes

2025/2026

Available from 12/05/2025

csedept-1
csedept-1 🇮🇳

1 document

1 / 153

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lenora College Of Engineering
Rampachodavaram
B.Tech – R23
Data Structures Using C Lab
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download DATA STRUCTURES LAB NOTES JNTUK R23 SYLLABUS and more Lecture notes Data Structures and Algorithms in PDF only on Docsity!

Lenora College Of Engineering

Rampachodavaram

B.Tech – R

Data Structures Using C Lab

ENGINEERING CURRICULUM - 2023 JNTUK B.Tech. R23 Regulations 87

L T P C

DATA STRUCTURES LAB

(Common to CSE, IT & allied branches)

Course Objectives:

The course aims to strengthen the ability of the students to identify and apply the suitable data

structure for the given real-world problem. It enables them to gain knowledge in practical

applications of data structures.

Course Outcomes: At the end of the course, Student will be able to

CO1: Explain the role of linear data structures in organizing and accessing data efficiently in

algorithms.

CO2: Design, implement, and apply linked lists for dynamic data storage, demonstrating

understanding of memory allocation.

CO3: Develop programs using stacks to handle recursive algorithms, manage program states,

and solve related problems.

CO4: Apply queue-based algorithms for efficient task scheduling and breadth-first traversal in

graphs and distinguish between deques and priority queues and apply them appropriately to

solve data management challenges.

CO5: Recognize scenarios where hashing is advantageous, and design hash-based solutions for

specific problems.

List of Experiments:

Exercise 1: Array Manipulation

i) Write a program to reverse an array.

ii) C Programs to implement the Searching Techniques – Linear & Binary Search

iii) C Programs to implement Sorting Techniques – Bubble, Selection and Insertion Sort

Exercise 2: Linked List Implementation

i) Implement a singly linked list and perform insertion and deletion operations.

ii) Develop a program to reverse a linked list iteratively and recursively.

iii) Solve problems involving linked list traversal and manipulation.

Exercise 3: Linked List Applications

i) Create a program to detect and remove duplicates from a linked list.

ii) Implement a linked list to represent polynomials and perform addition.

iii) Implement a double-ended queue (deque) with essential operations.

Exercise 4: Double Linked List Implementation

i) Implement a doubly linked list and perform various operations to understand its

properties and applications.

ii) Implement a circular linked list and perform insertion, deletion, and traversal.

Exercise 1: Array Manipulation i) Write a program to reverse an array. #include <stdio.h> int main() { int arr[100], n, i, temp; // Get the size of the array printf("Enter the number of elements in the array: "); scanf("%d", &n); // Get array elements from the user printf("Enter %d elements:\n", n); for(i = 0; i < n; i++) { scanf("%d", &arr[i]); } // Reverse the array in-place for(i = 0; i < n / 2; i++) { temp = arr[i]; arr[i] = arr[n - i - 1]; arr[n - i - 1] = temp; } // Print the reversed array printf("Reversed array:\n"); for(i = 0; i < n; i++) { printf("%d ", arr[i]); } printf("\n"); return 0; }

Output:

printf("Element found at position %d (index %d)\n", i + 1, i); break; } } if(!found) { printf("Element not found in the array.\n"); } return 0; }

Output(s):

printf("Element found at position %d (index %d)\n", mid + 1, mid); return 0; } else if(arr[mid] < key) { low = mid + 1; } else { high = mid - 1; } } printf("Element not found in the array.\n"); return 0; }

Output(s):

printArray(arr, n); bubbleSort(arr, n); printf("Sorted array: "); printArray(arr, n); return 0; } Output:

Selection sort in C #include <stdio.h> void selectionSort(int arr[], int n) { int i, j, min_idx, temp; 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; } } // Swap the found minimum element with the first element temp = arr[min_idx]; arr[min_idx] = arr[i]; arr[i] = temp; } } void printArray(int arr[], int n) { for (int i = 0; i < n; i++) { printf("%d ", arr[i]); } printf("\n"); } int main() { int arr[] = {64, 34, 25, 12, 22, 11, 90}; int n = sizeof(arr) / sizeof(arr[0]); printf("Original array: ");

Insertion Sort in C #include <stdio.h> void insertionSort(int arr[], int n) { int i, key, j; for (i = 1; i < n; i++) { key = arr[i]; j = i - 1; // Move elements of arr[0..i-1] that are greater than key // to one position ahead of their current position while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j--; } arr[j + 1] = key; } } void printArray(int arr[], int n) { for (int i = 0; i < n; i++) { printf("%d ", arr[i]); } printf("\n"); } int main() { int arr[] = {64, 34, 25, 12, 22, 11, 90}; int n = sizeof(arr) / sizeof(arr[0]); printf("Original array: "); printArray(arr, n);

insertionSort(arr, n); printf("Sorted array: "); printArray(arr, n); return 0; } Output:

// Insertion at the end void insertAtEnd(struct Node** head, int data) { struct Node* newNode = createNode(data); if (head == NULL) { head = newNode; printf("Inserted %d at the end\n", data); return; } struct Node temp = head; while (temp->next != NULL) { temp = temp->next; } temp->next = newNode; printf("Inserted %d at the end\n", data); } // Insertion after a given node (by value) void insertAfter(struct Node head, int afterData, int data) { struct Node temp = head; while (temp != NULL && temp->data != afterData) { temp = temp->next; } if (temp == NULL) { printf("Node with data %d not found\n", afterData); return; } struct Node* newNode = createNode(data); newNode->next = temp->next; temp->next = newNode; printf("Inserted %d after %d\n", data, afterData); }

// Deletion of the first node void deleteFirst(struct Node** head) { if (head == NULL) { printf("List is empty\n"); return; } struct Node temp = head; head = (head)->next; printf("Deleted %d from the beginning\n", temp->data); free(temp); } // Deletion of the last node void deleteLast(struct Node* head) { if (head == NULL) { printf("List is empty\n"); return; } if ((head)->next == NULL) { printf("Deleted %d from the end\n", (head)->data); free(head); head = NULL; return; } struct Node temp = *head; while (temp->next->next != NULL) { temp = temp->next; } printf("Deleted %d from the end\n", temp->next->data); free(temp->next);