Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Consider the task of searching a sorted array A[1,,n] for a given element x: a task we usually perform by binary search in time O(logn) . Show that any algorithm that accesses the array only via comparisons (that is, by asking questions of the form “is A[i]z 0?”), must take Ω(logn) steps.

Short Answer

Expert verified

Yes, any algorithm that accesses the array only via comparisons take Ωlogn steps.

Step by step solution

01

Explain Binary Search

Binary search is implemented on a sorted array. Binary search always starts with the mid element. Mid element compared with every other element and the element to be searched will be found.

02

Show that any algorithm that accesses the array via comparisons takes Ω(logn) steps.

Knowing that a query produces two kinds of results that is yes or no. The arrayA1,,ncan be divided into two parts based on the result of the query.

In the best case, the two divided parts will be equal and the search can be scaled regardless of the query result.

Therefore, To locate a unique element by comparisons, it takes Ωlogn steps

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Suppose we want to evaluate the polynomial P(x) = a0 + a1x + a2x2 + ... + anxn at point x.

  1. Show that the following simple routine, known as Horner’s rule, does the job and leaves the answer in z.
    z = an
    for I = n-1 down to 0 :
    z = zx + ai
  2. How many additions and multiplications does this routine use, as a function of n ? Can you find a polynomial for which an alternative method is substantially better?

An array A[1...n] is said to have a majority element if more than half of its entries are the same. Given an array, the task is to design an efficient algorithm to tell whether the array has a majority element, and, if so, to find that element. The elements of the array are not necessarily from some ordered domain like the integers, and so there can be no comparisons of the form “ is A[i]>A[j] ?”. (Think of the array elements as GIF files, say.) However you can answer questions of the form: “is ..?” in constant time.

(a) Show how to solve this problem in O(nlogn) time. (Hint: Split the array A into two arrays A1and A2of half the size. Does knowing the majority elements of A1and A2help you figure out the majority element of A? If so, you can use a divide-and-conquer approach.)

(b) Can you give a linear-time algorithm? (Hint: Here’s another divide-and-conquer approach:• Pair up the elements of A arbitrarily, to get n/2 pairs• Look at each pair: if the two elements are different, discard both of them; if they are the same, keep just one of them . Show that after this procedure there are at most n/2 elements left, and that they have a majority element if A does.)

A binary tree is full if all of its vertices have either zero or two children. Let Bndenote the number of full binary trees with n vertices. (a)By drawing out all full binary trees with 3, 5, or 7 vertices, determine the exact values of B3, B5, and B7. Why have we left out even numbers of vertices, like B4?

(b) For general n, derive a recurrence relation for Bn.

(c) Show by induction that Bnis Ω(2n).

Question: Use the divide-and-conquer integer multiplication algorithm to multiply the two binary integers 10011011and10111010 and .

Practice with polynomial multiplication by FFT.

(a) Suppose that you want to multiply the two polynomials x + 1 and x2+1using the FFT. Choose an appropriate power of two, find the FFT of the two sequences, multiply the results component wise, and compute the inverse FFT to get the final result.

(b) Repeat for the pair of polynomials 1+x+2x2and 2 + 3x.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free