algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/algorithms_writing.pdf · algorithms...

14
Algorithms writing WRITING FOR COMPUTER SCIENCE ALGORITHMS XUE, LEI

Upload: lamnguyet

Post on 09-Mar-2018

244 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Algorithms writingWRITING FOR COMPUTER SCIENCE ALGORITHMS

XUE, LEI

Page 2: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Why is the algorithm so important?Algorithm is always the core contribution in many papers in computer science;

These algorithms are often the product of moths of hard work;

An algorithm is usually submitted based on a great detail of discussion, barnstorming, prototyping, testing, analysis, and debate over details.

2

Page 3: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

How to describe algorithms in a paper?

3

Page 4: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Presentation of a algorithma. It provides a new or better way to compute a result.

b. In order to explain a complex process.

c. In order to show it is feasible to compute a result, regardless of the cost, or to show that a problem is decidable.

• A formal demonstration of correctness • Performance• An experimental validation.When such demonstrations are absent, the reason for the absence should be clear.

4

Page 5: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

What a reader would expect to find?a. The steps that make up the algorithm.

b. The input and output, and the internal data structures used by the algorithm.

c. The scope of application of the algorithm and its limitations.

d. The properties that will allow demonstration of correctness (i.e., preconditions, postconditions, and loop invariants).

e. A demonstration of correctness.

f. A complexity analysis, for both space and time requirements.

g. Experiments confirming the theoretical results.

5

Page 6: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Formalismsa. List style, the algorithm is broken down into a series of numbered or named steps and loops

involving several steps are represented by "go to step X" statements.

b. Pseudocode, the algorithm is presented as if written in a block-structured language and each line is numbered.

c. Prosecode, number each step, never break a loop over several steps, use subnumbering for the parts of a step, and include explanatory text.

d. Literate code, the detail of the algorithm is introduced gradually, intermingled with discussion of the underlying ideas and perhaps with the asymptotic analysis and proof of correctness

e. Flowcharts should not be used to describe algorithms. (Because of lack of modularity, promotion of the use of goto statements, lack of space for explanatory text, insufficient space for complex conditions, and inability to clearly represent algorithms of any complexity.)

6

Page 7: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

List styleAdvantage:

There is no restriction on the amount of text used to describe a step (although a step should be a single activity), so there is room for a clear statement of each step and for remarks on its properties.

Disadvantage:

The control structure is often obscure and it is too easy for the discussion to bury the algorithm.

7

Page 8: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

PseudocodeAdvantage:

The structure of the algorithm is immediately obvious.

Disadvantage:

Each statement is forced by formatting considerations to be fairly terse

It is not easy to include detailed comments.

8

Page 9: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

ProsecodeAdvantage:

The specification of the algorithm is direct and clear.

The assignment symbol “" is a good choice because it is unambiguous, in contrast to symbols such as "=".

Disadvantage:

The prosecode style of presentation is only effective when the concepts underlying the algorithm have been discussed before the algorithm is given.

9

Page 10: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Literate code

This example is incomplete, most algorithms worth presenting need a substantial explanation that can't be condensed into a page or two.

10

Page 11: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

NotationMathematical notation is preferable to programming notation for presentation of algorithms.

Mathematics provides many handy conventions and symbols that can be used in description of algorithms, including set notation, subscripts and superscripts, and symbols.

It was once common to include the text of a program in a paper, in addition to a description of the algorithm it embodies. This

11

Page 12: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Environment of algorithmsSpecify the types of all variables, other than trivial items such as counters;

Describe data structures carefully.

Be consistent.

12

Page 13: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Performance of algorithmsa. Basic of evaluation. The basis of evaluation should be made explicit. Where algorithms are

being compared, specify not only the environment but also the criteria used for comparison.

b. Processing time. Time (or speed) over some given input is one of the principal resources used by algorithms; others are memory, disk space, and disk and network traffic.

c. Memory requirements. You should take care to specify how your algorithms use memory.

d. Disk and network traffic. Disk costs have two components, the time to fetch the first bit of requested data (seek and latency time) and the time required to transmit the requested data (at a transfer rate).

e. Applicability. Algorithms can be compared not only with regard to their resource requirements, but with regard to functionality.

f. Asymptotic complexity.

13

Page 14: Algorithms writing - cnblogs.comfiles.cnblogs.com/files/yulele/Algorithms_writing.pdf · Algorithms writing WRITING FOR COMPUTER ... Pseudocode, the algorithm is ... Environment of

Thanks!