Ask a question to Desklib · AI bot


Data Structure & Algorithms

Added on -2019-09-13

| 10 pages
| 2062 words

Trusted by 2+ million users,
1000+ happy students everyday

Data structure & algorithms
Task 1This assignment requires you to produce fully working program/programs, which will compare operation times of various sorting algorithms for given sets of data.You should carefully consider the criteria below and then develop a fully documented program that will calculate the time taken to sort lists of 10, 100, 1000, and 10,000 integer numbers which will be supplied by the tutor in class. Note: The program has been done if you need I would forward the code as well This code done by visual basic studio 2010Task 1:#include<iostream>#include<conio.h>#include<time.h>#include<windows.h>usingnamespace std;int menuChoice = 0;int main(){/*int a[50],n,i,j,temp;cout<<"Enter the size of array: ";cin>>n;cout<<"Enter the array elements: "; */ DWORD starttime,endtime;//variables to store start and end timesfloat totaltime;//a float variable for the total timecout << "How many numbers?\n";cin >> menuChoice;starttime = GetTickCount();//get the start timesrand(time(NULL));int a[10000];for(int i = 0; i < menuChoice; i++){a[i] = rand() % 10000 + 1;}int temp;for(int i=1;i<menuChoice;++i){for(int j=0;j<(menuChoice-i);++j)if(a[j]>a[j+1]){temp=a[j];a[j]=a[j+1];a[j+1]=temp;}
}cout<<"Array after bubble sort:";for(int i=0;i<menuChoice;++i)cout<<" "<<a[i] <<" "; endtime=GetTickCount();//get finish time//calc timetotaltime=((float)endtime-(float)starttime)/1000.0;//calculate the total time in secscout<<"Totaltime="<<totaltime<<" sec\n";_getch();return 0;}There should be a minimum of 3 sorting algorithms used in the program, including an insertion sort, a bubble sort and another sorting algorithm of your choice.The program is to be written in C/C++ using the Microsoft C++ compiler in console mode.You must write a report that includes the following: -A description of each algorithm used, including pseudo code and/or flowcharts.A full code listing with commentsA table of results showing the time required for each algorithm to execute once. Usethe speed of the insertion sort as a guide to compensate for different processorspeeds.An explanation of how the timing of each algorithm is achieved.Justification of the best sorting algorithm to be used for the various data setssupplied.Any additional paperwork you consider necessary including additional research anddiscussions on sorting algorithms.Additional marks will be awarded for complexity and explanations of algorithms usedincluding discussions on how the test results were obtained.

Found this document preview useful?

You are reading a preview
Upload your documents to download
Become a Desklib member to get accesss

Students who viewed this