Introduction to Algorithms
Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
Question
Book Icon
Chapter 9.3, Problem 8E
Program Plan Intro

To give an algorithm that finds the median of all 2n elements in arrays X and Y in O(lgn) time.

Blurred answer
Students have asked these similar questions
Suppose we are given two sorted arrays A and B which each contain n elements. Give an O(log n) time divide-and-conquer algorithm which finds the median of A ∪ B.
Given 2 sorted arrays (in increasing order), find a path through the intersection that produces the maximum sum and return the maximum sum. That is, we can switch from one array to another array only atcommon elements. If no intersection element is present, we need to take the sum of all elements from the array with greater sum. Sample Input:61 5 10 15 20 2552 4 5 9 15Sample Output :81
Let A and B be two arrays of length n, each containing a random permutation of the numbers from 1 to n. An inversion between the two permutations A and B is a pair of values (x, y) where the index of x is less than the index of y in array A, but the index of x is more than the index of y in array B. Design an algorithm which counts the total number of inversions between A and B that runs in O(n log n) time.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education