You are on page 1of 11

CSE 4310 - Algorithm Analysis

Lecture Note 1

School of Computer Science and Engineering


California State University, San Bernardino
Course
• Title: Algorithm Analysis
• Time: M/W 9:00 – 12:00PM (Pacific Time)
• Zoom Link: https://csusb.zoom.us/j/86241805600
• This course includes implementations of algorithms in the C++
programming language.
• Books
• J.H. Kingston, "Algorithms and Data Structures", Addison Wesley, 1990.
• J.D. Smith, "Design and Analysis of Algorithms", PWS-KENT Publishing
Company, 1989.
• Udi Manber, "Introduction to Algorithms", Addison-Wesley, 1989.
• D. Knuth, "The Art of Computer Programming : Sorting and Searching",
Addison-Wesley, Reading, MA, 1973.
• Aho, Hopcroft and Ullman, "The Design and Analysis of Computer Algorithms",
Addison- Wesley, Reading, MA, 1983.
• G. Brassard and P. Bratley, "Algorithmics : Theory & Practice", Prentice Hall,
1988.

2 / 11
Definitions
• Algorithm:
• A set of rules for carrying out some calculation, either by hand or, more usually,
on a machine
• A finite set of rules, which gives a sequence of operations for solving a specific
problem and satisfies the following criteria:
• Finiteness: terminate in finite time
• Definiteness: each step must be precisely defined
• Input: zero or more inputs
• Output: one or more outputs
• Effectiveness: in principle, each step should be able to be traced by humans
• Named for the nineth-century Persian mathematician al-Khowarizmi

• Algorithmics:
• The study of algorithms

3 / 11
Multiplication Algorithms

4 / 11
Multiplication Algorithms

5 / 11
Implementation
#include <iostream>

using namespace std;

int russe(int m, int n){


int result = 0;

do{
if( m % 2 == 1 ){
result = result + n;
}
m = m / 2;
n = n * 2;
} while( m != 0 );

return result;
}

6 / 11
Multiplication Algorithms

7 / 11
Mathematical Notations

• ⋀ : and (conjunction)
• ⋁ : or (disjunction)
• ¬ : not (negation)
• ⟹ : implies (implication) [ 𝑝 ⇒ 𝑞 : 𝑖𝑓 𝑝, 𝑡ℎ𝑒𝑛 𝑞. ]
• ⟺ : equivalent
• ∀ : for all
• ∃ : there exist

8 / 11
Mathematical Notations
• Propositional Calculus
• ⋀ : and (conjunction)
• ⋁ : or (disjunction)
• ¬ : not (negation)
• ⟹ : implies (implication) [ 𝑝 ⇒ 𝑞 : 𝑖𝑓 𝑝, 𝑡ℎ𝑒𝑛 𝑞. ]
• ⟺ : equivalent
• ∀ : for all
• ∃ : there exist
• Set Theory
• ∪, ∩, ∅, ⊂, ⊆, ⊃, ⊇, ⊄, ⊅, 2! , 𝐴 , |
• 𝑎, 𝑏 , 𝑎, 𝑏 , 𝑎, 𝑏 , [𝑎, 𝑏)
• Sum and Product % '

C 𝑓(𝑖) , E 𝑔(𝑗)
"#$ &#$

• Miscellaneous
• 𝑥, 𝑦
9 / 11
Proof Techniques
• Contradiction
• Demonstrating the truth of a statement by proving that its negation yields a
contradiction
• Called “proof of contradiction” or “indirect proof”
• Example Statements:
• 2 𝑖𝑠 𝑎 𝑖𝑟𝑟𝑎𝑡𝑖𝑜𝑛𝑎𝑙 𝑛𝑢𝑚𝑏𝑒𝑟.
• 𝑇ℎ𝑒𝑟𝑒 𝑎𝑟𝑒 𝑖𝑛𝑓𝑖𝑛𝑖𝑡𝑒𝑙𝑦 𝑚𝑎𝑛𝑦 𝑝𝑟𝑖𝑚𝑒 𝑛𝑢𝑚𝑏𝑒𝑟𝑠.

10 / 11
Proof Techniques
• Mathematical Induction
• Reasoning
• Induction: it remains possible that the general rule induced is wrong
• Deduction: deductive reasoning may yield a wrong result
• Principle
• Assume 𝑃 is a property of the integers and an integer 𝑎, known as the basis
• Step 1: Show that 𝑃 𝑎 ℎ𝑜𝑙𝑑𝑠
• Step 2: Show that 𝑃 𝑛 𝑚𝑢𝑠𝑡 ℎ𝑜𝑙𝑑 𝑤ℎ𝑒𝑛𝑒𝑣𝑒𝑟 𝑃 𝑛 − 1 ℎ𝑜𝑙𝑑𝑠, 𝑓𝑜𝑟 𝑛 > 𝑎
• Example Statements
' '
𝑛(𝑛 + 1) 𝑛(𝑛 + 1)(2𝑛 + 1)
C𝑖 = , C 𝑖( =
2 6
"#$ "#$

• Read 1.6 carefully

11 / 11

You might also like