Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2.4, Problem 22SC
Suppose the architect specifies a pattern with black, gray, and white tiles, like this:
Again, the first and last tile should be black. How do you need to modify the
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Give edgeTo after B is visited. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:-}.((Hint: the first step of the algorithm is to visit S, which should change the entries for A and B in edgeTo and distTo. The second step is to visit B, which should change the entries for C and E))Give distTo after B is visited. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:0}.Give edgeTo after Djiksta's is finished. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:-}.Give distTo after Dijkstra's is finished. Format your answer as {A:?, B:?, C:?, D:?, E:?, F:?, G:?, S:0}.
Examine the following graph. We will be running Dijkstra's algorithm starting at the node labeled S
S
5
1
2
A
E
F
9.
3
4
6
B
C
D
2
5
10
5
We're using the version of Dijkstra's algorithm described here in lecture: note that the fringe and
distro data structures are always changed at the same time.
Give the resulting edgeTo and distão maps after vertex B is visited (i.e. its outgoing edges to C and
E have been relaxed). Also give the resulting edgeTo and distro maps after Dijkstra's algorithm has
completely finished execution. Initialize the edgeTo for each vertex as - which will represent null
for us. Initialize the distro for each vertex as inf which we'll use to represent ∞o, except for S
where it should be 0.
So, before the first iteration, the values of these variables are:
edgeTo = {A, B, C:-, D:-, E:-, F:-, G:-, S:-}
distTo = {A: inf, B:inf, C:inf, D:inf, E:inf, F:inf, G:inf, S:0}
The maps must be in this order. If you have the same mappings but in a different order (i.e. the…
You are given an instance of a problem where you have an n x n grid
of squares. Each square can be unpainted or can have a hole, so you cannot go
on the square with a hole. The objective is to paint all the squares that do not
have a hole. You start in the square (0,0) which is unpainted. The actions you
can do are: (1) paint the square you are on if it is not painted; (2) move, either
vertically or horizontally, to an adjacent square inside the grid that is not painted
and does not have a hole.
a. Describe a state-space representation for the problem, specifying the
state representation, the initial state, the goal condition, and the actions.
b. Is the state space finite? Is it a tree or a graph?
c. Propose a heuristic for the problem. Is your heuristics admissible or not?
Explain briefly your answer
Chapter 2 Solutions
Big Java Late Objects
Ch. 2.1 - Declare a variable suitable for holding the number...Ch. 2.1 - What is wrong with the following variable...Ch. 2.1 - Declare and initialize two variables, unitPrice...Ch. 2.1 - Prob. 4SCCh. 2.1 - Some drinks are sold in four-packs instead of...Ch. 2.1 - Prob. 6SCCh. 2.1 - Prob. 7SCCh. 2.1 - Prob. 8SCCh. 2.1 - How would you explain assignment using the parking...Ch. 2.2 - A bank account earns interest once per year. In...
Ch. 2.2 - In Java, how do you compute the side length of a...Ch. 2.2 - The volume of a sphere is given by V=43r3 If the...Ch. 2.2 - Prob. 13SCCh. 2.2 - Prob. 14SCCh. 2.3 - Write statements to prompt for and read the users...Ch. 2.3 - What is wrong with the following statement...Ch. 2.3 - Prob. 17SCCh. 2.3 - What is problematic about the following statement...Ch. 2.3 - What is the output of the following statement...Ch. 2.3 - Using the printf method, print the values of the...Ch. 2.4 - Prob. 21SCCh. 2.4 - Suppose the architect specifies a pattern with...Ch. 2.4 - A robot needs to tile a floor with alternating...Ch. 2.4 - For a particular car, repair and maintenance costs...Ch. 2.4 - The shape of a bottle is approximated by two...Ch. 2.5 - What is the length of the string "Java Program"?Ch. 2.5 - Consider this string variable. String str = "Java...Ch. 2.5 - Use string concatenation to turn the string...Ch. 2.5 - Prob. 29SCCh. 2.5 - Prob. 30SCCh. 2 - Write declarations for storing the following...Ch. 2 - What is the value of mystery after this sequence...Ch. 2 - What is wrong with the following sequence of...Ch. 2 - Write the following mathematical expressions in...Ch. 2 - Write the following Java expressions in...Ch. 2 - What are the values of the following expressions?...Ch. 2 - What are the values of the following expressions,...Ch. 2 - What are the values of the following expressions?...Ch. 2 - Assuming that a and b are variables of type int,...Ch. 2 - Suppose direction is an integer angle between 0...Ch. 2 - Find at least five compile-time errors in the...Ch. 2 - Find three run-time errors in the following...Ch. 2 - Consider the following code segment. double...Ch. 2 - Explain the differences between 2, 2.0, 2, 2, and...Ch. 2 - Explain what each of the following program...Ch. 2 - Write pseudocode for a program that reads a word...Ch. 2 - Write pseudocode for a program that reads a name...Ch. 2 - Write pseudocode for a program that computes the...Ch. 2 - Modify the pseudocode for the program in How To...Ch. 2 - Prob. 20RECh. 2 - You are cutting off a piece of pie like this,...Ch. 2 - The following pseudocode describes how to obtain...Ch. 2 - Suppose you are given a string str and two...Ch. 2 - Prob. 24RECh. 2 - For each of the following computations in Java,...Ch. 2 - Prob. 26RECh. 2 - This chapter contains a number of recommendations...Ch. 2 - Write a program that displays the dimensions of a...Ch. 2 - Write a program that computes and displays the...Ch. 2 - Write a program that reads a number and displays...Ch. 2 - Write a program that prompts the user for two...Ch. 2 - Enhance the output of Exercise E2.4 so that the...Ch. 2 - Write a program that prompts the user for a...Ch. 2 - Write a program that prompts the user for a radius...Ch. 2 - Write a program that asks the user for the lengths...Ch. 2 - Improve the program discussed in How To 2.1 to...Ch. 2 - Write a program that helps a person decide whether...Ch. 2 - Write a program that asks the user to input The...Ch. 2 - File names and extensions. Write a program that...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Printing a grid. Write a program that prints the...Ch. 2 - Write a program that reads in an integer and...Ch. 2 - Write a program that reads two times in military...Ch. 2 - Writing large letters. A large letter H can be...Ch. 2 - Write a program that transforms numbers 1, 2, 3, ,...Ch. 2 - Write a program that prints a Christmas tree:...Ch. 2 - Easter Sunday is the first Sunday after the first...Ch. 2 - In this project, you will perform calculations...Ch. 2 - The following pseudocode describes how a bookstore...Ch. 2 - The following pseudocode describes how to turn a...Ch. 2 - The following pseudocode describes how to extract...Ch. 2 - Giving change. Implement a program that directs a...Ch. 2 - An online bank wants you to create a program that...Ch. 2 - A video club wants to reward its best members with...Ch. 2 - Consider the following circuit. Write a program...Ch. 2 - The dew point temperature Td can be calculated...Ch. 2 - The pipe clip temperature sensors shown here are...Ch. 2 - Prob. 12PPCh. 2 - Consider the following tuning circuit connected to...Ch. 2 - According to the Coulomb force law, the electric...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Determine the output of each of the following circuits, assuming that the upper input is 1 and the lower input ...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Demonstrate each of the anomaly types with an example.
Modern Database Management (12th Edition)
What about the following version?
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
True or False: You must have a return statement in a value-returning method.
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
In Exercises 55 through 60, find the value of the given function where a and b are numeric variables of type Do...
Introduction to Programming Using Visual Basic (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- A robot starts on a point marked “A” on a rectangular grid of points. The starting point is always the top left point on the grid. The robot can move left, right, up or down, moving from one point to the next. By moving in steps going left, right, up or down, the robot would like to reach a point marked “B”, which is always the bottom right point in the grid. Sometimes, points are marked as “x”, and the robot is not allowed to visit them at all. A robot is never allowed to visit a point more than once. In how many ways can the robot move from A to B and visit all points along the way? For example, in the following grid, represented in text as A . . . . B there is only one path from A to B: In the following grid, represented in text as A . . x x B there is still only one path (we're lucky because of the two x's): However, in the grid A . . . x B there are no ways for the robot to move from A to B and visit all points that are not marked with “x”. Write a single…arrow_forwardA boatman, a wolf, a sheep, and a cabbage are on the bank of a river. They have a small boat that is capable of carrying the boatman and at most one other animal/item with him. However, if left alone by the boatman, the wolf can eat the sheep, and the sheep can eat the cabbage. How can all four be moved safely to the opposite bank of the river? Here is a nice visualization of the whole process in the original game. Disclaimer: writers, testers and CodeChef are not related to this link. This leads to a more general problem. If there are other groups of animals/items with the boatman, is it possible to move them all to the opposite bank of the river in such a way that nobody/nothing gets eaten? We will give you the number of animals/items (not including the boatman). Moreover, we will give you all a list of pairs of the form "X Y" where the X-th animalitem will be eaten by the Y-th one if they are both on the opposite bank to the boatman. You are to determine whether it is possible to…arrow_forwardCSEarrow_forward
- java-matlabarrow_forwardCan you provide the code and comment for this question.arrow_forwardWrite a function find_equivalent_matchings that takes a matching and returns all matchings with the same pattern (including the original one). Using this function, draw all matchings equivalent to {(0, 7), (1, 4), (2, 3), (5, 6)}. You might find it helpful to generate all permutations of a list using itertools.permutation (imported above) as in the following code template. perms=permutations (list_of_items) for p in perms:arrow_forward
- Need help in writing a backtracking code that finds a path in a given maze. The problem is that the given mazes do not have a given destination. The path exit is when you reach an edge square that is not the point of entry.Example: X X X X O O O X O- represents the path that we're allowed go X X O X 1- represents the wall X X O X the last O would be the exit. The code has to be written in c++. If you cant write the code, please at least help me with the logics. Thank you so much !!!arrow_forwardWrite a program using Python to solve the locker riddle which reads as follows: Imagine 100 lockers numbered 1 to 100 with 100 students lined up in front of those 100lockers:The first student opens every locker.The second student closes every 2nd locker.The 3rd student changes every 3rd locker; if it’s closed, she opens it; if it’s open, she closes it.The 4th student changes every fourth locker (e.g., 4th, 8th, etc.).The 5th student changes every 5th locker (e.g., 5th, 10th, etc.).That same pattern continues for all 100 students. Which lockers are left open after all 100 students have walked the rowof lockers?arrow_forwardYour objective is to write the solution to the 9 × 9 sudoku puzzle below. You must write in the digits 1 through 9 in each row such that no digit is repeated vertically, horizontally and in each box. In your solution, write each row on itsown line; and for each row, write each digit enclosed in square braces. For instance, if the row is (1, 2, 3, 4, 5, 6, 7, 8, 9), then you would type [1][2][3][4][5][6][7][8][9] for that row.arrow_forward
- Your objective is to write the solution to the 9 × 9 sudoku puzzle below. You must write in the digits 1 through 9 in each row such that no digit is repeated vertically, horizontally and in each box. In your solution, write each row on itsown line; and for each row, write each digit enclosed in square braces. For instance, if the row is (1, 2, 3, 4, 5, 6, 7, 8, 9), then you would type [1][2][3][4][5][6][7][8][9] for that row.arrow_forwardSubstitution ciphers are encryption/decryption algorithms that replace one letter or number with another. The first attested use of a substitution cipher in military affairs was by Julius Caesar, described by him in Gallic Wars (cf. Kahn pp83-84). In caesar cipher , you replace each letter by 3rd letter on. If it is out of bound (later than Z), then round to the head (letter A) and continue the shift. For example:meet me after the toga party PHHW PH DIWHU WKH WRJD SDUWB Please write a program in Java to implement the Caesar Cipher: a. Implement the encryption algorithm. Ask the user to input one all lower case normal sentence (called plaintext) using the nextLine method, and then output the encrypted text (called ciphertext). b. Implement the decryption algorithm. Ask the user to input one encrypted sentence (i.e. ciphertext) using the nextLine method, and then output the decrypted text (i.e. plaintext).arrow_forwardLet's begin with a lesson in roulette. Roulette is a casino game that involves spinning a ball on a wheel that is marked with numbered squares that are red, black, or green. Half of the numbers 1–36 are colored red and half are black and the numbers 0 and 00 are green. Each number occurs only once on the wheel. We can make many different types of bets, but two of the most common are to bet on a single number (1–36) or to bet on a color (either red or black). These will be the two bets we will consider in this project. After all players place their bets on the table, the wheel is spun and the ball tossed onto the wheel. The pocket in which the ball lands on the wheel determines the winning number and color. The ball can land on only one color and number at a time. We begin by placing a bet on a number between 1 and 36. This bet pays 36 to 1 in most casinos, which means we will be paid $36 for each $1 we bet on the winning number. If we lose, we simply lose whatever amount of money we…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY