0% found this document useful (0 votes)
1K views

Algorithm Lab Report

This document appears to be a lab report from 2010 analyzing various algorithms including probability, sorting, traveling salesman problem, and quicksort. It includes descriptions of experiments conducted in GNU Octave to analyze sorting algorithms, generate random numbers to calculate probabilities, validate TSP tours, and compare performance of standard quicksort versus a hybrid quicksort/insertion sort. The report records output like graphs, means, standard deviations, and comments on results.

Uploaded by

the.nube
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Algorithm Lab Report

This document appears to be a lab report from 2010 analyzing various algorithms including probability, sorting, traveling salesman problem, and quicksort. It includes descriptions of experiments conducted in GNU Octave to analyze sorting algorithms, generate random numbers to calculate probabilities, validate TSP tours, and compare performance of standard quicksort versus a hybrid quicksort/insertion sort. The report records output like graphs, means, standard deviations, and comments on results.

Uploaded by

the.nube
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Algorithm Anaysis &

Design

Lab Report
(2010)

Rohit Man Amatya


107CS056
Probability

Prove that the probablity of the coin is 0.5

Input:
• Automatically generate random no.

Output:
• Graph

Programming:
GNU Octave, version 3.0.5
Octave was configured for "x86_64-pc-linux-gnu".
Sorting Analysis

Compariting the no of comparition made by the different Sorting Algorithm in Different Data
inputs

Sorting Method:
• Selection Sort
• Insertion Sort
• Bubble Sort
• Quick Sort
• Merge Sort

Data Input:
• Random
• Reverse ordered
• Almost Sorted (Rearraging 10% of the element from sorted list)
• Nearly sorted

Programming:
GNU Octave, version 3.0.5
Octave was configured for "x86_64-pc-linux-gnu".

Description:
• All sorting algorithm have been written in Octave.
• Program Automatically generates the input for analysis and plots the graph.
• For changing the range change the value of line 114, 115, 116
TSP Tour Verification

Verifing the TSP tour

Input:
• No of Cities
• Adjacency Matrix
• Tour

Output:
Validate Tour

Programming:
C++
Quicksort algorithm

Use the Quicksort algorithm to develop a program to conduct the following experiment:
Repeatedly fill an array of size 4096 with randomly generated integers and record the count of the
number of compares needed to sort the list each time. Run this test inside of a loop 50 times, and
when finished, record the average number of compares, the best value, the worst value, and the
standard deviation. You will have to increment a counter every time you make a comparison inside
the partition function. The standard deviation
is given by the following formula:
σ= Standard deviation
μ= mean

Input:
• Automatically generate random no.

Output:
• Mean
• Standard Deviation

Programming:
GNU Octave, version 3.0.5
Octave was configured for "x86_64-pc-linux-gnu".
Quicksort algorithm

Modify your sorting algorithm in the previous problem to stop partitioning the list in Quicksort
when the size of the (sub)list is less than or equal to 12 and sort the remaining sublist using
insertionSort. Your counter will now have to count compares in both the partition function and in
each iteration of insertionSort. Again, run the experiment for 50 iterations and record the same set
of statistics. Compare your results for the two different sorting techniques and comment upon your
results.

Input:
• Automatically generate random no.

Output:
• Mean
• Standard Deviation

Programming:
GNU Octave, version 3.0.5
Octave was configured for "x86_64-pc-linux-gnu".

Comment:
Improvement in the time.

You might also like