Algorithms
2+2+...+2 = 200 vs 2*100 = 200
Pseudocode
i) let = denote the assignment operator.
x = y means "copy the value of y into x"
x = y is executed, the value of y is unchanged.
ii) Example
if(y>x)
z = x
y = z
if(y==x)
z = x
y = z
if(y ㄱ= x)
y = x
else
z = x
a = z
if(y < x)
y = x
else
z = x
a = z
large = s1
i = 2
while(i <= n){
if(si > large)
large = si
i = i + 1
}
large = s1
for i = 2 to n
if(s1 > large)
large = si
max2(a,b,c){
x = a
if(b > x)
x = b
if(c > x)
x = c
return x
}
max(s,n){
large = s1
for i = 2 to n
if(si > large)
large = si
return large
}
p ( index 1 to m), t (index 1 to n), i , j
for i = 1 to n-m+1 {
j = 1
while( t(i+j-1) == p(j) )
{
j += 1
if( j > m )
return i
}
}
return 0
'[이산 수학] - Discrete Mathematics > [Concept]' 카테고리의 다른 글
One to One, Onto definition (0) | 2020.10.23 |
---|---|
Chapter 4.3 (0) | 2020.10.12 |
[이산수학] - Chapter1. Sets and Logic (2) (0) | 2020.09.28 |
[이산수학] - Chapter1. Sets and Logic (1) (0) | 2020.09.28 |