Presentation is loading. Please wait.

Presentation is loading. Please wait.

Let’s Play Tes Kelemotan Otak.

Similar presentations


Presentation on theme: "Let’s Play Tes Kelemotan Otak."— Presentation transcript:

1 Let’s Play Tes Kelemotan Otak

2 Aturannya Jawab spontan, jangan kelamaan mikir Baca satu demi satu
Konsentrasi

3 Permainan konsentrasi warna
... mulai

4 Kertas HVS warnanya apa?
Awan warnanya apa? Tissu warnanya apa? Sapi minum apa?

5 Yang ngejawab susu konsentrasi kamu terganggu, karena sapi minum air

6 Rambut warnanya apa? Alis warnanya apa? Aspal warnanya apa? Kelelawar tidurnya kapan?

7 Yang menjawab malam, artinya konsentrasinya tergganggu, karena kelelawar tidur siang hari

8 Warna cendol apa? Daun kelapa warnanya apa? Warna umum rumput? Jerapah makan apa?

9 Yang jawab rumput, itu salah, karena Jerapah makan daun.

10 Ayo ngaku salah berapa? Pasti senyum sendiri Smile ini berguna untuk otak mu

11 Problem Solving Techniques and Algorithm
Bla bla bla bla Problem Solving Techniques and Algorithm (c) Khaeroni, S.Si, M.Si

12 Representation Method (Algorithm)

13 Objective After this topic, students will be able to
Knowing basic principles on algorithm Create an algorithm for several cases Represent an algorithm into pseudocode and flowchart

14 discuss There are two pails of paint with different color. One is red and the other is blue. If you want to switch the contain of this two different pails, determine your step(s)!

15

16 Overview Algorithms are basically a set of instructions that, if correct and if followed carefully, produce some desired result Since they are sets of instructions, they are generally presented in such a way that that the step-by-step nature of how they should be followed is readily apparent The two most common representations are pseudocode and flowcharts

17 WORK IN GROUP Determine what is the best steps to solve a problem given You just only have 3 minutes Check/test your work

18 Good Algorithm Correctness : True, output like as desired (efectivity)
Amount of work done : Number of work, choose the smallest (eficiency) –> Complexity of Algorithm Amount of space use : Number of memory used (eficiency) Simplicity/Clarity : Simple, easy to verify Optimality : The best of working class, F(n) = W(n) (W : Worst)

19 PHASE of PROGRAMMING Computer programming can be divided into two phases: Problem solving phase Make an ordered sequence of steps that solves a problem these sequence of steps is called an algorithm Implementation phase implement using a programming language

20 Pseudocode A hybrid mixture of programming language and English for defining algorithms Independent of any programming language so it can be easily converted to any programming language

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

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

23 YOUR JOB Write your algorithm in pseudocode

24 The Flowchart A Flowchart is another algorithm but graphical
shows logic solution emphasizes individual steps and their interconnections A flowchart must have a start and stop A steps in a flowchart must connect. Can’t leave a step “hanging” with no connection. e.g. control flow from one action to the next

25 Flowchart Symbols Flowchart Symbol Explanation
Taken from Problem solving and programming concepts / Maureen Sprankle, Jim Hubbard. — 9th ed, 2012 Flowchart Symbol Explanation Flowlines are indicated by straight lines with optional arrows to show the direction of data flow. The arrowhead is necessary when the flow direction might be in doubt. Flowlines are used to connect blocks by exiting from one and entering another. Flattened ellipses indicate the start and the end of a module. An ellipse uses the name of the module at the start. The end is indicated by the word end or stop for the top or Control module and the word exit for all other modules. A start has no flowlines entering it and only one exiting it; an end or exit has one flowline entering it but none exiting it.

26 Flowchart Symbols Taken from Problem solving and programming concepts / Maureen Sprankle, Jim Hubbard. — 9th ed, 2012 Flowchart Symbol Explanation The rectangle indicates a processing block, for such things as calculations, opening and closing files, and so forth. A processing block has one entrance and one exit. The parallelogram indicates input to and output from the computer memory. An input/output (I/O) block has one entrance and only one exit.

