PowerPoint Presentation

Published on Slideshow
Static slideshow
Download PDF version
Download PDF version
Embed video
Share video
Ask about this video

Scene 1 (0s)

[Audio] Lecture 13 & 14 MODULAR PROGRAMMING & PROBLEM SOLVING TECHNIQUES Pusat Asasi Sains, Universiti Malaya.

Scene 2 (11s)

[Audio] LEARNING OUTCOME: At the end of this topic, students should be able to: Identify input, process and output from a given problem. To analyze the problem using Problem Analysis Chart (PAC) Use an IPO chart to designate the input, processing, and output for a solution of a problem Solve problem using flow chart..

Scene 3 (35s)

[Audio] TYPES OF PROBLEMS IN NATURE ALGORITHMIC SOLUTIONS Solutions for the given problems can be reached by completing the series of action in steps ‘Computer dominated’ HEURISTIC SOLUTIONS Solutions require reasoning built on knowledge & experience with process of trial & error. ‘Human dominated’ as naturally having emotional factors, i.e. unsatisfactory & uncertainty. Innovation ~ Artificial Intelligence & fifth-generation languages (5GL)..

Scene 4 (1m 11s)

[Audio] Problem Solving. Problem Solving.

Scene 5 (1m 17s)

[Audio] . Input a list of data source provided to the problem Problem??? Separate into three components Output a list of the output required Processing a list of actions needed to produce the required outputs.

Scene 6 (1m 26s)

[Audio] Problem Solving in Programming Programming is a process of problem solving Problem solving techniques Analyze the problem Outline the problem requirements Specify what the solution should do Design steps, called an algorithm, to solve the problem (the general solution) Verify that your solution really solves the problem.

Scene 7 (1m 46s)

[Audio] Organising Problems Certain organisational tools can help us to solve problems :- Problem Analysis Charts – a beginning analysis of the problem Structure/Interactivity Charts – shows the overall layout or structure of the solution.

Scene 8 (2m 0s)

[Audio] Organising Problems IPO Chart – shows the input, the processing and the output Algorithm – show the sequence of instructions comprising the solution Flowcharts – graphic representations of the algorithms.

Scene 9 (2m 16s)

[Audio] What is PAC? PAC (Problem Analysis Chart) According to Sprankle and Hubbard, (2012), the initial step for a programs need to do when get a problem is to analyze and understand the requirements. To easily analyze the problem, a Problem Analysis Chart (PAC) was introduced. This chart have four section: — The given data — The required result — The processing involved — A list of solution alternative.

Scene 10 (2m 57s)

[Audio] Problem Analysis Chart (PAC) separates the problem in 4 parts Given Data Required Results Section 1:Data given in the problem or provided by user-Data, constants, variables Section 2:Requirements to produce the output-information and format required Processing required Solution alternatives Section 3:List of processing required – equations, or searching or sorting techniques Section 4: List of ideas for the solution..

Scene 11 (3m 27s)

[Audio] Example1: Write a Problem Analysis Chart (PAC) to convert any Number in distance in miles to kilometers per mile. (1mile = 1.609km) Given Data Required Results Processing required Solution alternatives.

Scene 12 (3m 49s)

[Audio] Example 2: Write a Problem Analysis Chart (PAC) to find an area of a circle where area = pi * radius * radius Given Data Required Results Processing required Solution alternatives.

Scene 13 (4m 7s)

[Audio] Example 3: Write a problem analysis chart (PAC) that asks a user to enter the distance of a trip in miles, the miles per gallon estimate for the user’s car, and the average cost of a gallon of gas. Calculate and display the number of gallons of gas needed and the estimated cost of the trip. Given Data Required Results Processing required Solution alternatives.

Scene 14 (4m 34s)

[Audio] . Try This!!! PROBLEM: A program is required to find the volume of a cube. Please construct the PAC for this problem. Given Data Processing Required Required Result Solution Alternative.

Scene 15 (4m 45s)

