1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bulgar [2K]
4 years ago
9

You will be given a value of n and k, one line each. You will write a program that determines the minimum number of probe attemp

ts in the worst case before you determine the correct day. Your output should be a single number that represents the minimum number of probes.
Computers and Technology
1 answer:
Natalija [7]4 years ago
4 0

Answer:

The written program is in the explanation

Explanation:

RomanticDays.java

import java.util.Scanner;

class RomanticDays {

  static int max(int a, int b) {

      return (a > b) ? a : b;    }

  static int minAttempt(int k, int n) {

      int romancticDays[][] = new int[k+1][n+1];

      int res;

      int loop1,loop2,i;

      for (loop1 = 1; loop1 <= k; loop1++) {

          romancticDays[loop1][1] = 1;

          romancticDays[loop1][0] = 0;    }

      for (loop2 = 1; loop2 <= n; loop2++)

          romancticDays[1][loop2] = loop2;

      for (loop1 = 2; loop1 <= k; loop1++) {

          for (loop2 = 2; loop2 <= n; loop2++) {

              romancticDays[loop1][loop2] = Integer.MAX_VALUE;

              for (i = 1; i <= loop2; i++) {

                  res = 1 + max(romancticDays[loop1 - 1][i - 1], romancticDays[loop1][loop2 - i]);

                  if (res < romancticDays[loop1][loop2])

                      romancticDays[loop1][loop2] = res;  

        }

          }

      }

      return romancticDays[k][n];

  }

  /* Driver program to test */

  public static void main(String args[]) {

      int n,k;

      System.out.print("Enter the value of N and k :");

      Scanner sc=new Scanner(System.in);

      n=sc.nextInt();

      k=sc.nextInt();

      System.out.println( minAttempt(k,n));

}

}

You might be interested in
What is Software Process Improvement?
kenny6666 [7]

Answer:

Software Process Improvement (SPI) methodology is defined as a sequence of tasks, tools, and techniques to plan and implement improvement activities to achieve specific goals such as increasing development speed, achieving higher product quality or reducing costs.

8 0
3 years ago
File
Degger [83]

Explanation:

formula should add cells D3:07.

Empanadas & More

1

In cell D9 create a formula that calculates the total after a 10% disco

you need help understanding how to take a percentage off of a total

LINE TOTAL

2 MENU ITEM

3 Empanadas: Buffalo Chicken

4 Empanadas: Braised Short Rib

5 Empanadas: Fig and Goat Cheese

6 Sides: Black beans and rice

7

UNIT PRICE

$2.98

$2.98

$3.75

$1.98

QUANTITY

20

30

25

40

TAX

8

TOTAL

6 0
3 years ago
Both the Cancel box and the Enter box appear on the formula bar when you begin typing in a cell.
amm1812
The correct answer for the question that is being presented above is this one: "TRUE." Both the Cancel box and the Enter box appear on the formula bar when you begin typing in a cell. The statement is true to the software application, spreadsheet or Excel.
5 0
3 years ago
ASAP PLZ!!! Select the correct answer. A research organization conducts certain chemical tests on samples. They have data availa
MrRa [10]

Answer & Explanation:

Data classification is an approach to identifying, protecting and managing information which has rapidly become best practice. Implemented as part of a layered security strategy, it enables an enterprise to defend itself against a variety of threats – from aggressive outsiders to untrained or well-meaning insiders – while unlocking the full potential of its data to drive innovation and productivity.

8 0
3 years ago
Differentiate toolbar and title bar​
deff fn [24]

Answer:

what???????

Explanation:

really? are you serious? just forget it. bye

6 0
3 years ago
Other questions:
  • In the relocatable dynamic partitions scheme, the Memory Manager relocates programs to gather together all of the empty blocks a
    9·1 answer
  • A ______ oversees the planning and implementation of sophisticated security measures to block unauthorized access but at the sam
    7·1 answer
  • When is a wrecker considered to be an emergency vehicle?
    12·1 answer
  • Large Format Camera holds:
    8·1 answer
  • Which of the following is a true statement? a. To have the computer close the current form when the user clicks the Exit button,
    9·1 answer
  • Assume that programs spend about 25% of their time waiting for I/O operations to complete. If there are FOUR programs loaded int
    9·1 answer
  • In what way are high-level programming languages limited? (5 points)
    13·2 answers
  • A falsh movies consist of how many frame? ​
    12·2 answers
  • Who is this wrong answers only
    7·1 answer
  • Types of computers bazed on size cost &amp;performance​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!