Algorithms and Problem Solving

Slides:



Advertisements
Similar presentations
Algorithms.
Advertisements

Lecture 6: Software Design (Part I)
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Chapter 1 An Overview of Computers and Programming Languages.
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. 6-2 Chapter Goals Determine whether a problem is suitable for a computer solution Describe the computer.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
© Janice Regan Problem-Solving Process 1. State the Problem (Problem Specification) 2. Analyze the problem: outline solution requirements and design.
Algorithms and Problem Solving-1 Algorithms and Problem Solving Mainly based on Chapter 6: “Problem Solving and Algorithm Design” from the Book: “Computer.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
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
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 9: Algorithms and Pseudo-code.
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Chapter 6 Problem Solving and Algorithm Design Nell Dale John Lewis.
Programming Fundamentals (750113) Ch1. Problem Solving
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
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.
Fundamentals of Algorithms MCS - 2 Lecture # 1
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
CSE 219 Computer Science III Program Design Principles.
“The study of algorithms is the cornerstone of computer science.” Algorithms Fall 2011.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Design & Analysis of Algorithms Lecture 1 Introduction.
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
Data Structures Using C++ 2E
The Art of Programming. The process of breaking problems down into smaller, manageable parts By breaking the problem down, each part becomes more specific.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
 Problem Analysis  Coding  Debugging  Testing.
Principles of Programming & Software Engineering
ICS 3UI - Introduction to Computer Science
Lecture 1 Introduction Richard Gesick.
Chapter 1: An Overview of Computers and Programming Languages
CS101 Introduction to Computing Lecture 19 Programming Languages
Algorithm and Ambiguity
About the Presentations
Lecture 2 of Computer Science II
Algorithm Algorithm is a step-by-step procedure or formula or set of instruction for solving a problem Its written in English language or natural language.
Introduction to Computer Programming
Algorithm and Ambiguity
Object-Oriented Design
Chapter 1 Software Engineering.
Unit# 9: Computer Program Development
Problem Solving Techniques
PROBLEM SOLVING SKILLS
Chapter 5 Designing the Architecture Shari L. Pfleeger Joanne M. Atlee
Algorithm An algorithm is a finite set of steps required to solve a problem. An algorithm must have following properties: Input: An algorithm must have.
Objective of This Course
Chapter 5: Algorithms Computer Science: An Overview Tenth Edition
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Problem Solving Skill Area 305.1
Programming.
Algorithm and Ambiguity
Algorithms and Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Lecture 6 Architecture Algorithm Defin ition. Algorithm 1stDefinition: Sequence of steps that can be taken to solve a problem 2ndDefinition: The step.
Programming Fundamentals (750113) Ch1. Problem Solving
Basic Concepts of Algorithm
Computer Science: An Overview Tenth Edition
Presentation transcript:

Algorithms and Problem Solving

Lecture Objectives Problem Identification Problem Analysis Problem definition Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development Become aware of problem solving process

A problem can be regarded as a difference between the actual situation and the desired situation. This means that in order to identify a problem we must know where it is meant to be and have a clear understanding of where it currently is in relation to the perceived problem.

Problem Solving Programming is a process of problem solving Problem solving techniques Analyze the problem Outline the problem requirements Design steps (algorithm) to solve the problem Algorithm: Step-by-step problem-solving process Solution achieved in finite amount of time

Problem Solving Process Step 1 - Analyze the problem Outline the problem and its requirements Design steps (algorithm) to solve the problem Step 2 - Implement the algorithm Implement the algorithm in code Verify that the algorithm works Step 3 - Maintenance Use and modify the program if the problem domain changes

Analyze the Problem Thoroughly understand the problem Understand problem requirements Does program require user interaction? Does program manipulate data? What is the output? If the problem is complex, divide it into subproblems Analyze each subproblem as above

What is an algorithm? The idea behind the computer program Stays the same independent of Which kind of hardware it is running on Which programming language it is written in Solves a well-specified problem in a general way Is specified by Describing the set of instances (input) it must work on Describing the desired properties of the output

What is an algorithm? (Cont’d) Before a computer can perform a task, it must have an algorithm that tells it what to do. Informally: “An algorithm is a set of steps that define how a task is performed.” Formally: “An algorithm is an ordered set of unambiguous executable steps, defining a terminating process.” Ordered set of steps: structure! Executable steps: doable! Unambiguous steps: follow the directions! Terminating: must have an end!

Important Properties of Algorithms Correct always returns the desired output for all legal instances of the problem. Unambiguous Precise Efficient Can be measured in terms of Time Space Time tends to be more important

Representation of Algorithms A single algorithm can be represented in many ways: Formulas: F = (9/5)C + 32 Words: Multiply the Celsius by 9/5 and add 32. Flow Charts. Pseudo-code. In each case, the algorithm stays the same; the implementation differs!

Representation of Algorithms (Cont’d) A program is a representation of an algorithm designed for computer applications. Process: Activity of executing a program, or execute the algorithm represented by the program  Process: Activity of executing an algorithm.

Expressing Algorithms English description Pseudo-code High-level programming language More precise More easily expressed

Pseudocode Pseudocode is like a programming language but its rules are less stringent. Written as a combination of English and programming constructs Based on selection (if, switch) and iteration (while, repeat) constructs in high-level programming languages Design using these high level primitives Independent of actual programming language

Pseudocode (Cont’d) Example: The sequential search algorithm in pseudocode

Algorithm Discovery The Two Steps of Program Development: 1. Discover the algorithm. 2. Represent the algorithm as a program. Step 2 is the easy step! Step 1 can be very difficult! To discover an algorithm is to solve the problem!

Problem Solving: A creative process Problem solving techniques are not unique to Computer Science. The CS field has joined with other fields to try to solve problems better. Ideally, there should be an algorithm to find/develop algorithms. However, this is not the case as some problems do not have algorithmic solutions. Problem solving remains an art!

Problem Solving Strategies Working backwards Reverse-engineer Once you know it can be done, it is much easier to do What are some examples? Look for a related problem that has been solved before Java design patterns Sort a particular list such as: David, Alice, Carol and Bob to find a general sorting algorithm Top Down Design/Stepwise Refinement Break the problem into several sub-problems Solve each subproblem separately Produces a modular structure Bottom up Progression from the individual elements to the whole K.I.S.S. = Keep It Simple Stupid!

Stepwise Refinement Stepwise refinement is a top-down methodology in that it progresses from the general to the specific. Bottom-up methodologies progress from the specific to the general. These approaches complement each other Solutions produced by stepwise refinement posses a natural modular structure - hence its popularity in algorithmic design.

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

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