|
|
Subject:
Data structure and algorithm
Category: Computers > Algorithms Asked by: math01-ga List Price: $3.00 |
Posted:
16 Jul 2003 08:09 PDT
Expires: 20 Jul 2003 23:53 PDT Question ID: 231628 |
Analyze the complexity (in big-O terms) of the following selection-sort routine. The routine picks out the largest element in the current list and exchanges it with the last element. It continues until the list has only one element: for (i = n-1; i > 0; i--) { MaxPosition = i; for (j = 0; j < i; j++) { if (a[j] > a[MaxPosition]) MaxPosition = j; } exchange(i, MaxPosition); } |
|
There is no answer at this time. |
|
Subject:
Re: Data structure and algorithm
From: stephenvakil-ga on 17 Jul 2003 09:44 PDT |
Shouldn't this be the same order as a bubble sort, as it is basically a reversed bubble sort? Bubble sort has a worst case and average case O(n)^2 There are several analyses of bubble sort that you can find by searching google for "Bubble Sort Complexity" |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |