Algorithm Lab Report
Transcript of Algorithm Lab Report
Algorithm Anaysis & Design
Lab Report(2010)
Rohit Man Amatya107CS056
Probability
Prove that the probablity of the coin is 0.5
Input:• Automatically generate random no.
Output:• Graph
Programming:GNU Octave, version 3.0.5Octave 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.5Octave 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.5Octave 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.5Octave was configured for "x86_64-pc-linux-gnu".
Comment:Improvement in the time.