Feb 122018A list can do everything an array can do, and more; the array data type is strictly “less useful” than the list data type.
However, the array data structure is both faster and uses less memory than any list data structure.(1)
This is common: if a data type supports fewer operations, then programmers who use that type have less freedom, but programmers who implement it (or choose an implementation) have more freedom.
A data structure supporting fewer operations can often be more efficient in speed, memory use, or both; or, if you want more operations supported, expect a lower efficiency.
Feb 122018We have the idea of an abstract data type (ADT) — a data type which is defined by its set of possible values and set of supported operations, but which does not specify how those values should be represented in memory, nor how the operations should be implemented.
We also have a memory model for thinking about data structures, which fill in these details.(1)
Feb 122018A type defines not just the possible values that some data can take, but also the operations which can be performed on that data.
For example, the int
type represents integers, and supports arithmetic operations, bitwise operations and comparison operations.
Feb 052018Computer programs use variables and data structures to store data in memory.(1)
A data structure is a scheme for representing values of some type in memory; before we can understand, analyse and design data structures, we need to understand memory.
Feb 052018Boolean is a type of data, with only two possible values: true and false.
- In Python, the type
bool
has values True
and False
.
- In Java, the type
boolean
has values true
and false
.
Almost every programming language has Booleans, because they’re necessary for the checks, comparisons and other logical conditions in if/else statements and loops.(1)
Feb 052018Using multiple bits to represent an integer requires deciding what the bits mean.
A simple scheme for representing numbers could be to represent e.g. the integer value 3 by using three 1s, like so:
Feb 052018Programmers deal with many types of data: most programming languages have integers, booleans, floating point numbers, strings, lists, and more.
The word “type” has a specific meaning: each value has a type.
In Python the value 1
has the type int
, and the value 'Hello, world!'
has the type str
.
In Java the value 1
has the type int
, and the value "Hello, world!"
has the type String
.
Feb 052018This blog supports CMP4272 Data Structures and Algorithms UG1, a first-year undergraduate module taken by students in the School of Computing and Digital Technology at Birmingham City University.
This blog will include explanations of topics in Data Structures and Algorithms, with examples in Python.
Installing Python 3 (with IDLE) on your own computer is recommended.