UCEST105 M2 Ktunotes - in

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

ALGORITHMIC THINKING WITH PYTHON

Prof. Sarju S
15 October 2024

Downloaded from Ktunotes.in


Module 2

Page 2
Downloaded from Ktunotes.in
Module 2

► ALGORITHM AND PSEUDOCODE REPRESENTATION:- Meaning and Definition of


Pseudocode, Reasons for using pseudocode, The main constructs of pseudocode -
Sequencing, selection (if-else structure, case structure) and repetition (for, while,
repeat-until loops), Sample problems

► FLOWCHARTS :- Symbols used in creating a Flowchart - start and end, arithmetic


calculations, input/output operation, decision (selection), module name (call), for loop
(Hexagon), flow-lines, on-page connector, off-page connector.

Page 3 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

Page 4
Downloaded from Ktunotes.in
Flowchart

► Flowcharts use standardized symbols to visually


represent various aspects of an algorithm or a
process.

► Terminator : A terminator symbol is used to START


represent the beginning and end of an algorithm
STOP

► Connector Lines: Connector lines are used to


connect symbols in the flowchart.
► The direction of the arrow indicates the next step.

Page 5 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► Process: A process symbol : represents an activity. Process


It represents a particular step of an algorithm.
► The symbol contains text which describes the step.
Sum = Number1+ Number2 Example

► Data: A data symbol represents data used in the


algorithm. It is also used to represent the input
and output
Examples
► The symbol contains text which describes the step.
Read
► Multiple inputs can be read or multiple data can be Number1
initialised in the same symbol

Count =0

Page 6 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► Decision: A symbol used to branch into different


steps based on condition
► Based on whether the condition succeeds or fails,
connector lines connect to different points in the
flowchart.
Count TRUE
<10

FALSE

► On page and Off Page References: Symbols used


when the entire flowchart cannot fit on the same A P2
page fully.
On page
Off page
Reference
Reference

Page 7 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► Rectangle with vertical side-lines denotes a


module. A module is a collection of statements
written to achieve a task. It is known by the name
function in the programming domain.

► Hexagon denotes a for loop. The symbol shown


here is the representation of the loop: for count =
A to B by S.

Page 8 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► Problem 2.1 To find simple interest.

Page 9 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► Problem 2.2 To determine the larger of two numbers.

Page 10 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► To determine the smallest of three numbers.

Page 11 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► To determine the entry-ticket fare in a zoo based on age as follows:

Page 12 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► To print the colour based on a code value as follows:

Page 13 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► To find the factorial of a number


Solution: The factorial of a number n is defined as n! = n×n−1×· · · · · ·×2×1.

Page 14 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► To find the factorial of a number


Solution: The factorial of a number n is defined as n! = n×n−1×· · · · · ·×2×1.

Page 15 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Flowchart

► To find the average height of boys and average height of girls in a class
of n students.

Page 16 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
References

► https://www.scaler.com/topics/how-to-write-pseudo-code/
► Algorithmic Thinking with Python – Ajeesh Ramanujan, Narasimhan T

Page 17 Prof. Sarju S, Department of Computer Science and Engineering, SJCET Palai
Downloaded from Ktunotes.in
Thank You

Prof. Sarju S
Department of Computer Science and Engineering
St. Joseph’s College of Engineering and Technology, Palai (Autonomous)
[email protected]

Page 18 Disclaimer - This document contains images/texts from various internet sources. Copyright belongs to the respective content creators.
Document is compiled exclusively for study purpose
Downloaded from and shall not be used for commercial purpose.
Ktunotes.in

You might also like