0% found this document useful (0 votes)
3 views42 pages

cs3401 Lab Manual - IGCE

The document is a lab manual for the Algorithms course at Indra Ganesan College of Engineering, detailing various experiments related to searching, sorting, and graph algorithms. It includes exercises on linear search, binary search, sorting methods, graph traversal, and algorithm design techniques, along with additional content beyond the syllabus. Each experiment aims to implement algorithms, measure their time complexity, and visualize results through graphs.

Uploaded by

jaigoku361
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views42 pages

cs3401 Lab Manual - IGCE

The document is a lab manual for the Algorithms course at Indra Ganesan College of Engineering, detailing various experiments related to searching, sorting, and graph algorithms. It includes exercises on linear search, binary search, sorting methods, graph traversal, and algorithm design techniques, along with additional content beyond the syllabus. Each experiment aims to implement algorithms, measure their time complexity, and visualize results through graphs.

Uploaded by

jaigoku361
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

INDRA GANESAN COLLEGE OF ENGINEERING

TRICHY - 12

Department of Computer Science and Engineering

B.E (CSE)

IV SEMESTER

REGULATION R -2021

CS3401 – ALGORITHMS

LAB MANUAL
lOMoARcPSD|39223546

CS3401 ALGORITHMS COMPONENT LABORATORY LTPC3024

Ex. Page
No. Date Name of The Experiments No. Marks Sign.

Searching and Sorting Algorithms


Implement Linear Search. Determine the time required to
search for an element. Repeat the experiment for different
1
values of n, the number of elements in the list to be searched
and plot a graph of the time taken versus n.
Implement recursive Binary Search. Determine the time
required to search an element.Repeat the experiment
2 for different values of n, the number of elements in the
list to be searched and plot a graph of the time taken
versus n
Given a text txt [0...n-1] and a pattern pat [0...m-1], write
a function search (char pat [ ], chartxt [ ]) that prints all
3
occurrences of pat [ ] in txt [ ]. You may assume that n
> m.
Sort a given set of elements using the Insertion sort and
Heap sort methods and determine the time required to sort
4 the elements. Repeat the experiment for different values of
n, the number of elements in the list to be sorted and plot
a graph of the time taken versus n.

Graph Algorithms

5 Develop a program to implement graph traversal using


Breadth First Search
6
Develop a program to implement graph traversal using
Depth First Search
7
From a given vertex in a weighted connected graph,
develop a program to find the shortest paths to other
vertices using Dijkstra’s algorithm
8 Find the minimum cost spanning tree of a given undirected
graph using Prim’s algorithm
Implement Floyd’s algorithm for the All-Pairs- Shortest-
9
Paths problem
Compute the transitive closure of a given directed graph
10
using Warshall's algorithm
Algorithm Design Techniques
Develop a program to find out the maximum and minimum
11
numbers in a given list of n numbers using the divide and
conquer technique
Implement Merge sort and Quick sort methods to sort an
12
array of elements and determine the time required to sort.
Repeat the experiment for different values of n, the number
of elements in the list to be sorted and plot a graph of the
time taken versus n.

Downloaded by hod cse (hodcse@igceng.com)


lOMoARcPSD|39223546

CS3401 ALGORITHMS COMPONENT LABORATORY LTPC3024

Ex. Page Marks Sign.


No. Date Name of The Experiments No.
State Space Search Algorithms
13
Implement N Queens problem using Backtracking

Approximation Algorithms Randomized Algorithms

Implement any scheme to find the optimal solution for the


14
Traveling Salesperson problem and then solve the same
problem instance using any approximation algorithm and
determine the error in the approximation
Implement randomized algorithms for finding the kth smallest
15 number (C/C++/JAVA/ Python)

CONTENT BEYOND SYLLABUS

1 Knuth-Morris-Pratt (KMP) algorithm

2 Naive string-matching Algorithms

3 Rabin Karp algorithm

From a given vertex in a weighted connected graph,


4 develop a program to find theshortest paths to other vertices
using Bellman Ford algorithm
Find the minimum cost spanning tree of a given undirected
5 graph using Kruskal’salgorithm

Downloaded by hod cse (hodcse@igceng.com)


lOMoARcPSD|39223546

EX. NO: 1 Implement Linear Search. Determine the time required to search
for element. Repeat the experiment for different values of n, the
number of elements in the list to besearched and plot a graph of the
time taken versus n.

Aim:
To implement Linear Search, measure its time complexity for searching an element,
vary the input size by changing the number of elements in the list, and plot a graph to visualize
the relationship between time taken and input size

Algorithm:

1. Start with the first element of the list.


2. Compare the element with the value being searched for.
3. If the element matches, return the index.
4. If the element does not match, move to the next element and repeat steps 2-3.
5. If the end of the list is reached and no match is found, return -1.

Note:
This code first implements the linear_search function which takes a list arr and an
element x as input and returns the index of x in arr if it exists, otherwise returns -1. The function
measure_time takes a number n as input and returns the time taken to search for an element
that is not in the list of n elements. The main block of code then creates a list of n_values, each
representing the number of elements in the list, and measures the time taken to search for an
element in each of these lists. Finally, it plots the graph of the time taken versus n.

Downloaded by hod cse (hodcse@igceng.com)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy