Algorithms and Problem Solving

Slides:



Advertisements
Similar presentations
Problem Solving and Algorithm Design
Advertisements

1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Slides modified by Erin Chambers Problem Solving and Algorithm Design.
6-1 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s.
Problem Solving and Algorithm Design
Chapter 6 Problem Solving and Algorithm Design. 2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 6 Problem Solving and Algorithm Design. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Algorithms and Problem Solving-1 Algorithms and Problem Solving Mainly based on Chapter 6: “Problem Solving and Algorithm Design” from the Book: “Computer.
Problem Solving #1 ICS Outline Review of Key Topics Review of Key Topics Example Program Example Program –Problem 7.1 Problem Solving Tips Problem.
1 Chapter 6 Object-Oriented Software Design and Implementation.
Algorithms and Problem Solving-1 Algorithms and Problem Solving Mainly based on Chapter 6: “Problem Solving and Algorithm Design” from the Book: “Computer.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Chapter 2: Algorithm Discovery and Design
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
Chapter 6 Problem Solving and Algorithm Design Nell Dale John Lewis.
Chapter 1 Software Engineering. Homework ► Read Section 2.2 (pages 79-98) ► Answer questions: ► 7, 8, 11, 12, & 13 on page 134. ► Answer on paper, hand.
6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question.
Problem Solving and Algorithm Design
Domain Modeling (with Objects). Motivation Programming classes teach – What an object is – How to create objects What is missing – Finding/determining.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Chapter 9 High-Level Programming Languages: C++. Chapter Goals Describe the expectations of high level languages Distinguish between functional design.
CPS 120: Introduction to Computer Science
Chapter 9 Object-Oriented Design and High-Level Programming Languages.
Simple Program Design Third Edition A Step-by-Step Approach
Chapter 4 ADT Sorted List. 2 Goals Describe the Abstract Data Type Sorted List from three perspectives Implement the following Sorted List operations.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Problem Solving and Algorithm Design. 2 Problem Solving Problem solving The act of finding a solution to a perplexing, distressing, vexing, or unsettled.
Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.
CS 1308 Computer Literacy and The Internet Software.
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
Developing an Algorithm
CPS120 Introduction to Computer Programming The Programming Process.
Algorithms CS139 – Aug 30, Problem Solving Your roommate, who is taking CS139, is in a panic. He is worried that he might lose his financial aid.
Chapter 6 Problem Solving and Algorithm Design Nell Dale John Lewis.
Chapter 6 Problem Solving and Algorithm Design. 2 Problem Solving Problem solving The act of finding a solution to a perplexing, distressing, vexing,
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
Chapter 6 Problem Solving and Algorithm Design. 2 Chapter Goals Apply top-down design methodology to develop an algorithm to solve a problem Define the.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
Lecture 13: 10/10/2002CS149D Fall CS149D Elements of Computer Science Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
2. Program Development Intro Programming in C++ Computer Science Dept Va Tech August 2001 ©2001 Barnette ND & McQuain WD 1 Top-Down Design:A solution method.
Data Structures Using C++ 2E
Software Engineering CS103 February 13, How Do You Solve Big Problems? Thousands of programmers Thousands of programmers Months or years of coding.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
A little hardware; a little software CS 139 – 08/29/07.
CSI 1340 Introduction to Computer Science II Chapter 1 Software Engineering Principles.
Chapter 6 Problem Solving and Algorithm Design. 2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
Chapter 4 ADT Sorted List. Sorted Type Class Interface Diagram SortedType class IsFull GetLength ResetList DeleteItem PutItem MakeEmpty GetItem Private.
Algorithms CS280 – 10/20/05. Announcement  Part 1 of project 2 due.  Read chapters 10, 7 for this unit  Tuesday we will also be in the classroom We.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Chapter 2 Principles of Programming and Software Engineering.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Low-Level Programming Languages, Pseudocode and Testing Chapter 6.
Algorithms Sept 4, Tuesday’s Lab You developed an algorithm Input – an 8 ½ x 11 inch piece of paper Audience – Fellow classmates Process – Instructions.
Algorithms and Problem Solving
C++ Plus Data Structures
About the Presentations
Object-Oriented Design
Chapter 1 Software Engineering.
PROBLEM SOLVING SKILLS
Problem Solving and Algorithm Design
Problem Solving and Algorithm Design
Programming We have seen various examples of programming languages
Algorithms and Problem Solving
Presentation transcript:

Algorithms and Problem Solving Mainly based on Chapter 6: “Problem Solving and Algorithm Design” from the Book: “Computer Science Illuminated” by Nell Dale and John Lewis.

Objectives Determine whether a problem is suitable for a computer solution Describe the computer problem-solving process and relate it to Polya’s How to Solve It list Distinguish between following an algorithm and developing one Apply top-down design methodology to develop an algorithm to solve a problem Apply the object-oriented design methodology to develop a collection of interacting objects to solve a problem

Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

