True or false aThe best algorithm for finding the mostfreque

True or false.

(a)The best algorithm for finding the most-frequent word in a paragraph is O(n log n), because there is a simple O(n) solution method when we assume that the list of words is sorted into alphabetical order.

(b) The GenLoop algorithm, which finds the nth element of a recurrence relation with k weights, is O(n · k).

(c) The sum of the series 20 + 21 + 22 + . . . + 2n is (2n+1 1).

(d) If its running time is T(n) = 13n 2 + 9 for problem size n, then the algorithm is (n) but not O(n).

(e) The following sequence of statements int a[10]; int *b = a; *(b+2) = 12; assigns 12 to a[2].

(f) If you sort the input before calling each function, then Quicksort is much faster than Selection Sort.

(g) If the array from a[1] to a[n] is a binary heap, then a[7] cannot be its third-smallest element.

(h) The deletemin function for a binary heap is O(1). (it can be either min or max)

(i) The statement vector> test; creates a vector of objects, each of which is a vector of Fraction items.

(j) If you execute the statement ofstream myfile (\"example.txt\"); then cout << \"Hello world!\"; would send its greeting to the the file named “example.txt” instead of the standard output.

Please state your explanations.

Solution

1.a) TRUE

For example take a positive integer K and a bif text. The text can be actually viewed as word sequence. So we don\'t have to worry about how to break downit into word sequence.

To Summarize the total time is O(n+nlog(n)+k), since K is similar than N, so it is actually O(n log(n)).

1.h) The deletemin function of a binary heap is not O(1) ,it is O(log n)

True or false. (a)The best algorithm for finding the most-frequent word in a paragraph is O(n log n), because there is a simple O(n) solution method when we ass

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site