Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSI 1 3 1 Computational Thinking LAB 1 - Problem solving, introducing repetition and decisions: Intuitive Objectives: a ) Describe the difference between heuristic and
CSI Computational Thinking
LAB Problem solving, introducing repetition and decisions: Intuitive
Objectives:
a Describe the difference between heuristic and algorithmic solutions to problems.
b List describe the five steps to solving a problem that has an algorithmic solution.
Problem Types: From the definition of algorithm we see that it involves a set of steps to get to the solution. This is possible with numeric problems like performing long division, calculating the trajectory of a baseball, or adding a column of numbers. These problems are said to have an algorithmic solution. Some problems cannot be solved through a sequence of steps. For example, determining whether an egg is over cooked, deciding if a person is nice or whether to buy a certain stock. These problems have heuristic solutions. The solution is determined through trial and error techniques, experience or intuition.
Five Steps in Problem Solving:
i Understand the Problem: Once the problem is identified take time to understand every aspect of the problem. It is very important to do this because only after one understands the problem can one begin to solve the problem.
ii Design a Solution: Identify alternative solutions to the problem. The list should be as complete as possible. Look in books, discuss with friends, and consider all approaches you can think up consider the ridiculous, think outside the box Identify and evaluate the pros and cons of each possible solution prior to choosing the best one. Then design a solution using a flowchart in this class
iii Validate the solution: trace the logic to make sure that it produces correct answers. This requires testing every branch of the logic.
iv Implement the Best solution: In this class we will be using C to implement or solutions on a computer.
v Test the Solution: Check if the result is correct, and if it satisfies the needs of the person with the problem. If the result is either incorrect or unsatisfactory the process must be started over. If the solution contains semantic errors then use code tracing to debug the code.
Assignment Bob the Robot Bob has instructions in his knowledge base. He can follow a set of instructions and do what he is told, as long as they are part of his knowledge base. He executes instructions in sequential order when he is finished with one instruction he executes the next in order He does only what he is told.
Maneuvering Instructions:
Sit Down
Stand Up
Take Step will take a single step forward in the direction he is currently facing
Turn rotate left degrees
Open Door opens a door that is immediately in front of Bob
Conditional Instructions:
Wall in Front tests if there is a wall impeding next move
Door Closed tests if a door is closed
Chair in Front tests if chair is in front
Chair in Room tests if a chair is in the same room as Bob
Is Door test if door is in front
Repeat Instructions :
Repeat x Times instructionexecutes instruction x times
RepeatUntil statementrepeats until statement is false
Other Instructions :
Add Bob can remember a single number called Memoryand this will add one to it The number is zero when execution begins
Subtract this will subtract one from the number in Bobs memory
Halt stops execution of instructions
Example: Direct Bob to walk down a hall where a chair is sit down, get up and go back to where Bob started. Bob is currently facing the correct direction but we do not know how many steps to the chair.
RepeatUntilChair in Front Bob keeps walking and counting the
Take Step number of steps until the chair is encountered.
Add
Turn Turn Bob around so the chair is behind him.
Turn
Sit Down Bob sits
Stand Up Bob stands
Repeat Memory Times Take Step Bob goes back the number of steps he took
Halt Stop.
Use the five steps to solve the following:
a Direct Bob to walk in a square that is steps on each side. All turns are to be lefthand turns. How many solutions can you find?
b Direct Bob to walk in a square that is steps on each side. All turns are to be righthand turns. How many solutions can you find?
c Direct Bob to walk to a wall that is any distance forward and then walk back to three steps to the left of the starting location.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started