JAVA What is the running time required for repeatedly splitting a problem into two equally sized halves, assuming no additional work needs to be done?
|
O(1) |
||
|
O(log10N) |
||
|
O(log2N) |
||
|
O(log2N) |
||
|
O(N) |
||
|
O(N log N) |
||
|
O(N2) |
||
|
O(N3) |
||
|
O(Nk) |
||
|
O(2N) |
||
|
O(N!) |
Recursive formula for repeatedly splitting a problem into two equally sized halves, assuming no additional work needs to be done
T(n) = T(n/2) + 1
= T(n/4) + 1 + 1
= T(n/8) + 1 + 1 + 1
......
......
......
= T(n/n) + 1 + .... + 1 + 1 + 1 [log(n) +1 terms]
= 1 + 1 + .... + 1 + 1 + 1 [log(n) +1 terms]
= log2(n)
= O(log2n)

|
O(log2N) |
JAVA What is the running time required for repeatedly splitting a problem into two equally sized...
What is the average running time for quicksort? O(1) O(log10N) O(log2N) O(log2N) O(N) O(N log N) O(N2) O(N3) O(Nk) O(2N) O(N!)
What is the worst case running time of a linear search? O(1) O(log10N) O(log2N) O(log2N) O(N) O(N log N) O(N2) O(N3) O(Nk) O(2N) O(N!)
What is the worst case running time of a binary search? O(1) O(log10N) O(log2N) O(log2N) O(N) O(N log N) O(N2) O(N3) O(Nk) O(2N) O(N!)
JAVA Deques are traversable data structures. True False What is the running time required for adding an item to a linked stack? O(1) O(log N) O(N) O(N/2)
Assume a set of problems that have the following time complexities(time efficiencies):Which n-sized problem has the most time-complex algorithm? A: O (n) B: O (nlog2n) C: O (n3) D: O (2n) E: O (nn)
4. Big-Oh and Rune time Analysis: describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. howing your work is not required (although showing work may allow some partial t in the case your answer is wrong-don't spend a lot of time showing your work.). You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for...
Mergesort3: Your friend suggests the following variation of Mergesort: instead of splitting the list into two halves, we split it into three thirds. Then we recursively sort each third and merge them. Mergesort3 (A[1...n]): If n <= 1, then return A[1..n] Let k = n/3 and m = 2n/3 Mergesort3(A[1..k]) Mergesort3(A[k+1..m]) Mergesort3(A[m+1..n) Merge3(A[1..k], A[k+1,..m], A[m+1..n]) Return A[1..m]. Merge3(L0, L1, L2): Return Merge(L0, Merge(L1,L2)). Assume that you have a function Merge that merges two sorted...
1. (10 points) Write an efficient iterative (i.e., loop-based) function Fibonnaci(n) that returns the nth Fibonnaci number. By definition Fibonnaci(0) is 1, Fibonnaci(1) is 1, Fibonnaci(2) is 2, Fibonnaci(3) is 3, Fibonnaci(4) is 5, and so on. Your function may only use a constant amount of memory (i.e. no auxiliary array). Argue that the running time of the function is Θ(n), i.e. the function is linear in n. 2. (10 points) Order the following functions by growth rate: N, \N,...
Assume you are given two linear lists of size n each; consider the problem of determining whether any element of one list is an element of the other (not value, element). Derive a lower bound for this problem and design an algorithm for this problem. Derive its time complexity. It should be as close the lower bound as possible. My work so far: //Copy list n1 into n3 int n3[n]; for(int I = 0; I < n; i++)n3[i] = n1[i];...
Problem #1: (15 points) You have two sorted lists of integers, L, and L2. You know the lengths of each list, L1 has length N, and L2 has length N2 (a) Design an efficient algorithm (only pseudocode) to output a sorted list L L2 (the intersection of L and L2). (b) If you know that N2> Ni. What is the running time complexity of your algorithm? Justify Important Note For this problem, you don't need to submit any implementation in...