# Algorithms and Data types: Introduction Dr. Andrew Wallace PhD BEng(hons) EurIng

## Presentation on theme: "Algorithms and Data types: Introduction Dr. Andrew Wallace PhD BEng(hons) EurIng"— Presentation transcript:

Algorithms and Data types: Introduction Dr. Andrew Wallace PhD BEng(hons) EurIng andrew.wallace@cs.umu.se

Overview Algorithms Data types Program design Writing code Testing code

Algorithms What is an algorithm? Set of instructions for calculating / doing something. Examples Sorting Path finding Item finding Controlling

Algorithms History Abū ʿ Abdallāh Mu ḥ ammad ibn Mūsā al-Khwārizmī Brahmagupta 0628 Algoritmi de numero Indorum. Anthyphairesis Euclidean algorithm Euclid's Elements -0299 Gottfried Wilhelm von Leibniz Calculus ratiocinator 1680 Augusta Ada King, Countess of Lovelace 19 th Cent.

Algorithms Time and space complexity Analysis Pseudocode Design

Data Types What is a data type? A way of classifying pieces of information Useful for computers Examples Primitive Integers, reals, boolean(?) Composite Arrays, struct, unions Abstract Stacks, queues, heaps, trees

Data Types Integers int nVar; short intnVar; long intlVar; unsigned intlVar; intnArray[nSize];

Data Types Floats / doubles floatfVar; doubledVar; long doubledVar;

Data Types Char charcVar; signed charcVar; charstrArray[nSize];

Data Types Void void*pVar;

Program design The ideal way: Customer specification Program / top level specification Top level design Low level design Implementation

Program design Customer specification From the users point of view What to do but not how Program / top level specification Technical What to do but not how!!!

Program design Top level design Modelling the system What data? What functions / methods? How to solve the problem?

Program design Top level design Structured Analysis / Structured design Data flow Object orientated Encapsulation Agents design Task orientated

Program design Low level design Function design KISS Does one thing! Algorithm design Pseudocode

Program design Program boundary Program Input Output check function

Program design int function (n) check n if error return error else do something clever return 0

Writing code Hungarian notation Block structure

Writing code n – integer nVar l – long lVar f – floatfVar d – doubledVar b – BooleanbVar m_- memberm_nVar o – ObjectoVar fp, i, j

Writing code Blocks { } Indentation if … else while.. for …

Testing code Does it meet the requirements? Time constraints Space constraints Does it work (bugs?) Usability

Testing code Block / function test Assembly / integration test Customer / validation testing function Assembly system

Testing code Static Asymptotic analysis Logical proof checking Dynamic Running the code debugger

Testing code Debugging Break points Check variables Change variables Jump in and out of code Step through code Look at the memory

Questions?

Download ppt "Algorithms and Data types: Introduction Dr. Andrew Wallace PhD BEng(hons) EurIng"

Similar presentations