Write a program using binary search approach

Assignment Help Programming Languages
Reference no: EM131993

There is a 10 by 10 grid on which the first player hides three battleships. Each battleship takes up five consecutive grid squares in a line (horizontal or vertical), so 15 grid square are occupied. The second player guesses a series of grid positions and is informed whether each one hits or misses a battleship; once the second player has found all the occupied grid squares, the game is over. You are to write a program that plays the game Battleship. To simulate the first player, randomly choose locations for the battleships. To simulate the second player, devise a strategy for finding all the battleship locations as quickly as you can. Use a divide-and-conquer or binary search approach.

Reference no: EM131993

Questions Cloud

Write a recursive program : Write a recursive program to compute the number of ways in which an integer k can be written as sum
Prepare a use case diagram : Prepare a Use Case Diagram based on the given problem description.
Explain the solution to the paradox using reasoning : Investigate puzzle and explain the solution to the paradox using mathematical reasoning.
Estimate the linear demand equation : Estimate the linear demand equation
Write a program using binary search approach : Write a program using binary search approach
Write a java class : Write a Java class called PQueue that extends the provided abstract QueueADT class.
Data structures and algorithm design : Data Structures and Algorithm Design

Reviews

Write a Review

Programming Languages Questions & Answers

  Formula translation

Write a c code that will evaluate the roots of a quadratic equation

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Write a paper on memory management

Write a paper on Memory Management

  Ethics and social responsibility

Ethics and social responsibility at McDonalds

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Communicate with a pc using the rs232c serial protocol

In this assignment we will use the UART0 peripheral to communicate with a PC using the RS232C serial protocol.

  Build a student record managing system application

Build a student record managing system application

  Create child processes

Create child processes

  Write a vhdl code for soda vending machine

Write a VHDL code that implements the above soda machine. You have to turn in the following: A state diagram showing the implementation of your design. Clearly show all the states and the conditions on which transitions occur.

  Build a student record managing system application

Build a student record managing system application

  Html/css

"Validating Your Work" Please respond to the following:  Describe attribute minimization. Explain what would happen if you tried to validate a page containing instances of attribute minimization. Propose a solution to this problem.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd