Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Computing Lecture 00: Part 3 Introduction to Algorithms and Flowcharts (continued) Introduction to Computing Lecture 00: Part 3 Introduction.

Similar presentations


Presentation on theme: "Introduction to Computing Lecture 00: Part 3 Introduction to Algorithms and Flowcharts (continued) Introduction to Computing Lecture 00: Part 3 Introduction."— Presentation transcript:

1 Introduction to Computing Lecture 00: Part 3 Introduction to Algorithms and Flowcharts (continued) Introduction to Computing Lecture 00: Part 3 Introduction to Algorithms and Flowcharts (continued) Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical&Electronics Engineering nukhet.ozbek@ege.edu.tr

2 Expressing Algorithms Natural Languages Natural Languages Pseudocode Pseudocode Flowcharts Flowcharts Programming Languages Programming Languages

3 Natural Language Algorithm Cilbir 6 eggs 6 eggs ½ kg yogurt ½ kg yogurt 3 large garlic cloves 3 large garlic cloves 4 Tbs fresh butter 4 Tbs fresh butter 1 tsp red pepper, coarsely ground 1 tsp red pepper, coarsely ground 2 middle-sized onions cut horizontally 2 middle-sized onions cut horizontally plenty water plenty water Boil water in a fairly big pot. Break one by one the eggs and pour them in a plate, being careful not to break the yolk. To ensure a homogenous cooking, let them “glide” from the plate into the boiling water. Within three minutes the eggs are ready but if you prefer hard-boiled, allow them to cook for another minute or so. Boil water in a fairly big pot. Break one by one the eggs and pour them in a plate, being careful not to break the yolk. To ensure a homogenous cooking, let them “glide” from the plate into the boiling water. Within three minutes the eggs are ready but if you prefer hard-boiled, allow them to cook for another minute or so. Meanwhile brown the butter in a skillet and add the garlic and onion. In the last possible moment add the coarsely ground red pepper and turn off the fire. Remove the eggs from the pot using a skimmer and place them in a deep plate. Meanwhile brown the butter in a skillet and add the garlic and onion. In the last possible moment add the coarsely ground red pepper and turn off the fire. Remove the eggs from the pot using a skimmer and place them in a deep plate. Cover the eggs with plenty of yogurt and pour the hot butter over them. Serve immediately. Cover the eggs with plenty of yogurt and pour the hot butter over them. Serve immediately. From www.gourmet.gr

4 Pseudocode Algorithm Example Set moveCount to 1 FOR each row on the board FOR each column on the board FOR each column on the board IF gameBoard position (row, column) is occupied THEN IF gameBoard position (row, column) is occupied THEN CALL findAdjacentTiles with row, column CALL findAdjacentTiles with row, column INCREMENT moveCount INCREMENT moveCount END IF END IF END FOR END FOR END FOR

5 Algorithm Example Set number counter to zero Set sum to zero While (number counter < 10) { input a number Sum = Sum + Number increment number counter by 1 } Calculate average = sum / 10

6 Labwork 1 Write an algorithm to calculate the area of circle Write an algorithm to calculate the area of circle

7 Labwork 1 Input radius Set pi = 3.14 Calculate area = pi * radius * radius

8 Labwork 2 Write an algorithm to calculate the sum of multiples of 3 up to 100 Write an algorithm to calculate the sum of multiples of 3 up to 100

9 Labwork 2 Set number counter to zero Set sum to zero While (number counter < 100) { Sum = Sum + Number counter increment number counter by 3 }

10 Flowcharts Flowcharts are schematic representations of processes Flowcharts are schematic representations of processes Generally the start point, end points, inputs, outputs, possible paths and the decisions that lead to these possible paths are included Generally the start point, end points, inputs, outputs, possible paths and the decisions that lead to these possible paths are included Flow-charts can be created by hand or manually in most office software, but lately specialized diagram drawing software has emerged that can also be used for the purpose Flow-charts can be created by hand or manually in most office software, but lately specialized diagram drawing software has emerged that can also be used for the purpose

11 Flowchart Symbols (Mostly Used) Start / End symbol Start / End symbol Arrows Arrows Processing steps Processing steps Input/Output Input/Output Conditional (Decision) Conditional (Decision)

12 Flowchart Symbols (Others) Document Document Magnetic Tape Magnetic Tape Display Display Manual Input Manual Input

13 Flowchart Example From wikipedia.org

14 Flowchart Example From smartdraw.com

15 Flowchart Example Read NAME, BALANCE, RATE Compute INTEREST as BALANCE x RATE Write (Display) NAME and INTEREST

16 Flowchart Example From wikipedia.org

17 Flowchart Example START Input N Sum =0 C = 0 Input number Sum = Sum + number C = C + 1 C = N? A = Sum / N END No Yes Print A

18 Labwork 3 Draw a flowchart to find the sum of first 50 counting numbers Draw a flowchart to find the sum of first 50 counting numbers

19 Labwork 3

20 Labwork 4 Draw a flowchart to find the largest of three numbers A,B, and C. Draw a flowchart to find the largest of three numbers A,B, and C.

21 Labwork 5 Draw a flowchart to find the product of two numbers using only addition operation Draw a flowchart to find the product of two numbers using only addition operation

22 Labwork 5

23 Labwork 6 Draw a flowchart to find the division of two integer numbers using only subtraction operation. Find the division and remainder. Draw a flowchart to find the division of two integer numbers using only subtraction operation. Find the division and remainder.

24 Labwork 6

25 Summary Problem Solving Process Problem Solving Process Algorithms Algorithms Components of Algorithms Components of Algorithms Flowcharts Flowcharts


Download ppt "Introduction to Computing Lecture 00: Part 3 Introduction to Algorithms and Flowcharts (continued) Introduction to Computing Lecture 00: Part 3 Introduction."

Similar presentations


Ads by Google