Problem Solving G. Polya wrote How to Solve It: A New Aspect of Mathematical Method His How to Solve It list is quite general Written in the context of solving mathematical problems The list becomes applicable to all types of problems Polya "How to Solve It" (http://www.mste.uiuc.edu/courses/ci430fa01/students/ambailey/Problem solving now and then.html)          In 1945, mathematics professor George Polya wrote "How to Solve It", a guide on problem solving that still influences mathematics education today. Polya believed problem solving (although in "vogue" then) was not only not a new aspect of mathematics but also would have a definite place in the future. Polya did not use the phrase problem solving --- instead he talked about "studying the methods of solving problems." (vii) This method is a four-step process. The first step is understanding the problem. By being able to point out the relevant parts (the given data) and identify the unknown, the student has a base from which to begin. The student should proceed to the second step and formulate a plan based on the information in the first step and on any previous knowledge that he/she may possess which may help with the problem. Determining what previous knowledge will and will not be helpful makes this the hardest step. A second alternative is to consider if there is another problem similar to this one that the student knows how to solve. This may result in a few false starts that will not lead to the solution, which will in turn frustrate some students. The third step is to carry out the plan from step two and see if it does lead to the solution. If it does not, then the student will need to return to step two and use this last attempt to make a new plan. If it does work, the student would then proceed to step four, which is to look back. This step is usually characterized as checking your solution to guarantee that it makes sense with the information given in the problem. However, Polya stressed the importance of the student looking for a different way to solve the problem and thinking about other problems that could be solved in a similar fashion, with the final result being to create a variety of ways to solve problems and in turn becoming a better problem solver. Through problem solving, Polya hoped to alter the student's perception of mathematics so that the student would come to view mathematics as a puzzle to figure out (dare I say enjoy?) like a crossword and not simply adding and multiplying.         Polya emphasized that the solution is not the main focus of the process --- after all, a lucky guess could result in the right answer --- instead, it is the journey to the solution. If a student does not understand the problem, then they do not understand how, why, or even if their answer is correct which results in frustration and, in turn, poor problem solvers. Polya mentioned that the type of problem is important as well. For example, if the student were not interested or curious about the problem, then the student would not have the necessary inclination to understand or try the problem.

Problem Solving and Algorithms Ask questions to understand the problem Look for familiar things Divide and conquer Test your solution

Ask Questions... …to understand the problem What do I know about the problem? What is the information that I have to process in order the find the solution? What does the solution look like? What sort of special cases exist? How will I recognize that I have found the solution?

Look for Familiar Things You should never reinvent the wheel In computing, you see certain problems again and again in different guises A good programmer sees a task, or perhaps part of a task (a subtask), that has been solved before and plugs in the solution

Divide and Conquer Break up a large problem into smaller units that we can handle Applies the concept of abstraction The divide-and-conquer approach can be applied over and over again until each subtask is manageable

Algorithms An algorithm is defined as a finite set of steps, each of which may require one or more operations and if carried out on a set of inputs, will produce one or more outputs after a finite amount of time.

The Computer Problem-Solving Process

Pseudocode Uses a mixture of English and formatting to make the steps in the solution explicit

Following an Algorithm Preparing a Hollandaise sauce

Following an Algorithm (cont.) Preparing a Hollandaise sauce Page 150

Developing an Algorithm The plan must be suitable in a suitable form Two methodologies that are currently in use: Top-down design Object-oriented design

Top-Down Design Breaking the problem into a set of subproblems called modules Creating a hierarchical structure of problems and subproblems

Top-Down Design Figure 6.5 An example of top-down design This process continues for as many levels as it takes to expand every task to the smallest details A step that needs to be expanded is an abstract step

A General Example Planning a large party

A Computer Example Problem Create an address list that includes each person’s name, address, telephone number, and e-mail address This list should then be printed in alphabetical order The names to be included in the list are on scraps of paper and business cards

A Computer Example

A Computer Example

A Computer Example

A Computer Example

Testing the Algorithm The process itself must be tested Testing at the algorithm development phase involves looking at each level of the top-down design

Testing the Algorithm Desk checking: sit at a desk with a pencil and paper and work through the design Walk-through: Manual simulation of the design by the team members Take sample data values and simulate the design using the sample data Inspection: The design is handed out in advance, and one person (not the designer) reads the design line by line while the others point out errors

Object-Oriented Design Methodology Four stages to the decomposition process Brainstorming Filtering Scenarios Responsibility algorithms

CRC Cards

Brainstorming A group problem-solving technique that involves the spontaneous contribution of ideas from all members of the group All ideas are potential good ideas Think fast and furiously first, and ponder later A little humor can be a powerful force Brainstorming is designed to produce a list of candidate classes

Filtering Determine which are the core classes in the problem solution There may be two classes in the list that have many common attributes and behaviors There may be classes that really don’t belong in the problem solution

Scenarios Assign responsibilities to each class There are two types of responsibilities What a class must know about itself (knowledge) What a class must be able to do (behavior) Encapsulation is the bundling of data and actions in such a way that the logical properties of the data and actions are separated from the implementation details

Responsibility Algorithms The algorithms must be written for the responsibilities Knowledge responsibilities usually just return the contents of one of an object’s variables Action responsibilities are a little more complicated, often involving calculations

Computer Example Let’s repeat the problem-solving process for creating an address list Brainstorming and filtering Circling the nouns and underlining the verbs Page 171

Computer Example First pass at a list of classes Page 172

Computer Example Filtered list

CRC Cards

Responsibility Algorithms