ANSWER MULTIPLE CHOICE
What is the tightest(best) worst case runtime for retrieving the smallest element in a min heap?
a. O(n)
b. O(1)
c. O(log(n))
o(log(n))
min heap
Definition: A min-Max heap is a complete binary tree such that if it is not empty,each element has a data member called key.Alternating levels of this tree are min levels and max level,respectively.the root is on min level.
To add an element to a min-max heap perform following
operations:
1. Append the required key to the array representing the min-max
heap. This will likely break the min-max heap properties, therefore
we need to adjust the heap. 2. Compare this key with its parent: 1.
If it is found to be smaller (greater) compared to its parent, then
it is surely smaller (greater) than all other keys present at nodes
at max(min) level that are on the path from the present position of
key to the root of heap. Now, just check for nodes on Min(Max)
levels. 2. If the key added is in correct order then stop otherwise
swap that key with its parent
ANSWER MULTIPLE CHOICE What is the tightest(best) worst case runtime for retrieving the smallest element in...
Show that the worst-case runtime of the Algorithm Heapify is on an array of length n in Ω(log(n)). Note: Construct a heap A with n nodes and show that heapify is called recursively accordingly.
Select all the valid asymptotic runtime bounds for the following function f2 in the worst case: public static int f1 (int n) { int x = 0; for (int i = 0; i < n; i++) { x++; } return x; } public static int f2 (int n) { if (n <= 1) { return 1; } return f1(n) + f2(n/2) + f2(n/2); } Θ(n^2) O(n^2) Θ(log(n)) Θ(log^2(n)) Θ(nlog(n)) Ω(n) Ω(n^2)
Which big-O expression best characterizes the worst case time complexity of the following code? public static int foo(int N) ( int count = 0; int i1; while (i <N) C for (int j = 1; j < N; j=j+2) { count++ i=i+2; return count; A. O(log log N) B. O(log N2) C. O(N log N) D. O(N2)
What is the Big Oh of the list method remove() in best case and worst cases? The answers to these two questions, found on page 396 are O(1) and O(n). Why is the best case O(1) and worst case O(n) ?
C++ Question 9 5 pts Deleting the minimum element in a min-heap of N elements takes in average case O(N log N) O(1) O(N) Oſlog N) D Question 10 5 pts The time taken to find an element in an AVL tree of depth d is Old) 02) Oſlog d) Old log d) Question 11 5 pts Secondary clustering in a hash table occurs when using Linear probing Separate chaining Quadratic probing Double hashing Question 12 5 pts When sorting...
what is the worst case run time when finding the maximum value in a binary min heap(implemented using array ) containing N elements? worst case run time: explain:
In the worst case, the very best that a comparison based sorting algorithm can do when sorting n records is Q (n^2) Q(log (n!)) (log n) O Q (n)
4. In an array-based implementation of the ADT list, what is the best case performance of the contains method? a. O(1) b. O(log n) C. O(n) d. O(nº) 5. In an array-based implementation of the ADT list, what is the worst case performance of the contains method? a. O(n) b. O(n) C. O(log n) d. 0(1) 6. In an array-based implementation of the ADT list, what is the performance of the contains method when the entry is not in the...
The time-complexity of searching an AVL tree is in the worst case and in the average case. On), On) O(logot). O(log O ON), C(n) 0(), O(log) Question 16 2 pts The time-complexity of searching a binary search tree is in the worst case and in the average case (1), O(log) O(logn), O(log,n) On), On) 001), 001)
PYTHON: Im stuck here, big O notation and runtime. What is it and Why are they those? Please look at the pic, need help as Im confused. Thank You! def method3(n): for i in range(n): for j in range(100): for k in range(n): print(i+j+k) What is the runtime (tightest/closest bound in terms of O) for the above python function (method 3)? Please briefly explain. Enter your answer here def method4(n): for i in range(n): for j in range(n, o, -2):...