Top Banner
Brief Introduction of Algorithm
16

Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Jan 03, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Brief Introduction of Algorithm

Page 2: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

What is Algorithm

A method with several definite steps to effectively complete a task.

In general, it starts from the initial state with input data and ends at final states (not only one!!) with some output information.

Typically, it can be described with a flow chart.

Page 3: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

An Example of Flow Chart

Flow chart is also a basic mechanism of language. There is a kind of “flow chart” which can be much more complicated and we are not going to talk about that in detail.

Page 4: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

If You Want to Learn Algorithm…

This is a book for those without any fundamental knowledge of algorithm. However, some coding techniques and concept is prerequisite.

Page 5: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

An Example of Algorithm

Sorting some disordered data Bubble sort Quick sort

Page 6: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Example – Bubble Sort

A step-by-step example

Page 7: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Example – Quick Sort

A step-by-step example

Page 8: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Example – Comparison

In general, quick sort can be much more faster than bubble sort.

However, there are some issues when making comparison A quantitative comparison? Is there a worst case?

Page 9: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Computational Complexity

Big O notation (infinite asymptotics) Ex: What does O(n2) means? Ex: What about O(2n)? Ex: If an algorithm takes several steps (listed below) to

finish, how do we denote its complexity using big O notation?

3210001510 nnn nnnn 2log12 32

Page 10: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Computational Complexity

Bubble sort: O(n2)Quick sort: O(n log n)

Page 11: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Worst case

For some algorithms, there are some cases will terribly downgrade their performance.

For example, complexity of quick sort will become O(n2) when encountering worst cases.

Page 12: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Other Considerations

Memory consumption Usually, we must strike a balance between

computation speed and memory consumption.

Programming difficulty Some legendary algorithm performs great.

However, writing the program can be a nightmare.

Page 13: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Other Considerations

More detailed complexity Doing multiplication is much slower than doing

addition. Some algorithms replace parts of multiplication

operations with additions. Ex: Conventional matrix multiplication: O(n3) Strassen’s matrix multiplication: O(n2.808) Is it truly much better than conventional method?

Page 14: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Algorithm and Computation Theory

There are huge number of algorithms designed for different kinds of problem. Common mathematical problem, numerical

evaluation, networking, etc.

However, all of them can be discussed in view of computation theory. It is doubtless that we should take care of their

computation behavior and concept. Hence, we can further improve them.

Page 15: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

Some Methodology of Algorithm Design

Divide and conquerDynamic programmingGreedy methodLinear programmingGenetic algorithm

Page 16: Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.

For Further Reading…

“The Art of Computer Programming” by Donald Knuth

Creator of TeX Turing award Be sure to have some program

ming knowledge before reading it!