This action might not be possible to undo. Are you sure you want to continue?

Lecture Objectives

• Learn about problem solving skills

**• Explore the algorithmic approach for problem solving
**

• Learn about algorithm development • Become aware of problem solving process

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 .Maintenance Use and modify the program if the problem domain changes .Implement the algorithm Implement the algorithm in code Verify that the algorithm works • Step 3 .

divide it into subproblems Analyze each subproblem as above .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.

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 .

” Ordered set of steps: structure! Executable steps: doable! Unambiguous steps: follow the directions! Terminating: must have an end! . defining a terminating process.” • Formally: “An algorithm is an ordered set of unambiguous executable steps.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.

What is an algorithm? (Cont’d) .

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

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. the implementation differs! . Pseudo-code. the algorithm stays the same. • In each case. Flow Charts.

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 More easily expressed More • Pseudo-code precise • High-level programming language .

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

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

2.Algorithm Discovery • The Two Steps of Program Development: 1. 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! . Discover the algorithm.

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

Problem Solving Strategies • Working backwards Reverse-engineer Once you know it can be done.S. Carol and Bob to find a general sorting algorithm • Stepwise Refinement Break the problem into several sub-problems Solve each subproblem separately Produces a modular structure • K.I. 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. = Keep It Simple Stupid! .S.

. • Bottom-up methodologies progress from the specific to the general.Stepwise Refinement • Stepwise refinement is a top-down methodology in that it progresses from the general to the specific. 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 .

Class-Responsibility-Collaboration (CRC) Cards .

and ponder later A little humor can be a powerful force • Brainstorming is designed to produce a list of candidate classes .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.

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 .

often involving calculations .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.

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

Computer Example (Cont’d) • First pass at a list of classes .

Computer Example (Cont’d) • Filtered list .

CRC Cards .

Responsibility Algorithms .

- Future Cache Design
- Contract4J for Design by Contract in Java Design Pattern-Like Protocols and Aspect Interfaces
- Most IMP Questions Part-I
- 175 PMP Sample Questions
- wiegers-spitraps
- Unterkalmsteiner 2011 Tse Spi Sysrev
- Team Software Process
- Mcqs on Cmmi
- Introducing Php
- MA Form Private A4 Combined
- Basic Electronics
- بکرے کا گوشت آدھا کلو
- Three Days to See
- Helen Keller the Day Language
- Arabi Ka Muallim Vol-2
- TG_TG_9780195471397
- Practice Set 7
- Synonyms Bank 2
- graphstructures2(1)
- Lecture 5 MATLAB Programming (3)
- Bit Oriented Protocols
- module4-0
- simulink
- Matlab Tutorial
- Count Up or Down Through Specified Range of Numbers - Simulink

Sign up to vote on this title

UsefulNot usefulAlgorithms and Problem Solving can be easily understand by these slides.

Algorithms and Problem Solving can be easily understand by these slides.

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.