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

  Show how the tree might be type-checked

Attempt to derive proof tree for the judgment Show how the tree might be type-checked

  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

  Using the irvine32 library functions

Create 32 random points which have (x, y) co-ordinates

  Travelling salesman problem

Travelling Salesman Problem on the L1-metric plane.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Program to perform a search of an employee list

Write a /bash/bin program to perform a search of an employee list.

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  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.

  Create a simple shell

Create a simple shell. Basically your shell should read the line from standard input, parse the line with command and arguments, and operate the command with arguments.

  Write a paper on memory management

Write a paper on Memory Management

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