d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Algorithm Worst Case/average Case?
Add Reply New Topic New Poll
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Feb 11 2014 09:46pm
Nvm got it thanks

This post was edited by lopelurag on Feb 11 2014 10:10pm
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Feb 11 2014 10:08pm
For this algorithm,

Worst case would be the array is reverse sorted, meaning you would have to do N*N comparisons.

Average case would be the array is partially sorted, but the algorithm isn't checking mid sort if the sort is complete. Thus, you still will do the full N*N comparisons.

Both running times would have O(N^2) running time
Member
Posts: 24,101
Joined: Nov 8 2007
Gold: 5,561.70
Feb 11 2014 10:11pm
Quote (Minkomonster @ Feb 12 2014 12:08am)
For this algorithm,

Worst case would be the array is reverse sorted, meaning you would have to do N*N comparisons.

Average case would be the array is partially sorted, but the algorithm isn't checking mid sort if the sort is complete. Thus, you still will do the full N*N comparisons.

Both running times would have O(N^2) running time


Yea I figured it out, needed the exact number of comparisons though, knew the Big-O was n^2

Got the summations figured out tho thanks
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll