Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

typedef struct Coordinate { int col ; // The column where this rook is located (1 through board width). int row ; // The row

typedef struct Coordinate { int col; // The column where this rook is located (1 through board width). int row; // The row where this rook is located (1 through board height). } Coordinate;

int allTheRooksAreSafe(char **rookStrings, int numRooks, int boardSize); Description: Given an array of strings, each of which represents the location of a rook on a boardSize boardSize chess board, return 1 if none of the rooks can attack one another. Otherwise, return 0. You must do this in O(numRooks + boardSize) time. Parameter Restrictions: boardSize will be a positive integer describing both the length and width of the square board. (So, if boardSize = 8, then we have an 8 8 board.) rookStrings will be a non-NULL (but possibly empty) array of strings, and any strings within that array will be unique (there will be no repeats), and all of those strings will follow the format described above for valid coordinates on a boardSize boardSize board. numRooks will be a nonnegative integer indicating the number of strings in the rookStrings array. Output: This function should not print anything to the screen. Runtime Requirement: The runtime for this function must be no worse than O(numRooks + boardSize). For details, see Section 3, Runtime Requirements (above). Returns: 1 if all the rooks are safe. Otherwise, return 0.

void parseCoordinateString(char *rookString, Coordinate *rookCoordinate); Description: Parse through rookString to determine the numeric row and column where the given rook resides on the chess board, and populate rookCoordinate with that information. You may assume that rookString is non-NULL, and that it contains a valid coordinate string using the format described above in Section 2.1, Coordinate System. You may assume that rookCoordinate is non-NULL and is a pointer to an existing Coordinate struct. Returns: Nothing. This is a void function.

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

Students also viewed these Databases questions

Question

WHAT IS AUTOMATION TESTING?

Answered: 1 week ago

Question

What is Selenium? What are the advantages of Selenium?

Answered: 1 week ago

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago