Lecture # 01 - New
Lecture # 01 - New
Research Interest
Machine Learning
Pattern Recognition
Web: CUOnline
Textbook: See next slide
Grading on 100
Collaborative-learning:
You will do small group discussion activities.
Introduction
Procedure: Method
Mix the sugar, baking powder and flour, mix in beaten
eggs, melted butter and bake at 325F for 40 mins.
Result: Output
2 75 remainder
2 37 1
2 18 1
2 9 0
2 4 1
2 2 0
2 1 0
0 1
1001011
Department of Computer Science
Procedure for Decimal to Binary conversion
1. Write the decimal number
2. Divide by 2; write quotient and remainder
3. Repeat step 2 on the quotient; keep on repeating until the
quotient becomes zero
4. Write all remainder digits in the reverse order (last remainder
first) to form the final result
What is it?
A procedural solution to given problem
Briefly speaking, algorithms are procedural
solutions to problems
Algorithms are not answers, but rather
precisely defined procedures for getting
answers. (e.g., sorting 3 numbers)
Department of Computer Science
Formal
Definition
problem
algorithm
Is there a
relationship
between input
and output?
L
o
g
i
c
Statement of problem:
Input: a sequence of N numbers <a1, a2, …, aN>
Output: a reordering of the input sequence <a’1, a’2,
…, a’N> so that a’i ≤ a’j whenever i < j
Instance: the sequence <5, 3, 2, 8, 3> becomes
<2, 3, 3, 5, 8> after sorting
Algorithms:
Bubble Sort
Selection sort
Insertion sort
Merge sort
Quick sort and many more
m
n
Upshot
Pseudo-code
A mixture of natural language and programming
language-like structures
Precise and brief
also avoids most issues of ambiguity
No particular agreement on syntax
programming language
tend to require expressing low-level details that are
not necessary for a high-level understanding
Process
Input or output
Decision
Flowchart
Symbols Flow line
Connector
Off-page connector
Flowchart
counter
Symbols Automatic- A B
counter loop S
situation is used:
1.
Input
Step 2
quotient; keep on repeating Step 3Record Remainder to List
until the quotient becomes
Number = Quotient
zero
No
If Quotient
=0 Step 3
4. Write all remainder digits in
the reverse order (last Yes
remainder first) to form the
Display List
final result In Reverse Order Step 4
End
2. Divide by 2; write
quotient and remainder
Idea:
if n 0, gcd(m, n) = gcd(n, m mod n);
if n = 0, gcd(m, n) = m.
Euclid’s algorithm for computing gcd(m, n)
Step1 If n=0, return the value of m as the answer
and stop; otherwise proceed to Step2.
Step2 Divide m by n and assign the value of the
remainder to r.
Step3 Assign the value of n to m and the value of r
to n. Go to Step1.
What is an algorithm?
Understand the concept and properties of an algorithm.
Define and use the three constructs for developing
algorithms: sequence, decision, and repetition.
What properties an algorithm must have?
Understand the properties of an algorithm.
How to specify an algorithm?
Understand and use three tools to represent algorithms:
flowchart, pseudocode, and structure.
One problem different algorithms having
different speeds
Discussed importance of algorithms
Department of Computer Science 04/22/24 88
Summary
Great thinkers
will always be needed.