120 likes | 327 Views
CSC 1750 Problem Solving. Spring 2013. References. Sprankle, Maureen and Jim Hubbard, Problem Solving and Programming Concepts , Eighth Edition, Prentice Hall, 2009. Polya, George , How to Solve It, Second Edition, Doubleday Anchor Books, 1957. Types of Problems. Algorithmic solutions
E N D
CSC 1750 Problem Solving Spring 2013
References • Sprankle, Maureen and Jim Hubbard, Problem Solving and Programming Concepts, Eighth Edition, Prentice Hall, 2009. • Polya, George, How to Solve It, Second Edition, Doubleday Anchor Books, 1957
Types of Problems • Algorithmic solutions • Problems that can be solved with a series of actions • Balancing checkbook, baking a cake • Alphabetizing 10,000 names • Heuristic solutions • Problem solution requiring reasoning based on knowledge and experience, and a process of trial and error • Solutions cannot be reached through a direct set of steps • How to buy the best stock or expand the company • Difficult to evaluate the solution
Types of Problems • People are better at solving heuristic problems • Artificial intelligence is the field of computer science that deals with heuristic problems • Computers are better at solving complicated calculus problems or alphabetizing 10,000 names • This class deals with algorithmic solutions
Problem Solving Steps • Identify the problem • Understand the problem • Identify alternative ways to solve the problem • Select the best way to solve the problem from the list of alternative solutions • List instructions that enable you to solve the problem using selected solution • Evaluate the solution
Problem Solving Techniques • Divide and conquer: break down a large, complex problem into smaller, solvable problems. • Hill-climbing: attempting at every step to move closer to the goal situation. • Means-end analysis: requires the setting of sub-goals based on the process of getting from the initial state to the goal state when solving the problem.
Problem Solving Techniques • Trial-and-error: select a possible answer, apply it to the problem and, if it is not successful, select another possibility. Ends when a possibility yields a solution. • Brainstorming: a group technique designed to generate a large number of ideas for the solution of a problem.
Software Problem Analysis • Analyze the problem to determine: • What equations will be needed • What are the variables and what are their types • What are the inputs and how will they arrive • What are the outputs and where will they be sent • Sequence of events
Example Program One • Enter, compile, and run a program named SquareArea.java to compute the area of a square. The length of the sides will be entered from the keyboard each time the program is run. • Analysis • Equations • area = side2 • Variables and types • area, integer or double • side, integer or double • Inputs • side, input for keyboard • Outputs • area, output to monitor
Example Program One (cont.) • Enter, compile, and run a program named SquareArea.java to compute the area of a square. The length of the sides will be entered from the keyboard each time the program is run. • Analysis • Sequence of events • Declare variables double area; double side; • Input side Declare input stream Read input from keyboard • Calculate area of square area = side * side; • Output area of square System.out.println(“The area of a square with side = “ + side + “is “ + area);