[Audio] . Extends information in PAC and modules in Have 4 parts What is IPO? IPO (Input — Processing - Output) Emphasizing the three components of problem (input, processing and output).

Scene 16 (4m 54s)

[Audio] Input Process Output (IPO) Analysis The IPO is used to analyze problems and develop algorithms Used to organize and summarize the results of a problem analysis It shows where in the solution the processing takes place.

Scene 17 (5m 14s)

[Audio] 2.Input Process Output (IPO) Analysis Represented using IPO chart Input Processing Output All input data (from Section 1 of the PAC) All processing steps (from sections 3 and 4 of the PAC) Processing items: All output requirements (from sections 1 and 2 of the PAC) Algorithm:.

Scene 18 (5m 42s)

[Audio] 2.Input Process Output (IPO) Analysis Input : Process : Output : To do the IPO Analysis, start with: Output (Display the results) Input (Read the data) Process (Perform the computation) Identify.

Scene 19 (6m 7s)

[Audio] 2. Input Process Output (IPO) Analysis Output should answer the following question: What does the user want to see printed on the printer, displayed on the screen, or stored in a file?.

Scene 20 (6m 23s)

[Audio] 2. Input Process Output (IPO) Analysis Input should answer the following question: What information will the computer need to know to print, display, or store the output items?.

Scene 21 (6m 39s)

[Audio] 2. Input Process Output (IPO) Analysis Processing item: An intermediate value that the algorithm uses when processing the input into the output.

Scene 22 (6m 53s)

[Audio] Analyze the Problem What is it you are trying to accomplish? What outcome you are trying to arrive at? List the Inputs and Outputs Often you work backwards from the Output List the Outputs, and then figure out what Inputs you need in order to arrive at the Output.

Scene 23 (7m 15s)

[Audio] Example1: Write an Input Process Output (IPO) to convert any Number in distance in miles to kilometers per mile. (1mile = 1.609km) Analyze the Problem Problem Analysis: Input: Process: Output:.

Scene 24 (7m 38s)

[Audio] IPO chart: Input Processing Output Processing items: Algorithm:.

Scene 25 (7m 47s)

[Audio] Example 2: Write an Input Process Output (IPO) to find an area of a circle where area = pi * radius * radius Analyze the Problem Problem Analysis: Input: Process: Output:.

Scene 26 (8m 8s)

[Audio] IPO chart: Input Processing Output Processing items: Algorithm:.

Scene 27 (8m 17s)

[Audio] Example 3: Write an Input Process Output (IPO) that asks a user to enter the distance of a trip in miles, the miles per gallon estimate for the user’s car, and the average cost of a gallon of gas. Calculate and display the number of gallons of gas needed and the estimated cost of the trip. Analyze the Problem Problem Analysis: Input: Process: Output:.

Scene 28 (8m 47s)

[Audio] IPO chart: Input Processing Output Processing items: Algorithm:.

Scene 29 (8m 56s)

[Audio] What is Flow Chart? Program flowcharts show the sequence of instructions in a single program or subroutine. Different symbols are used to draw each type of flowchart. A Flowchart shows logic of an algorithm emphasizes individual steps and their interconnections e.g. control flow from one action to the next.

Scene 30 (9m 19s)

[Audio] 3. Flow Chart Graphical representation of an algorithm. Special-purpose symbols connected by arrows (flow lines)..

Scene 31 (9m 31s)

[Audio] Four Flowchart Structures Sequence Selection Repetition Case.

Scene 32 (9m 38s)

[Audio] . Flowchart Symbols Terminal symbol - indicates the beginning and end points of an algorithm. Process symbol - shows an instruction other than input, output or selection. Input-output symbol - shows an input or an output operation. Disk storage 1/0 symbol - indicates input from or output to disk storage. Printer output symbol - shows hardcopy printer output..

Scene 33 (9m 54s)

[Audio] . O I Flowchart Symbols cont... Selection symbol - shows a selection process for two-way selection. Off-page connector - provides continuation of a logical path on another page. On-page connector - provides continuation of logical path at another point in the same page. Flow lines - indicate the logical sequence of execution steps in the algorithm..

