Question
2. (20 points) Alice writes n distinct integers on a blackboard, and picks a positive integer K. She then allows Bob to make moves,
2. (20 points) Alice writes n distinct integers on a blackboard, and picks a positive integer K. She then allows Bob to make moves, each of which consist of the following steps. 1. Identify two integers x and y on the blackboard which differ by at most K, i.e. |xy|K. 2. Erase the smaller of the two chosen integers. Bob's task is to make moves in this way until he is no longer able to do so. Note that in some cases, Bob may be unable to make even a single move. Design an algorithm which runs in O(n log n) time and finds the longest sequence of moves. If there are several sequences of maximum length, you may find any of them.
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 StartedRecommended Textbook for
A First Course In Probability
Authors: Sheldon Ross
9th Edition
978-9332519077, 9332519072
Students also viewed these Programming questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App