• Tidak ada hasil yang ditemukan

Consider the strategy that minimizes the number of trials in the worst-case

N/A
N/A
Protected

Academic year: 2024

Membagikan "Consider the strategy that minimizes the number of trials in the worst-case"

Copied!
1
0
0

Teks penuh

(1)

COL351: Analysis and Design of Algorithms (CSE, IIT Delhi, Semester-I-2016-17) HW-4, Programming

There are 1 questions for a total of 25 points.

1.

(25) The egg drop problem: There is a building withnfloors. You have identical eggs with the property that any egg will break iff thrown from floorB and above. If an egg breaks, you cannot fix and reuse it. You want to determine the value of B. Consider the case where you only have one egg. In this case, the worst-case number of trials needed isn−1 since the value ofB may be equal tonand the only strategy is to start dropping the egg from floor 1,2,3, ..., n−1. Now, suppose you have two eggs. Consider the strategy that minimizes the number of trials in the worst-case. Let this worst-case number of trials be denoted byT(n,2). Similarly, we can define T(n,3), T(n,4), ... (for 3 eggs, 4 eggs etc.). Design an algorithm to compute the value of T(n, k) for any given k(1≤ k≤100) and n(1 ≤n ≤10000). You may assume that 1≤B ≤n.

Your programs should take input from a file named input.txt and should write the output in a file named output.txt. Your programs should produce an output within 2 minutes for this assignment.

The format for input and output files are as follows.

INPUT: The first line of the input file givesn, k. Below is an example of an input file.

5,1

OUTPUT: The output should beT(n, k). For example, consider the output file corresponding to the input file above:

4

SUBMISSION INSTRUCTIONS: All your program files should be in a directory namedhYour entry no.i. You will be asked to create a zip of this directory and submit this zip file. In this directory, there should be a makefile that will compile your code (read about makefile on the net in case you do not know what it is). After runningmake, the directory should have executable calledeggdrop. This when executed, should read the input file (input.txt) and write the answer in the output file (output.txt).

1 of 1

Referensi

Dokumen terkait

Analysis of Financing Strategy in Optimizing The Concept of Green Finance (Case Study at Bankaltimtara Syariah, Berau

Yielding the floor Teacher : “ Could you explain about the generic structure in descriptive text!” Student : “ Generic structure in descriptive text are identification and

STRATEGY OF BUSINESS INNOVATION IN SYARI’AH BANKS CASE STUDY OF THE FINANCING TRANSACTION MODEL IN BANK BJM SYARI’AH‘S PRODUCTS SURABAYA Ismail Nawawi IAIN Sunan Ampel Surabaya

se in the construction 1 is analysed as a genitive Case morpheme in the Dgen head position of DP 2 ; this head c-selects NP in 1 as its complement.. Consequences In this section we

Endpoints in the EMPERIAL-Preserved and EMPERIAL-Reduced trials Primary endpoint • Change from baseline in 6-min walk test distance at week12 Key secondary endpoints • Change from

The result of the current state value stream mapping of the manufacturing process of rubber modular screen panels indicated how much WIP was on the factory floor, mapped out information

Iranian Journal of Otorhinolaryngology, Vol.343, Serial No.1 22 , May-2022 Case Report A Case Report of Kissing Carotid Arteries in the Retropharynx Siti Asmat Md Arepen1, Azreen

The results of this research explain 1 A case study of digital marketing strategies for MSMEs in Riau Province in the digital era explains that the strategies implemented are