Question

Please show the work. I already know the answers, but don't understand how to get there.

5. Q5. Algorithm Efficiency I. Algorithm A performs (n) binary searches in an array of size n/2. Algorithm B performs e(n) se

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a) worst case time of algo A = e(n) binary searches

single binary search operation on a list of n/2 elements take = elogn) time

Total time taken by algo A = elogn) * (n) = (nlogn)

b) worst case time of algo B = (Vn – sequenntial searches

single sequential search operation on a list of 4n elements take = on) time

Total time taken by algo B = ) Ꮎ = ( u )Ꮎ * ( u* }Ꮎ

c) Asymptotically O(n1.5) > (nlogn) ​​​​​​​

Hence, algorithm A is more efficient

Add a comment
Know the answer?
Add Answer to:
Please show the work. I already know the answers, but don't understand how to get there....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please provide solution/methods so I can understand how this work. Given a algorithm with f(n) 5n2...

    Please provide solution/methods so I can understand how this work. Given a algorithm with f(n) 5n2 + 4n + 14 in the worst case, f(n) 3n2 + 17 log, n + 1in the average case, and f(n) in 17 the best case. Which of the following would be the tightest possible asymptotic descriptions of the algorithm? The following statement that would be tightest possible asymptotic description of the algorithm above A) O(n) B) o (n) C) (n?) D) On Log...

  • (1) Give a formula for SUM{i} [i changes from i=a to i=n], where a is an...

    (1) Give a formula for SUM{i} [i changes from i=a to i=n], where a is an integer between 1 and n. (2) Suppose Algorithm-1 does f(n) = n**2 + 4n steps in the worst case, and Algorithm-2 does g(n) = 29n + 3 steps in the worst case, for inputs of size n. For what input sizes is Algorithm-1 faster than Algorithm-2 (in the worst case)? (3) Prove or disprove: SUM{i**2} [where i changes from i=1 to i=n] ϵ tetha(n**2)....

  • please I need it urgent thanks algorithms 2.1 Searching and Sorting- 5 points each 3. What is the worst case for quick sort? What is the worst case time com- plexity for quick sort and why? Ex...

    please I need it urgent thanks algorithms 2.1 Searching and Sorting- 5 points each 3. What is the worst case for quick sort? What is the worst case time com- plexity for quick sort and why? Explain what modifications we can make to quick sort to make it run faster, and why this helps. 4. Give pseudocode for an algorithm that will solve the following problem. Given an array AlL..n) that contains every number between 1 and n +1 in...

  •    1st photo is the introduction. 2nd photo are the questions. Thanks in advance! 5 Comparing...

       1st photo is the introduction. 2nd photo are the questions. Thanks in advance! 5 Comparing Substrings Here you'll evaluate running times of algorithms whose input size is expressed using two parameters. Let T[l.n] and T'[1.n] be strings of length n, over a finite alphabet (For example, T and T' might be over the alphabet {A, C, G, T), and represent DNA strands.) A function Match indicates whether or not a letter of T matches a letter of T. That...

  • I also don't quite understand the meaning of N.size, is N.size (the sum of nodes) (a...

    I also don't quite understand the meaning of N.size, is N.size (the sum of nodes) (a node and its sub trees) has? please also explain that, thank you. modify the standard definition of a binary search tree to add a field N.size at each Suppose that we node, which records the size of the subtree under N'Tincluding N itself). A. Explain how to modify the procedure for adding both the case where X is not yet in the tree and...

  • I already solved part A and I just need help with part B 1. Matrix Multiplication...

    I already solved part A and I just need help with part B 1. Matrix Multiplication The product of two n xn matrices X and Y is a third n x n matrix 2 = XY, with entries 2 - 21; = xixYk x k=1 There are n’ entries to compute, each one at a cost of O(n). The formula implies an algorithm with O(nº) running time. For a long time this was widely believed to be the best running...

  • Please give little explanation, I'm trying to understand why. 2. List appropriate Worst Case Big O...

    Please give little explanation, I'm trying to understand why. 2. List appropriate Worst Case Big O Notation under the different algorithms or data structure operations. O(1) O(n) O(n ^ 2) O(log n) A. Directly Accessing value in a 2-dimensional by [row][column] B. Selection Sort then Binary Search on a 1,000,000 element array C. Binary Search D. Highest element algorithm for 10,000 element array. E. Traversal of 6 character string O(n) 3. Give examples of Implicit declarations for Python and C++....

  • PLEASE READ CAREFULLY AND ALL THE WAY THROUGH!!! I already asked this question but unfortunately the...

    PLEASE READ CAREFULLY AND ALL THE WAY THROUGH!!! I already asked this question but unfortunately the person who answered it did not read it. There is a sorting algorithm, “Stooge-Sort” which is named after the comedy team, "The Three Stooges." if the input size, n, is 1or 2, then the algorithm sorts the input immediately. Otherwise, it recursively sorts the first 2n/3 elements, then the last 2n/3 elements, and then the first 2n/ 3 elements again. The details are shown...

  • Insertion sort on small arrays in merge sort Although merge-sort runs in Θ(n log n) worst-case...

    Insertion sort on small arrays in merge sort Although merge-sort runs in Θ(n log n) worst-case time and insertion sort runs in Θ(n 2 ) worst-case time, the constant factors in insertion sort can make it faster in practice for small problem sizes on many machines. Thus, it makes sense to coarsen the leaves of the recursion by using insertion sort within merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k sublists of...

  • Please Use C++ Language. And Note that please donot post the answer already there Because there...

    Please Use C++ Language. And Note that please donot post the answer already there Because there is similar answer code but I need with modified Quick sort algorithm ​. Update your program from ... Create an array that holds 1000 random integers between 1-1000. Allow the user to enter an integer to search. Create and implement modified Quick sort algorithm which will sort the array before the Binary Search algorithm is executed. Create and implement a Binary Search Algorithm ....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT