Write algorithm to calculate the median using queries

Assignment Help Data Structure & Algorithms
Reference no: EM1368930

You are interested in analyzing some hard-to-obtain data from two separate databases. Each database contains n numerical values - so there are 2n values in all - and you can assume that no two values are the same. You'd like to determine the median of this set of 2n values, which we will define here as the n-th smallest value. However, the only way you can access these values is through queries to the databases. In a single query, you can specify a value k to one of the databases, and the chosen database will return the k-th smallest value that it contains. Since queries are expensive, you would like to calculate the median using as few queries as possible. Provide an algorithm which determines the median value using at most O(lg n) queries.

Reference no: EM1368930

Questions Cloud

Find the speed of the moving charge : Two identical 30 {rm g} particles each carry 3 {rm mu C} of charge. One is held fixed, and the other is located 1 {rm mm} away and released. Find the speed of the moving charge when it's 1{rm cm} from the fixed charge.
Explain new technologies or material changes : Explain new technologies or material changes that transform businesses' or companies' expectations and the way they interact
Considerations for training development : Considerations for Training Development - Show the process through which training needs identified in the analysis phase are translated into the training objectives.
What is the goal of employee development : What is the relationship between employee training and employee development and are both necessary within an organization
Write algorithm to calculate the median using queries : Calculate the median using as few queries as possible. Provide an algorithm which determines the median value using at most O(lg n) queries.
Determine the constant velocity of car : Two cars cover the same distance in a straight line. Car A covers the distance at a constant velocity. Car B starts from rest and maintains a constant acceleration. Both cars cover a distance of 547m in 221s.
Describe how you think a biographer causes of the event : Describe how you think a biographer, historian, or social scientist would describe the causes and consequences of the event
What is the linear charge density along the arc : A wooden raft has a mass of 59 kg. When empty it floats in water (density 1000 kg/m3) with 59 percent of its volume submerged. What mass of sand can be put on raft without it sinking.
Analyzing competitive markets : In a speech, Professor Gregory Mankiw contends that our elected federal leaders should raise the gasoline tax. Not quickly, but substantially.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Decrypting the ciphertext to recover the plaintext

If you get ciphertext message YPHDCRPBEQTAA, decrypt to recover plaintext.

  Survey of fault tolerance policy for load balancing scheme o

This paper investigates about fault-tolerance in load balancing schemes in distributed environment. There are some more parameters influencing QOS but our main focus is on fault tolerance and load balancing.

  Compare the average behavior of insertion sort

Compare the average behavior of insertion sort for n elements with that of the n insertions into an initially-empty straight array implementation of a priority queue

  Polynomial time algorithm for rooted directed acyclic graphs

Illustrate that if you were given a polynomial time algorithm for determining whether two rooted directed acyclic graphs are isomorphic, then polynomial time algorithm for testing.

  Devise ef?cient algorithm for computing probability

Given the probabilities r1, · · · , rn, the costs c1, · · · , cn, and the budget B, ?nd the redundancies m1, · · · , mn that are within the available budget and that maximize the probability that the system works correctly. Devise an ef?cient algo..

  Algorithm to take input m constraints over n variables

For instance, the constraints x1 = x2, x2 = x3, x3 = x4, and x1 6= x4 cannot be satis fied. Give an efficient algorithm that takes as input m constraints over n variables and decides whether the constraints can be satis fied.

  Sort array of elements using the quick sort algorithm

"sort an array of 10,000 elements using quick sort algorithm as follows: sort the array using pivot as middle element of the array

  Algorithm-find schedule to obtain maximum amount of profit

Give an algorithm to find schedule which obtains maximum amount of profit, assuming that all processing times are integers between 1 and n.

  Explaining elementary operations used in algorithm

How many elementary operations are used in algorithm given below? The elementary operations are comparison operations (such as > and

  Determine the inorder, preorder and postorder traversal

Determine the Inorder, preorder and postorder traversal

  Create algorithm to perform any sequence of two operations

Let A[1, n] be an array of real numbers. Create an algorithm to perform any sequence of the following two operations: Add(i, x): add the value x to A[i].

  Find cost of sorting the relation in seconds

Suppose you need to sort a relation of 40 gigabytes, with 4 kilobyte blocks, using a memory size of 40 megabytes. Find the cost of sorting the relation, in seconds, with bb = 1 and with bb = 100.

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