views:

66

answers:

0

(1) consider the SelectionSorter method sort. Which of the following statements is true at the beginning of each iteration of the loop? explain

a. for all j, such that 0 <= j < i, 0 <= a[j] <= a[i].

b. for all j, such that 0 <= j < i, a[j] is in its final position in the sorted array.

c. for all j, such that 0 <= j < i, a[0]... a[j] is sorted.

(2) what is the growth rate of the following method?

public static int count(int [] a, int c){
        int count = 0;
                  for(int i=0, i<a.length; i++){
                       if (a[i]==c)
                          count++;
                       }
                       return count;
                  }

(3) what is the maximum number of elements that will be visited by the binary seach algorithm when searching a sorted 45-element array? could you explain too?

(4) suppose algorithm A takes 5 seconds to handle a data set of 1000 records. If the algorithm A is an o(n) algorithm, how long will it take to handle a data set of 2000 records? of 10000 records?

(5) approximately how many seconds would it take to sort a data set of 80000 values?

I just want simple explantion with answers if you can. I know it sounds like im just asking for the answer. but, well i couldn't do it on my own.. and I would like to learn from you if you can kindly explain what it is..

please I'll be much appriciated if you can help me. thank you