Problem Solving Concepts

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

ALGORITHMS AND FLOWCHARTS
Summer ’12 AP Computer Science APCS Summer Assignments Read thoroughly this ppt and solve examples 6 and 7.
ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
ALGORITHMS AND FLOWCHARTS
Programming Fundamentals (750113) Ch1. Problem Solving
Developing logic (Examples on algorithm and flowchart)
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Review Algorithm Analysis Problem Solving Space Complexity
Fundamentals of C programming
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Planning for the Solution
CSC141 Introduction to Computer Programming
Software Life Cycle What Requirements Gathering, Problem definition
Algorithm & Flow Charts
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Flowcharting & Algorithms. Quick. Close your Eyes and Listen You are still sitting in the classroom. However, you have been called to the counselor’s.
1 Program Planning and Design Important stages before actual program is written.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Concepts of Algorithms CSC-244 Unit Zero Pseudo code, Flowchart and Algorithm Master Prince Computer College Qassim University K.S.A.
Problem, Problem Solving, Algorithm & Flow Charts –Part 1 Presented By Manesh T Course:101 CS 101CS Manesh T1.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Introduction to Flowcharts
Let’s Play Tes Kelemotan Otak.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
 Problem Analysis  Coding  Debugging  Testing.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Program design Program Design Process has 2 phases:
1. Computational Thinking
Problem Solving & Computer Programming
ALGORITHMS AND FLOWCHARTS
GC101 Introduction to computers and programs
Algorithm & Flow Charts Week 1
Programming Languages
Unit 3: ALGORITHMS AND FLOWCHARTS
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
Algorithm & Programming
ALGORITHMS AND FLOWCHARTS
FLOWCHARTS.
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Algorithms and Flowcharts
Lecture 2 Introduction to Programming
Introduction To Flowcharting
Introduction to Computer Programming
Programming Fundamentals
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
Programming Fundamentals (750113) Ch1. Problem Solving
1) C program development 2) Selection structure
Algorithm Discovery and Design
ALGORITHMS AND FLOWCHARTS
Introduction to Algorithms and Programming
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Flowcharting & Algorithms
Flowcharts and Pseudo Code
ICT Gaming Lesson 2.
Introduction to Programming
Basic Concepts of Algorithm
Presentation transcript:

Problem Solving Concepts Dr. Munesh Singh

POINTS TO BE DISCUSSED: What is mean by data, information, data structure What is a problem?-Types of problems Problem Solving in everyday life. Six steps for general problem solving Problem solving concepts for computers Organising Problems Problem Analysis Charts Structure/Interactivity Charts, IPO Chart Algorithm, Flowcharts, Internal and External documentation

Review of Data Structure Data is raw Unorganized facts that needs to be processed Data can be simple and seamlessly random Useless until it is organized Example: Student record is one piece of data Information When data is processed Organized or structured Presented in a given context to make it useful

Review of Data Structure Data Type: a data type or simply type is a classification identifying one of various types of data: Real-valued Integer Boolean determines the possible values for that type the operations that can be done on values of that type the meaning of the data the way values of that type can be stored. Data Structure: a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

Types of Data Structures

What is a Problem? A state of difficulty that needs to be resolved Problems exist where goals need to be attained and there is uncertainty about solution A Problem is an opportunity for improvement A problem is the difference between your current state and your goal state

Problem Faced in Everyday in Life People make decisions everyday Examples: Should I wear casual or formal today? Should I watch TV or go out to cinema? what career? what course? What shoes? Everything needs a DECISION AS A SOLUTION TO THE PROBLEM

What happens when bad decisions are made? WASTAGE OF TIME AND RESOURCES

Six steps to ensure a Best decision in PROBLEM SOLVING 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

Take the problem of what to do to get solution A Water Jug Problem: You are given two jugs, a 4-gallon one and a 3-gallon one, a pump which has unlimited water which you can use to fill the jug, and the ground on which water may be poured. Neither jug has any measuring markings on it. How can you get exactly 2 gallons of water in the 4-gallon jug?

Problem Steps To solve this we have to make some assumptions not mentioned in the problem. They are 1. We can fill a jug from the pump. 2. we can pour water out of a jug to the ground. 3. We can pour water from one jug to another. 4. There is no measuring device available.

What I am Expecting How to approach this problem in terms traditional way. Hint. Input, output, and logic How to Map this problem in computer language Which kind of Data Structure you need to Solve this problem efficiently This problem is heuristic or Algorithmic. how many solution of this problem. And which one is the best solution with reason

First Solutions of the Problem

Second and Third Solution

Data structure for above problem Graph will be the data structure to solve this problem BFS (Breadth first search) DFS (Depth first search)

Another Problem On one bank of a river are three missionaries and three cannibals. There is one boat available that can hold up to two people and that they would like to use to cross the river. If the cannibals ever outnumber the missionaries on either of the river’s banks, the missionaries will get eaten.  How can the boat be used to safely carry all the missionaries and cannibals across the river?