Scene 34 (10m 10s)

[Audio] Sequence Structure a series of actions are performed in sequence The pay-calculating example was a sequence flowchart..

Scene 35 (10m 19s)

[Audio] Example1: Write a Flowchart to solve the problem of converting any Number in distance in miles to kilometers per mile. (1mile = 1.609km).

Scene 36 (10m 35s)

[Audio] Example 2: Write a Problem Analysis Chart (PAC) to find an area of a circle where area = pi * radius * radius pi - pi=22/7.

Scene 37 (10m 51s)

[Audio] Example 3: Write a problem analysis chart (PAC) that asks a user to enter the distance of a trip in miles, the miles per gallon estimate for the user’s car, and the average cost of a gallon of gas. Calculate and display the number of gallons of gas needed and the estimated cost of the trip..

Scene 38 (11m 20s)

[Audio] Selection Structure One of two possible actions is taken, depending on a condition..

Scene 39 (11m 29s)

[Audio] Selection Structure A new symbol, the diamond, indicates a yes/no question. If the answer to the question is yes, the flow follows one path. If the answer is no, the flow follows another path YES NO.

Scene 40 (11m 48s)

[Audio] Selection Structure In the flowchart segment below, the question “is x < y?” is asked. If the answer is no, then process A is performed. If the answer is yes, then process B is performed. YES NO x < y? Process B Process A.

Scene 41 (12m 7s)

[Audio] Selection Structure The flowchart segment below shows how a decision structure is expressed in C++ as an if/else statement. Flowchart C++ Code YES NO x < y? a= x + y a= x * 2 if (x < y) a = x * 2; else a = x + y;.

Scene 42 (12m 34s)

[Audio] Selection Structure The flowchart segment below shows a decision structure with only one action to perform. It is expressed as an if statement in C++ code. YES NO x < y? Calculate a as x times 2. if (x < y) a = x * 2;.

Scene 43 (12m 57s)

[Audio] Example1: Write a Flowchart to solve the problem of ADD two numbers if number One less than number Two and MULTIPLY two numbers if number One greater than number Two. Data Processing Output Processing item: Algorithm:.

Scene 44 (13m 16s)

[Audio] Repetition Structure A repetition structure represents part of the program that repeats. This type of structure is commonly known as a loop..

Scene 45 (13m 27s)

[Audio] Repetition Structure Notice the use of the diamond symbol. A loop tests a condition, and if the condition exists, it performs an action. Then it tests the condition again. If the condition still exists, the action is repeated. This continues until the condition no longer exists. Yes No.

Scene 46 (13m 54s)

[Audio] Repetition Structure In the flowchart segment, the question “is x < y?” is asked. If the answer is yes, then Process A is performed. The question “is x < y?” is asked again. Process A is repeated as long as x is less than y. When x is no longer less than y, the repetition stops and the structure is exited. x < y? Process A YES NO.

Scene 47 (14m 20s)

[Audio] Repetition Structure The flowchart segment below shows a repetition structure expressed in C++ as a while loop. Flowchart C++ Code while (x < y) x++; x < y? Add 1 to x YES NO.

Scene 48 (14m 42s)

[Audio] Controlling a Repetition Structure The action performed by a repetition structure must eventually cause the loop to terminate. Otherwise, an infinite loop is created. In this flowchart segment, x is never changed. Once the loop starts, it will never end. QUESTION: How can this flowchart be modified so it is no longer an infinite loop? x < y? Display x YES NO.

Scene 49 (15m 18s)

[Audio] Controlling a Repetition Structure ANSWER: By adding an action within the repetition that changes the value of x. x < y? Display x Add 1 to x YES NO.

Scene 50 (15m 33s)

[Audio] A Pre-Test Repetition Structure This type of structure is known as a pre-test repetition structure. The condition is tested BEFORE any actions are performed. NO.