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

  Windows gui usually excels over command line interface cli

windows gui typically excels over command line interface cli owing to its ease of use and short learning curve. in your

  Create function that accepts one input parameter

Using Pseudocode, create your own function that accepts one input parameter and returns a float number. You decide the theme.

  Derive taylor polynomials of degree

Derive taylor's polynomials of degree n for: f(x) = (1+x)^(1/2) and f(x) = cos x. Find the approximate value of above functions at x = pi/4 by hand calculator upto two decimal points. Show steps.

  What would the data dictionary

what would the data dictionary look like for question 5a pg. 88

  Write lines of code as instructed in steps

Write lines of code as instructed in Steps

  Explain the major concepts behind computers

1. Explain the major concepts behind computers, computer algorithms, and computer literacy. 2. Explain the technologies that have contributed to the exponential growth of the Internet and the World Wide Web (WWW)3. Describe the impact of software d..

  Write a program that prompts the user for an integer value

write a program that prompts the user for an integer value for a length of a youtube clip in seconds then display the number of hours , minutes and seconds within the given length.

  Evidence handling is important in computer forensics

Evidence handling is important in computer forensics.

  Describe the importance of hardware independence

Describe the importance of hardware independence. List three benefits of data redundancy. What is the role of Active Directory in the Windows operating system

  Create an annotated bibliography

For the course project, you will create an annotated bibliography of five sources that cites and describes four of the best Internet resources on a specified topic and one of the best library database resources.

  Determine relation of m and n-existence of a hash function

Determine the most general relation of m and n that guarantees the existence of a hash function in H that causes no collision when hashing [n] into [m].

  Signed-magnitude representations binary numbers in computers

Why do we require signed-and-magnitude representations of binary numbers in computers? Represent decimal values: -37, -54, and 56 in binary by using signed-and magnitude representation.

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