Find the longest monotonically

Assignment Help Data Structure & Algorithms
Reference no: EM131184492

Assignment sheet

1. Give an O(n2) algorithm to find the longest monotonically increasing subsequence of a se- quence of n numbers. (Example: given the sequence 4,8,5,7,2,9,10,1 your algorithm should output 4,5,7,9,10.)

2. Describe an O(n) time algorithm that, given a set S of n distinct numbers and a positive integer k ≤ n, determines the k numbers in S that are closest to the median of S.

3. Let X[1..n] and Y [1..n] be two arrays, each containing n numbers already in sorted order. Give an O(log n) time algorithm to find the median of all 2n elements in arrays X and Y.

4. Consider two sets A and B, each having n integers in the range from 0 to 10n. We wish to compute the Cartesian sum of A and B, defined by

C = {x + y : x ∈ A, y ∈ B}.

Note that the integers in C are in the range 0 to 20n. We want to find the elements in C and the number of times each element of C is realized as a sum of elements in A and B. Show that the problem can be solved in O(n log n) time.

5. We are given 2 positive integers a = (an-1an-2 . . . a0) and b = (bn-1bn-2 . . . b0), of n bits each, as 2 arrays A[1..n] and B[1..n], respectively. The MSB of a, that is an-1, is stored in the location A[1] and so on. Similarly with b. Give an O(n log n) algorithm to compute the array C[1..2n] that holds the integer ab (the product of a and b) in binary.

Reference no: EM131184492

Questions Cloud

Which is not a sign of stress and tension in children : Which of the following is NOT a sign of stress and tension in children? Which is the best thing to say to a child to teach him or her to think about safety for themselves?
What is the firms weighted average cost of capital : If Ty's yield to maturity on bonds is 7.5% and investors require a 15% return on Ty's common stock, what is the firm's weighted average cost of capital?
Were the police methods effective : Are there investigative tactics or resources available today that would have been of assistance in the investigation? How did the police and other agencies work together? Did the investigators engage the public in any way, to assist in the investigat..
Find the force the electron exerts on a dust particle : Find the force the electron exerts on a dust particle, charged with a total charge of 3.2 x 10-19 C (two protons) and located at a distance R from the electron.
Find the longest monotonically : Describe an O(n) time algorithm that, given a set S of n distinct numbers and a positive integer k ≤ n, determines the k numbers in S that are closest to the median of S.
Analyze the characteristics of human rights : Analyze the characteristics of human rights. What exist? What is its origin? What is its cause? What can change? "from war and christian ethics second edition
Adopt a maturity matching approach to financing assets : How would a more aggressive or a more conservative approach differ from the maturity matching approach, and how would each affect expected profits and risk?
Compare the article and adler theory : Create a 10-12-slide PowerPoint on the usefulness of birth order as a construct. Compare the article and Adler's theory and Describe your birth order/your family's birth order; does the theory still work
Find the horizontal distance between the two charges : find the horizontal distance between the two charges under the assumption that ex is small.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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