TIC-TAC-TOE Problem

Approaches to solve a problem: Algorithmic : Solutions that can be solved with a series of known actions are called Algorithmic Solutions Heuristic : Employing a self-learning approach to the solution of a problems is known as Heuristic Solutions

Examples Algorithmic solution: To make a cup of coffee To find largest of three numbers Heuristic solutions: how to buy the best stock? How to play chess?

Problem solving with computers Computers use algorithmic solutions Program – set of instructions that make up solution to a problem Results – outcome of running the program Testing – Are the outcomes what you expected and correct Documentation – two types manual documentation instructions telling users how to use the program

Problem solving with computers involves several steps Clearly define the problem. Analyze the problem and formulate a method to solve it (see also .validation.). Describe the solution in the form of an algorithm. Draw a flowchart of the algorithm. Write the computer program. Compile and run the program (debugging). Test the program (debugging) (see also verification.). Interpretation of results.

ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution of problem this sequence of steps is called an algorithm Implementation phase implement the program in some programming language

Steps in Problem Solving First produce a general algorithm (one can use pseudo code) Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language. Pseudo code is an artificial and informal language that helps programmers develop algorithms. Pseudo code is very similar to everyday English.

Pseudo code & Algorithm Example 1: Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks.

Pseudo code & Algorithm Input a set of 4 marks Calculate their average by summing and dividing by 4 if average is below 50 Print “FAIL” else Print “PASS”

Pseudocode & Algorithm Detailed Algorithm Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4 Step 3: if (GRADE < 50) then Print “FAIL” else Print “PASS” endif

The Flowchart (Dictionary) A schematic representation of a sequence of operations, as in a manufacturing process or computer program. (Technical) A graphical representation of the sequence of operations in an information system or program. Information system flowcharts show how data flows from source documents through the computer to final distribution to users. Program flowcharts show the sequence of instructions in a single program or subroutine. Different symbols are used to draw each type of flowchart.

The Flowchart A Flowchart shows logic of an algorithm emphasizes individual steps and their interconnections e.g. control flow from one action to the next

Flowchart Symbols Basic

Example 1 START Input M1,M2,M3,M4 GRADE(M1+M2+M3+M4)/4 IS GRADE<50 PRINT “FAIL” STOP Y N PRINT “PASS”

Example 2 Write an algorithm and draw a flowchart to convert the length in feet to centimeter. Pseudo code: Input the length in feet (Lft) Calculate the length in cm (Lcm) by multiplying LFT with 30 Print length in cm (LCM)

Flowchart

Example 3 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Pseudocode Input the width (W) and Length (L) of a rectangle Calculate the area (A) by multiplying L with W Print A

Algorithm Step 1: Input W,L Step 2: A  L x W Step 3: Print A

Example 4 Write an algorithm and draw a flowchart that will calculate the roots of a quadratic equation Hint: d = sqrt ( ), and the roots are: x1 = (–b + d)/2a and x2 = (–b – d)/2a

Pseudo code: Input the coefficients (a, b, c) of the quadratic equation Calculate d Calculate x1 Calculate x2 Print x1 and x2

Algorithm: Step 1: Input a, b, c Step 2: d  sqrt ( ) Step 3: x1  (–b + d) / (2 x a) Step 4: x2  (–b – d) / (2 x a) Step 5: Print x1, x2 START Input a, b, c d  sqrt(b x b – 4 x a x c) Print x1 ,x2 STOP x1 (–b + d) / (2 x a) X2  (–b – d) / (2 x a)

DECISION STRUCTURES The expression A>B is a logical expression it describes a condition we want to test if A>B is true (if A is greater than B) we take the action on left print the value of A if A>B is false (if A is not greater than B) we take the action on right print the value of B

DECISION STRUCTURES

IF–THEN–ELSE STRUCTURE The structure is as follows: If condition then true alternative else false alternative endif

IF–THEN–ELSE STRUCTURE The algorithm for the flowchart is as follows: If A>B then print A else print B endif

Relational Operators

Example 5 Write an algorithm that reads two values, determines the largest value and prints the largest value with an identifying message. ALGORITHM Step 1: Input VALUE1, VALUE2 Step 2: if (VALUE1 > VALUE2) then MAX  VALUE1 else MAX  VALUE2 endif Step 3: Print “The largest value is”, MAX

NESTED IFS One of the alternatives within an IF–THEN–ELSE statement may involve further IF–THEN–ELSE statement

Example 6 Write an algorithm that reads three numbers and prints the value of the largest number.

A program that is easy to read & understand, and therefore, easy to maintain & enhance readable program?

A program with correct syntax & semantics correct program?

PPT you will get on the link https://shodhkarya.blogspot.in/ Queries ? PPT you will get on the link https://shodhkarya.blogspot.in/

ThanksYou