2. Write a program that paints the following checkerboard floor pattern. How long is your program...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. Write a program that paints the following checkerboard floor pattern. How long is your program in terms of number of commands? If the floor was of size n-by- n, give a big-e estimate for the length of the program needed to paint the same pattern. Explain how you derived your estimate. Hints: For a lower bound, what is the number of "P" commands that you will need in terms of n? For the upper bound, overestimate how many times you will need each command separately in terms of n and then add your estimates together. 2 Introduction Objective: In this project we will explore the concept of big- and give some big- estimates for different algorithms. Suppose you have a robot that you are trying to program¹ to paint floor patterns for you on a square grid in a square room. This robot can only understand a few simple commands: 1. F move forward one square 2. R-rotate 90° to the right 3. L rotate 90° to the left 4. P- paint the floor square underneath Assume that the robot always begins in the bottom leftmost square in the room facing upwards. 2. Write a program that paints the following checkerboard floor pattern. How long is your program in terms of number of commands? If the floor was of size n-by- n, give a big-e estimate for the length of the program needed to paint the same pattern. Explain how you derived your estimate. Hints: For a lower bound, what is the number of "P" commands that you will need in terms of n? For the upper bound, overestimate how many times you will need each command separately in terms of n and then add your estimates together. 2 Introduction Objective: In this project we will explore the concept of big- and give some big- estimates for different algorithms. Suppose you have a robot that you are trying to program¹ to paint floor patterns for you on a square grid in a square room. This robot can only understand a few simple commands: 1. F move forward one square 2. R-rotate 90° to the right 3. L rotate 90° to the left 4. P- paint the floor square underneath Assume that the robot always begins in the bottom leftmost square in the room facing upwards.
Expert Answer:
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Posted Date:
Students also viewed these programming questions
-
write a program that implements a variant of a linked list. This variant has a dummy node pointed to by the head link as shown in the following figure: Linked list with a dummy first node: item next...
-
Write a program that receives an ASCII code (an integer between 0 and 127) and displays its character. For example, if the user enters 97, the program displays the character a. Here is a sample run:...
-
Write a program that paints a smiley face, as shown in Figure 14.46a. (a)
-
Define the necessary and sufficient condition for two transactions to be serialisable. Give an example of a non-serialisable execution of a pair of transactions. [3 marks] (c) Define the necessary...
-
Registered nurses in 2007 made an average hourly wage of $30.04. In 2011, their hourly wage had risen to $33.23. Given that the CPI for 2007 was 207.3 and the 2011 CPI was 224.9, answer the...
-
Write a class named Retail Item that holds data about an item in a retail store. The class should store the following data in attributes: item description, units in inventory, and price. Once you...
-
White Company can invest in one of two projects, TD1 or TD2. Each project requires an initial investment of $101,250 and produces the year-end cash inflows shown in the following table. Required 1....
-
Eddie Kelly is running for reelection as mayor of a small town in Alabama. Jessica Martinez, Kelly's campaign manager during this election, is planning the marketing campaign, and there is some stiff...
-
What is the output of this code? x=3 num = 17 print(num %x)
-
(Allocating Parking Spots) You are the manager of a luxury apartment building whose parking garage contains 300 parking spots. Residents may choose to purchase a dedicated parking spot for $60,000...
-
need help with the below thanks SRV-01 SRV-02 . Network A Network C RTR-01 IP-1 RTR-02 IP-1 RTR-01 RTR-02 RTR-01 IP-2 Network B RTR-02 IP-2 WAN Connection RTR-03 IP-1 RTR-03 IP-2 o Network B is the...
-
Name the two most commonly used overall methods of accounting.
-
What tax benefits are embodied in specific legacies and bequests?
-
What is substantially appreciated inventory?
-
In what situation will a corporate shareholder receive non recognition treatment in a complete liquidation?
-
What are four broad types of like-kind exchanges?
-
Two 2.5-cm-diameter-disks spaced 1.9 mm apart form a parallel-plate capacitor. The electric field between the disks is 4.3105 V/m.
-
What services are provided by the provincial and territorial governments?
-
In Listing 19.1, GenericStack is implemented using composition. Define a new stack class that extends ArrayList. Draw the UML diagram for the classes and then implement GenericStack. Write a test...
-
The program in Listing 28.14 lets the user enter an input for the nine tails problem from the console and displays the result on the console. Write a program that lets the user set an initial state...
-
Add a slider to enable the user to set the current time for the video and a label to display the current time and the total time for the video. As shown in Figure 16.47a, the total time is 5 minutes...
-
How are risk and return each defined? Do you think there is a relationship between them?
-
Describe the components of a business plan. How does each of these components help the following people to make decisions about a business? (a) An investor. (b) A creditor. (c) A manager or owner.
-
Define relevant range. Why is it important?
Study smarter with the SolutionInn App