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

14 views4 pages
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
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.
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.

Already have an account? Log in

Get OneClass Notes+

Unlimited access to class notes and textbook notes.

YearlyBest Value
75% OFF
$8 USD/m
$30 USD/m
You will be charged $96 USD upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.
Payments are encrypted using 256-bit SSL. Powered by Stripe.