Analysis and Design of Algorithms
(01IT0403)
Department of Information Technology
4th Semester
Lab Manual
2024
FACULTYOFTECHNOLOGY
Information Technology
01IT0403–Analysis
Analysis and Design of Algorithms–LabManual
Algorithms
LAB PROGRAM
1 Write a program for Iterative and Recursive Binary Search.
2 Write a program for Merge Sort
3 Write a program for Quick Sort
4 Write a program for Heap Sort
5 Write a program for Optimal Merge Pattern
6 Write a program for Strassen’s Matrix Multiplication
7 Write a program for Minimum Spanning Trees using Kruskal’s algorithm
8 Write a program for Minimum Spanning Trees using Prim’s algorithm
9 Write a program for Single Source Shortest Path
10 Write a program for Floyd
Floyd-Warshall algorithm
11 Write a program for Traveling salesman problem
12 Write a program for Hamiltonian Problem
13 Write a program for N Queen Problem using Backtracking
14 Write a program for coin change problem using dynamic programming
Name[Enrollment no.] 4TD2(B) Page no.
FACULTYOFTECHNOLOGY
Information Technology
01IT0403–Analysis
Analysis and Design of Algorithms–LabManual
Algorithms
Experiment 1
Name[Enrollment no.] 4TD2(B) Page no.
FACULTYOFTECHNOLOGY
Information Technology
01IT0403–Analysis
Analysis and Design of Algorithms–LabManual
Algorithms
1. Write a program for Iterative and Recursive Binary Search.
Algorithm:
Step 1 : Find the middle element of array. using ,
middle = initial_value + end_value / 2 ;
Step 2 : If middle = element, return ‘element found’ and index.
Step 3 : if middle > element, call the function with end_value =
middle - 1 .
Step 4 : if middle < element, call the function with start_value
= middle + 1 .
Step 5 : exit.
Code:
#include <stdio.h
<stdio.h>
int iterativeBinarySearc
iterativeBinarySearch(int array[][], int
start_index x, int end_index, int element){
elemen
while (start_index
start_index <= end_index){
int middle = start_index + (end_inde
end_index-
start_index )/2;
if (arra
array[middle] == element)
retur
return middle;
if (arra
array[middle] < element)
start_index = middle + 1;
else
end_index = middle - 1;
}
return - -1;
}
int main(voi
void){
int arra
array[] = {1, 4, 7, 9, 16, 56, , 70};
int n = 7;
int element = 16;
int found_index =
iterativeBinarySearc
iterativeBinarySearch(array, 0, n-1, element);
if(found_index
found_index == -1 ) {
print
printf("Element
"Element not found in the array ");
}
else {
print
printf("Element
"Element found at index :
%d",found_inde
found_index);
Name[Enrollment no.] 4TD2(B) Page no.
FACULTYOFTECHNOLOGY
Information Technology
01IT0403–Analysis
Analysis and Design of Algorithms–LabManual
Algorithms
}
return 0
0;
}
#include <stdio.h
<stdio.h>
int recursiveBinarySearc
recursiveBinarySearch(int array[]
[], int
start_indexx, int end_index, int element){
elemen
if (end_index
end_index >= start_index){
int middle = start_index + (end_index
end_index -
start_index )/2;
if (arra
array[middle] == element)
retur
return middle;
if (arra
array[middle] > element)
retur
return recursiveBinarySearchh(array,
start_indexx, middle-1, element);
retur
return recursiveBinarySearch(arra
array,
middle+1, end_inde
end_index, element);
}
return --1;
}
int main(voi
void){
int arra
array[] = {1, 4, 7, 9, 16, 56,, 70};
int n = 7;
int element = 9;
int found_index =
recursiveBinarySearc
recursiveBinarySearch(array, 0, n-1, element);
if(found_index
found_index == -1 ) {
print
printf("Element
"Element not found in the array ");
}
else {
print
printf("Element
"Element found at index :
%d",found_inde
found_index);
}
return 00;
}
Name[Enrollment no.] 4TD2(B) Page no.
FACULTYOFTECHNOLOGY
Information Technology
01IT0403–Analysis
Analysis and Design of Algorithms–LabManual
Algorithms
OUTPUT SCREENSHOT WE CAN KEEP HERE
Time Complexity:
Best case:
Worst case:
Average case:
Note:
No plagiarism will be entertained. Such work will be rejected. Student
Studentss are suggested to
perform lab sessions on their own.
Practical are expected to be submitted within given deadline by faculty.
You need to follow this format with all its settings.
- Header [Lab title and Department name]
- Footer [Author name [enr[enroll. no.], Division(Batch), and page number]
- Fonts and Font sizes should be same for entire lab manual
- Use Courier New fonts for code and algorithm and size is 12.
Name[Enrollment no.] 4TD2(B) Page no.