# Data Struc and Algor Analysis Assignment

Anonymous

Question description

this is the assignment

Algorithms to write and analyse their complexities in term of big-O:

1- Sequential Search:  (array elements need not to be sorted)

generate n numbers at random in an array of size n; and search for a given number in the array; if found return its location in the array, else return -1,

2- Binary Search: (array elements must be sorted)

generate n numbers at random in an array of size n; use any sort algorithm you know to order the numbers in the array, i.e. quick_sort, bubble_sort,... ;

and search for a given number in the array; if found return its location in the array, else return -1,

for the search function: use both methods:  iteration, and recursion

Use  0<n<1000, and generated numbers must be less than 5 digits.

Class Time is used for grading your finished programs along with and their calculated complexities.

Be prepared and equiped with your laptops and finished programs.

HELP TO START:

#include <ctime>

#include <iostream>

using namespace std;

int a[10000], n=100;

//Here is a bubble sort code:

void sort() {for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(a[i]>a[j]) {int t; t=a[i]; a[i]=a[j]; a[j]=t;}}

//Here is a print code:

void print() { for(int i=0;i<n;i++) cout<<a[i]<<endl;}

//Here is a data generation code:

void generate() { srand(time(0)); for(int i=0;i<n;i++) a[i] =  rand()%1000;}

<<<<<<

(Top Tutor) Studypool Tutor
School: Rice University
Studypool has helped 1,244,100 students
flag Report DMCA

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors