# Data Structure & Algorithms

Added on - Sep 2019

• 10

Pages

• 2062

Words

• 379

Views

• Save

Share

Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 3 of 10 pages
Data structure & algorithms
Task 1This assignment requires you to produce fully working program/programs, which willcompare operation times of various sorting algorithms for given sets of data.You should carefully consider the criteria below and then develop a fully documentedprogram that will calculate the time taken to sort lists of 10, 100, 1000, and 10,000 integernumbers which will be supplied by the tutor in class.Note: The program has been done if you need I would forward the code as wellThis code done by visual basic studio 2010Task 1:#include<iostream>#include<conio.h>#include<time.h>#include<windows.h>usingnamespacestd;intmenuChoice = 0;intmain(){/*int a,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 timesfloattotaltime;//a float variable for the total timecout <<"How many numbers?\n";cin >> menuChoice;starttime = GetTickCount();//get the start timesrand(time(NULL));inta;for(inti = 0; i < menuChoice; i++){a[i] = rand() % 10000 + 1;}inttemp;for(inti=1;i<menuChoice;++i){for(intj=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(inti=0;i<menuChoice;++i)cout<<" "<<a[i] <<" ";endtime=GetTickCount();//get finish time//calc timetotaltime=((float)endtime-(float)starttime)/1000.0;//calculate the totaltime in secscout<<"Totaltime="<<totaltime<<" sec\n";_getch();return0;}There should be a minimum of 3 sorting algorithms used in the program, including aninsertion 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. 