27 Flowchart Symbols Taken from Problem solving and programming concepts / Maureen Sprankle, Jim Hubbard. — 9th ed, 2012 Flowchart Symbol Explanation The diamond indicates a decision. It has one entrance and two and only two exits from the block. One exit is the action when the resultant is True and the other exit is the action when the resultant is False. Rectangles with lines down each side indicate the process of modules.They have one entrance and only one exit.

28 Flowchart Symbols Taken from Problem solving and programming concepts / Maureen Sprankle, Jim Hubbard. — 9th ed, 2012 Flowchart Symbol Explanation The polygon indicates a loop with a counter. The counter starts with A (the beginning value) and is incremented by S (the incrementor value) until the counter is greater than B (the ending value). Counter is a variable. A, B, and S may be constants, variables, or expressions.

29 Flowchart Symbols Taken from Problem solving and programming concepts / Maureen Sprankle, Jim Hubbard. — 9th ed, 2012 Flowchart Symbol Explanation Flowchart sections can be connected with two different symbols. The circle connects sections on the same page, and the home base plate connects flowcharts from page to page. Inside these two symbols the programmer writes letters or numbers. The on-page connector uses letters inside the circle to indicate where the adjoining connector is located. An A connects to an A, a B to a B, etc. The off-page connectors use the page number where the next part or the previous part of the flowchart is located. This allows the reader to easily follow the flowchart. On- and off-page connectors will have either an entrance or an exit.

30 YOUR JOB Flowchart: Draw the flowchart of the previous algorithm.

31

32

33

34

35

36 Example Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4
START Input M1,M2,M3,M4 GRADE(M1+M2+M3+M4)/4 IS GRADE<60 PRINT “FAIL” STOP Y N Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4 Step 3: if (GRADE < 60) then Print “FAIL” else Print “PASS” endif PRINT “PASS”

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

38 Example Flowchart Algorithm Step 1: Input Lft Step 2: Lcm  Lft x 30
Step 3: Print Lcm START Input Lft Lcm  Lft x 30 Print Lcm STOP

39 Example 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

40 Example Algorithm Step 1: Input W,L Step 2: A  L x W Step 3: Print A
START Input W, L A  L x W Print A STOP

41 Example 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

42 Example Pseudocode: Input the coefficients (a, b, c) of the quadratic equation Calculate d Calculate x1 Calculate x2 Print x1 and x2

43 Example 4 Algorithm: Step 1: Input a, b, c Step 2: d  sqrt ( )
START 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 Input a, b, c d  sqrt(b x b – 4 x a x c) x1 (–b + d) / (2 x a) X2  (–b – d) / (2 x a) Print x1 ,x2 STOP

44 YOUR JOB Flowchart: Draw the flowchart of the previous algorithm.

45 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

46 DECISION STRUCTURES is A>B Y N Print A Print B

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

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

49 Relational Operators Operator Description Relational Operators >
Greater than < Less than = Equal to Greater than or equal to Less than or equal to Not equal to

50 Your flowchart Write an algorithm that reads three 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

51 “The largest value is”, MAX
Example START Input VALUE1,VALUE2 Y N is VALUE1>VALUE2 MAX  VALUE1 MAX  VALUE2 Print “The largest value is”, MAX STOP

52 nested if statements One of the alternatives within an
IF–THEN–ELSE statement may involve further IF–THEN–ELSE statement

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

54 Example 6 Step 1: Input N1, N2, N3 Step 2: if (N1>N2) then
MAX  N1 [N1>N2, N1>N3] else MAX  N3 [N3>N1>N2] endif if (N2>N3) then MAX  N2 [N2>N1, N2>N3] MAX  N3 [N3>N2>N1] Step 3: Print “The largest number is”, MAX

55 YOUR JOB Flowchart: Draw the flowchart of the previous algorithm.

56 CUL8R


Download ppt "Let’s Play Tes Kelemotan Otak."

Similar presentations


Ads by Google