Topic 3
Topic 3
Data Representation
1. Whole Number
Integer
data age as whole number
age = 21
2. Real Number
Float or Decimal values
data salary as real number
Complex data types have no default value, they start off as null.
1 0
2 0 0
3 0 0 0
4 0 0 0 Null
5 10 0 0 Null
6 10 20 0 Null
7 10 20 30 Null
8 10 20 30 “The answer is”
9 10 20 30 “The answer is”
10 10 20 30 “The answer is”
Kiran Rana 08/20/2020
12 Computer Memory
Every piece of data that is used in an algorithm must be stored somewhere.
It gets stored in the computer’s memory.
There are real physical constraints that impact on how we design algorithms.
We have finite amounts of computer memory.
We have finite amounts of CPU cycles.
The size of every data type is different for each programming language.
Scaling is the degree to which an algorithm can work for larger sets of data.
Many algorithms suffer from 'scaling issues‘.
What works for ten items of data, may not work as well for a thousand
The decisions we make about the data we store will have an impact on how useful the
algorithm is for larger tasks.
Consider a program which checks to see whether a key on a keyboard was pressed in
the past sixty seconds.
We could store that as a Boolean.
We could store that as an whole number.
We could store it as a string.
Choosing the right data type is important, because it makes everything else easier.
A phone number?
An address?
The gender of a student?
The age of a person?