Download presentation
Presentation is loading. Please wait.
Published byJulian Ward Modified over 9 years ago
1
Algorithms Describing what you know
2
Contents What are they and were do we find them? Why show the algorithm? What formalisms are used for presenting algorithms? Notes on notation Algorithmic performance
3
Where do we find them In computer science and engineering almost everywhere. Every other paper you read will include and introduce an algorithm in one form or another (see formalisms later) Most of the books you have read include them in some form or another
4
What are they? “In mathematics and computer science, an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning.” Source: http://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Algorithm Mind you… – The steps are not as important as is the correctness of the algorithm and to prove that it meets some performance claims. In most cases coming up with the algorithm is a lot more work than actually presenting it – This is often because: some steps might be unclear; validation/verification might be missing on incomplete; usefulness of the algorithm omitted.
5
Why is an algorithm important? It might be better than others – What is better? uses less memory; uses less CPU time; It is faster; It improves a previous case; does it maybe take up less space and requires less resources; or maybe all the above together?? It might be explaining a very complex process It might be used to show the feasibility of a result and that a problem is computable (deterministic as we say) regardless of cost
6
So what would expect to see in it? The steps that make up the algorithm The structures used by the algorithm for input, output and internal representation of data Where does it have meaning (the scope) and any known limitations What properties will show that the algorithms is correct (preconditions, postconditions, loop invariants) Demonstration of correctness A complexity analysis for time and resources requirements Experiments confirming the theoretical result.
7
What formalisms are used? There are certain styles for presenting algorithms so that they are understandable and clear List style Pseudocode Prosecode Literate code
8
Formalism – list style Algorithm broken down into a sequence of steps (numbered or named) See loops as involving ‘goto’ statements Good – Discuss while presenting – No restriction to text Bad – Sometimes easy to get lost in the discussion
9
Formalism - pseudocode Algorithm presented in a block-structure language Each line is numbered Good – Immediately obvious structure Bad – Statements tend to be short (and unclear) – Not allowed to include many comments
11
Formalism - prosecode Number each step Don’t break a loop over several steps Use sub-numbering for step parts Include explanatory text Good – Direct and clear explanation of the algorithm Bad – More effective when the algorithm has been previously discussed
13
Formalism – Literate code Introduce algorithmic detail gradually While introducing detail discuss underlying ideas The following example is incomplete
15
Notation For algorithms mathematical notation is preferable to a programming notation Quick: – Use x i not x[i] – Use × or ∙ not * or x – Avoid specific language constructors (for, variable++, etc) – Nesting can be used by numbering subsections Mathematics provide a wealth of symbols that enable us to describe almost anything we like – s {CSC135} x, y {ASSIGNMENTS} with x y If H(s, x) H(s,y) s will learn some LaTeX
16
Environment The steps of an algorithm is part of its description Environment description is the remainder of the algorithm – Data structures, input and outputs all should be clearly and unambiguously defined (think mathematics) – Other software/hardware, even the operating system If you are describing an algorithm for faster read-write operations on Blue-Ray discs then hardware and operating system aspects are important – Specify all variables – Mention assumptions and expectations – Mention possible errors – Say what the algorithms does Be consistent
17
Performance When comparing an algorithm state criteria used. Possibilities include (and are not limited to): – Processing time (or speed) Not easy to define due to various factors. Better use a mathematic model for times based performance evaluation – Memory and disk requirements Various ways of manipulation could affect performance. When describing the algorithm, be clear on memory usage – Disk and network traffic Seek time & transfer rate are important. Sequential access vs. random access can make the difference. Caching is also important. – Applicability Be sure you are comparing similar requirements & functionality algorithms. – Asymptotic analysis: used to compare algorithm performance (big O notation, another course)
18
Algorithms end summary What are they, why should we present them? What is to be expected What formalisms can be used Notation Environment Performance
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.