The obvious algorithm makes 2n - 2 comparisons

Assignment Help Basic Computer Science
Reference no: EM13935102

Given an array s =(s[1], s[2], . . . , s[n]), and n = 2^d for some d ≥ 1. We want to find the minimum and maximum values in s. We do this by comparing elements of s.

(a) The "obvious" algorithm makes 2n - 2 comparisons. Explain.

(b) Can we do it better? Carefully specify a more efficient divide-and-conquer algorithm.

(c) Let T(n) = the number of comparisons your algorithm makes. Write a recurrencerelation for T(n).

(d) Show that your recurrence relation has as its solution T(n) = 3n/2 - 2.

Reference no: EM13935102

Questions Cloud

Identify each of the following statements : Identify each of the following statements with fixed costs or variable costs by writing fixed or variable in the space provided.
Existence of just four large cpa firms-service virtually : The existence of just four large CPA firms that service virtually all of the major industrial and financial companies and thus dominate the accounting profession has led to criticism through the years. What dangers do you see from the dominance of a ..
What is the return on debt : Marten Corp has a 14% WACC with a 19% expected return on equity and a 60% debt-to-asset ratio. If Marten pays no income tax, what is the return on debt? If the debt-to-asset ratio increases to 80%, now what is Marten’s WACC?
Substantial dividend or repurchase shares of stock : Residential Inc. produced substantial profits in the previous year. Assume that Residential pays 35% corporate income tax. If investors are taxed at 25% on ordinary income, and have 0% capital gains tax, would Residential’s common stock investors pre..
The obvious algorithm makes 2n - 2 comparisons : Given an array s =(s[1], s[2], . . . , s[n]), and n = 2^d for some d ≥ 1. We want to find the minimum and maximum values in s. We do this by comparing elements of s. (a) The "obvious" algorithm makes 2n - 2 comparisons. Explain.
Should the company record sales when orders are placed : should the company record sales when orders are placed or, to be consistent with GAAP, wait until orders are delivered?
Fix the calculation part in form1 : Format the calculated values as currency which includes trailing zeros; clearing the control used to display the calculated values when the Add menu Item is clicked.
What is the big-o performance estimate : What is the big-O performance estimate of the following function? int f (n) {int sum = 0;
Explain the focus of managerial accounting : Assume the role of Summer and explain the focus of managerial accounting and some of the ways it differs from financial accounting.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Class templates are typically used to replace overloaded

1.How would you overload the comparison operators == and !=? What is the format to overload these operators? 2. Class templates are typically used to replace overloaded functions. Can you compare the two?

  What the mac-layer addresses

How can you find out what the MAC-layer addresses and IP host addresses are of the server farm devices?

  What were some of the industry factors

Your research should lead to answers to the following questions. What were some of the challenges that RIM faced to protect its intellectual property, and how did RIM handle those challenges? What were some of the industry factors that influenced..

  Assembling the research paper and presentation

You are only required to submit a final paper and presentation. However, during the previous six weeks, you will be assembling the research paper and presentation. Feel free to post questions or portions of the paper for review at any time as an emai..

  Theories of security management

1. Evaluate the effectiveness of the physical and environmental security measures that the organization you researched used in regard to protecting its assets. Indicate improvements to the organization's security measures where applicable. Justify yo..

  Entrepreneurs is starting a new data storage

An enterprising group of entrepreneurs is starting a new data storage and retrieval business, SecureStore, Inc. For a fee, the new company will accept digitalized data (text and images, multimedia), and store it on hard drives until needed by t..

  Create a local area network

Create a local area network (LAN) design diagram of the current network that describes the hardware and software resources that Matt described.

  Explaining data-tlb hit and data-cache hit

Upon a load instruction, event "data-TLB hit" followed by "data-cache hit" is the most probable to occur among four possibilities of Cartesian product.

  A network message transfer between source s and destinationd

Consider a network message transfer between a source S and a destination D

  What is the way in which exports are counted

What is the way in which exports are counted in the measurement of Gross Domestic Product (GDP)

  Use the 2s complement

Problem 1  Convert the following decimal numbers into (a) 8-bit, (b) 16-bit, and (c) 32-bit binary numbers. For negative numbers, use the 2's complement. State "overflow" if a number cannot be represented correctly. 1)  45 ten. 2)   -81 ten.  3)-3,0..

  Find the value in register a after the execution

Find the value in Register A after the execution of the following code, Which flag is used to see if the signed data are correctly added together

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd