Describe why algorithm runs in on time

Assignment Help Data Structure & Algorithms
Reference no: EM1372062

Assume you have an array A of n items, and you want to find the k items in A closest to the median of A. For example, if A contains the 9 values {7, 14, 10, 12, 2, 11, 29, 3, 4} and k = 5, then the answer would be the values {7, 14, 10, 12, 11}, since the median is 10 and these are the five values in A closest to the value 10. Give an algorithm to solve this problem in O(n) time, and explain why your algorithm runs in O(n) time. You may use the selection algorithms discussed in the book and the notes as subroutines of your solution. (Hint: you may want to call the selection algorithm more than once.)

Reference no: EM1372062

Questions Cloud

What is non-verbal communication : What is non-verbal communication and how does one improve it and how can one be self-aware of their non-verbal gestures?
Discuss the concept of marriage : Describe and critically discuss the concept of marriage from both the functionalist perspective and the conflict perspective. Provide at least one example for each.
Define subsidy : Mr. Smith, has fallen behind on his work, he has asked you to help to make a letter for a local business or economic project.
Contemporary norms associated with hegemonic masculinity : Determine the contemporary norms associated with the hegemonic masculinity and document the consequences of such norms for men and their families, and their relationships with women.
Describe why algorithm runs in on time : Assume you have the array A of n items, and you want to find k items in A closest to the median of A. Describe why your algorithm runs in O(n) time.
Disucss the influences of price elasticity of demand : Post a memo to explain the factors that contribute to the elasticity of goods. Also incorporate a real-life example of price elasticity of demand, and discuss how it impacts the economy.
Major methods of sociological research : Discuss how each of the major methods of sociological research - experiment, survey, participant observation, and secondary research - are suitable for helping us to answer different types of questions and to study different situations.
Source of knowledge in terms of strengths : Evaluate each source of knowledge in terms of its strengths and limitations as it applies to how your discipline obtains knowledge.
Explain algorithm from is optimal by proving lower bound : Illustrate that your algorithm from (a) is optimal by proving lower bound of n - k on number of comparisons required to solve the problem.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Create a solution algorithm using pseudocode

Algorithm that will receive two integer items from a terminal operator, and display to the screen their sum, difference, product and quotient.

  Efficient algorithm that achieves goal using base station

So that every house is within four miles of one of the base stations. Write efficient algorithm that achieves this goal, using as few base stations as possible.

  Create efficient algorithm to find path in graph

Given connected undirected graph G described by the adjacency list representation create the efficient algorithm to find the path in G which goes through exactly once in each direction.

  Design a divide-and-conquer algorithm

Design a divide-and-conquer algorithm for the Motif Finding problem and estimate its running time. Have you improved the running time of the exhaustive search algorithm?

  Dynamic-programming algorithm for rod-cutting problem

Consider a modification of the rod-cutting problem in which, in addition to a price pi for each rod, each cut incurs a fixed cost of c. Give a dynamic-programming algorithm to solve this modified problem.

  Implement a queue as a circular array

Implement a queue as a circular array as follows: Use two index variables head and tail that contain the index of the next element to be removed and the next element to be added.

  Computing total number of keys needed in symmetric cipher

Determine the total number of keys that are needed for organization if symmetric cipher is used.

  Explaining adaptive playout delay algorithm

Consider adaptive playout delay algorithm. Demonstrate through simple example which adjusting playout delay at beginning of each talk spurt results in compressing

  Algorithm on dynamic programming-minimize amount of walking

Our goal is to plan this trip so that we minimize the maximum amount of walking done in a single day. Your algorithm should be based on dynamic programming and run efficiently.

  Addition and subtraction of numbers in binary

Addition and Subtraction of numbers in binary and round to the nearest decimal number with three significant decimal digits

  Explain advantages of eager decision tree algorithm

Explain advantages and disadvantages of new algorithm compared with eager decision tree algorithm, and advantages and disadvantages of new algorithm compared with lazy kNN algorithm.

  Explain the sorting techniques selection sort

Explain the following sorting techniques using appropriate algorithms- (i) selection sort (ii) bubble sort

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