Question
a) How to find the k th smallest number given each element of the input sequence a1 , a2 , . . . an is
a) How to find the k th smallest number given each element of the input sequence a1 , a2 , . . . an is given one by one. Design an algorithm that again runs in O(n) expected time but this time uses O(k) space. You can assume that k is known ahead of time.
b) Give an O(n log n)-time algorithm to find the longest monotonically increasing sub- sequence of a sequence of n numbers. (Hint: Observe that the last element of a candidate subsequence of length i is at least as large as the last element of a can- didate subsequence of length i 1. Maintain candidate subsequences by linking them through the input sequence.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started