# CSC 2200 Lecture Notes - Lecture 2: Time Complexity, Sorting Algorithm, Knuth'S Algorithm X

14 views4 pages
19 Jul 2018
School
Course
CSC 2200 Lecture 2
Step by step process of writing an algorithm
o There are no well-defined standards for writing algorithms. Rather, it is problem and
resource dependent. Algorithms are never written to support a particular programming
code.
o All programming languages share basic code constructs like loops (do, for, while), flow-
control (if-else), etc. These common constructs can be used to write an algorithm.
Example
o Problem
Design an algorithm to add to numbers and display the result
Method 1
o Step 1 START
o Step 2 − declare three integers a, b & c
o Step 3 − define values of a & b
o Step 4 − add values of a & b
o Step 5 − store output of step 4 to c
o Step 6 − print c
o Step 7 STOP
Method 2
o Step 1 − START ADD
o Step 2 − get values of a & b
o Step 3 − c ← a + b
o Step 4 − display c
o Step 5 STOP
Unlock document

This preview shows page 1 of the document.
Unlock all 4 pages and 3 million more documents.