70 likes | 243 Views
Problem solving Procedures. Flowcharts, pseudocode. What are Flowcharts, pseudo-code used for in solving problems?. A six-step problem solving procedure :. Problem identification.
E N D
Problem solving Procedures Flowcharts, pseudocode
What are Flowcharts, pseudo-code used for in solving problems? A six-step problem solving procedure: Problem identification Algorithm – a finite sequence of steps arranged in a specific logical order to produce the solution to a problem. Problem analysis Algorithm design Flow chart and pseudo-code are two common ways to design and represent algorithms in details. Developing a solution Debugging and testing Documentation
Flow chart • Schematic representation of an algorithm or a stepwise process • Showing the steps as boxes of various kinds, and their order by connecting these with arrows. • Used in designing or documenting a process or program. • The two most common types of boxes in a flowchart:a processing step (usually called activity, and denoted as a rectangular box) a decision (usually denoted as a diamond)
Examples A flowchart forcalculating N!(factorial N)
Pseudo-code • Informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language • Intended for human reading rather than machine reading. • Easier to understand • Pseudo-code typically omits details that are not essential for human understanding of the algorithm • No standard for pseudo-code syntax exists • Commonly used • in textbooks • in scientific publications that are documenting various algorithms • in planning of computer program development • for sketching out the structure of the program before the actual coding takes place.
Examples Regular code written in PHP: <?php if (is_valid($cc_number)) { execute_transaction($cc_number, $order); } else { show_failure(); } ?> Pseudo-code: if credit card number is valid then execute transaction based on number and order else show a generic failure message end if
Start Flow chart: Find H.C.F. Input x, y Pseudo-code: Input x and y IF y is larger than x THEN swap x and y END IF r=remainder of x/y WHILE R<>0 BEGIN x=y y=r r=remainder of x/y END Output y y>x? Yes Swap x, y No R=remainder of x ÷ y R=0? No x=y y=r Yes Output y as H.C.F. End