- 1

Help me

How do I find worst case and best, average case #include<iostream> using namespace std; int main() { int a[5] = {34, 28, 1, 2, 65}; int i,j,b; for(i = 0; i < 5; i++){ cout<<a[i]<<"\t"; } cout<<"\n"; for( i = 1; i < 5; i++){ for(j = 0; j < (5-i); j++){ if( a[j] > a[j+1] ){ b = a[j]; a[j] = a[j+1]; a[j+1] = b; } } } for(j = 0; j < 5; j++){ cout<<a[j]<<"\t"; } return 0; }

16th Feb 2021, 2:30 PM
Bayan
2 Answers
+ 6
Bayan , you need to explain what your code is going to do. also saying "help me" is not sufficient. please explain clearly what your problem is. thanks!
16th Feb 2021, 2:41 PM
Lothar
Lothar - avatar
+ 2
lets start: what language are you using here? looks like C, or maybe a C derivative. is that correct?
16th Feb 2021, 2:54 PM
Wilbur Jaywright
Wilbur Jaywright - avatar