Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

A First Course In Probability

Authors: Sheldon Ross

9th Edition

978-9332519077, 9332519072

More Books

Students also viewed these Programming questions

Question

Will each visit to a restaurant result in consistent quality?

Answered: 1 week ago

Question

If E[X] = 1 and Var(X) = 5, find (a) E[(2 + X)2]; (b) Var(4 + 3X).

Answered: 1 week ago

Question

Use Theoretical Exercise 8 to prove that /Z Ft Ft

Answered: 1 week ago