2, Algorithm fs
2, Algorithm fs
1. problem definition
2. problem analysis
3. preparation of rules
4. create concise procedure for solving problem
Theory of Computer Science - Algorithms
4!=4 * (4-1)! = 4 * 3!
3!= 3 * 2!
2!= 2 * 1!= 2 * 1
Theory of Computer Science - Algorithms
1. i ← 1, go to 2
2. y ← xi, go to 3
3. whether i = n ? If yes – the end, if no – go to 4
4. i ← i + 1, go to 5
5. whether xi > y ? If yes – go to 2, if no– go to 3
Theory of Computer Science - Algorithms
sequence x: 3 4 2 5
quantity of x elements: n = 4
index of processing element: i=?
present maximum: y=?
1. i ← 1, go to 2
2. y ← xi, go to 3
3. whether i = n ? If yes – the end, if no – go to 4
4. i ← i + 1, go to 5
5. whether xi > y ? If yes – go to 2, if no– go to 3
Theory of Computer Science - Algorithms
Natural language
input/output operations
Sequence algorithm
The previous algorithm was a sequence algorithm.
instructions are executed one after one
n + 1 – amount of algorithm’s operations
Oi – operation number i
t( x ) – moment of time when is executed operation x
Parallel algorithm
At least 2 operations can be executed in the some time
n + 1 – amount of algorithm’s operations
Oi – operation number i
t( x ) – moment of time when is executed operation x
Conclusions
• In most cases the increase in space complexity, causes the
decrease in time complexity and vice versa.
• Processed data, have implication on execution time and
needed memory.
• Pessimistic and average efficiency, have implication on
algorithm’s application.
• In parallel algorithms, amount of processors, have
implication on time execution. The more processors, the
shorter time. But there is limited amount of processors, for
each algorithm, where if we use more processors above
this limit, it doesn’t increase the time.