1.4 Data types, structures and algorithms

studied byStudied by 6 people
5.0(1)
get a hint
hint

Importance of using the correct data type

1 / 145

Tags and Description

146 Terms

1

Importance of using the correct data type

Allows the right operations to be performed on it

New cards
2

Character

Single symbol

New cards
3

String

Collection of characters

New cards
4

Real/floating point

Number which can have a decimal part

New cards
5

Binary

2 digit number system

New cards
6

Fractions in binary

Represented by 1/2^x where x increases towards the right in the binary table

New cards
7

Most significant bit/leading bit

First binary digit

New cards
8

Sign magnitude

Uses an extra binary digit to add a +ve or -ve sign in front of the binary number

New cards
9

Sign magnitude - negative

1 as the leading bit (at the start)

New cards
10

Sign magnitude - positive

0 as the leading bit (at the start)

New cards
11

Two’s complement

Makes the most significant bit negative in the binary table

New cards
12

Hexadecimal

16 digit number system, base 16, uses 0-9 and A-F

New cards
13

Binary - hexadecimal

4 bits in binary is equivalent to one place of hex

New cards
14

Floating point binary- sections

Mantissa and exponent

New cards
15

Mantissa

Number

New cards
16

Exponent

Power, number of places the floating point is moved

New cards
17

To practise: subtraction, floating point arithmetic

Examples on physics and maths tutor

New cards
18

Floating point binary - accuracy

Larger values are less accurate

New cards
19

Floating point binary - normalisation

Starts 01 for a positive number or 10 for a negative number

New cards
20

Normalisation - advantage

Makes numbers as precise as possible in the given number of bits

New cards
21

Logical shift

Shift performed on binary numbers, moves all digits a set number of places to the right/left

New cards
22

Effect of logical shift

Division or multiplication by 2^shift number

New cards
23

Carry bit

Can hold 1 binary digit which is lost due to a shift

New cards
24

Mask

Applied to binary by combining with a logic gate

New cards
25

XOR

Exclusive OR, both on or both off=0

New cards
26

Bitewise manipulation

Logical shifts and mask

New cards
27

Character set

Collection of characters and corresponding codes which can be used by computers to represent text

New cards
28

ASCII

Uses 7/8 bits and can represent 128 characters

New cards
29

ASCII - advantage

Uses fewer bits so each character takes less memory to store

New cards
30

ASCII - disadvantage

Fewer characters can be represented

New cards
31

Unicode

Uses a varying number of bits so over a million characters can be represented

New cards
32

Unicode - advantage

Many more characters can be represented

New cards
33

Unicode - disadvantage

Uses more bits so each character requires more memory to be stored

New cards
34

Data structure

Specialised format for processing, storing and retrieving data, collection of different kinds of data

New cards
35

Static data structures

Fixed size during run-time

New cards
36

Dynamic data structures

Can change size during run-time

New cards
37

Array

Static, ordered, finite set of elements of a single type, 0-indexed, values stored contiguously

New cards
38

Data type

The form of a variable to which a value can be assigned

New cards
39

2D arrays

Like a table, use [y,x]

New cards
40

3D arrays

Like a spreadsheet with many sheets, use [z,y,x] with z as the array number

New cards
41

Record

Like a row in a file, made up of fields - each field can have a different data type

New cards
42

List

Dynamic data structure, values stored non-contiguously (do not have to be stored next to each other in memory)

New cards
43

List - data types

Can contain elements of more than one data type

New cards
44

Tuples

Static ordered set of values, immutable, initialised using normal brackets

New cards
45

Immutable definition

Elements cannot be added or removed once the structure has been created

New cards
46

Contiguous

Data stored consecutively together in memory

New cards
47

Linked-list

Dynamic data structure used to hold an ordered sequence of items (nodes)

New cards
48

Linked-list - advantage

Items do not have to be stored contiguously, dynamic so it can change size

New cards
49

Linked-list - disadvantage

No direct access to a single piece of data so slow to search, pointers must also be stored

New cards
50

Linked-list - items

Nodes, contains a data field and a link/pointer field

New cards
51

Linked-list - pointer

Holds the address of the next item

New cards
52

Linked-list - data stored

Index, data, pointer as well as start pointer and next available location for data

New cards
53

Linked-list - editing

Edit pointers to point to a new item or miss out an existing item

New cards
54

Linked-list - editing: advantage

Easy to edit

New cards
55

Linked-list - editing: disadvantage

Node is not removed but simply ignored, which wastes memory

New cards
56

Graph

Set of vertices/nodes connected by edges/arcs

New cards
57

Directed graph

Edges can only be traversed in one direction

New cards
58

Undirected graph

Edges can be traversed in both directions

New cards
59

Weighted graph

Weight (numerical value) attached to each edge

New cards
60

Graph - representation

Computers use an adjacency matrix or an adjacency list

New cards
61

Adjacency matrix - advantage

Quicker access times than adjacency list

New cards
62

Adjacency list - advantage

More space efficient for large, sparse networks

New cards
63

Stack

LIFO (last in first out) data structure, either static or dynamic

New cards
64

Stack - LIFO

Items can only be added to/removed from the top of the stack

New cards
65

Stack - use

To reverse an action e.g. go back a page in web browsers, undo buttons

New cards
66

Stack - static

Preferred when maximum size of the stack is known in advance, easier to implement and make more efficient use of memory

New cards
67

Stack - implementation

Uses a pointer that points to the top of the stack, where the next piece of data will be inserted

New cards
68

Stack - function

stackName.function(parameters)

New cards
69

Stack - check if empty

.isEmpty() - must be done before peeking or popping, returns Boolean value and works by checking the value of the top pointer

New cards
70

Stack - add a new value

.push(value)

New cards
71

Stack - return top value of stack

.peek()

New cards
72

Stack - remove and return top value of stack

.pop()

New cards
73

Stack - return size

.size()

New cards
74

Stack - check if full

.isFull() - returns Boolean value, works by comparing stack size to top pointer

New cards
75

Queue

FIFO (first in first out) data structure

New cards
76

Queue - FIFO

Items are added to the end of the queue and removed from the front of the queue

New cards
77

Queue - uses

Printers, keyboards, simulators

New cards
78

Linear queue

Data structure consisting of an array

New cards
79

Linear queue - items

Items added into the next available space and removed from the front of the queue

New cards
80

Linear queue - pointers

Two pointers, one pointing to each end of the queue, where items can be added/removed

New cards
81

Linear queue - advantage

Easy to implement

New cards
82

Linear queue - disadvantage

As the queue removes items, there are addresses that cannot be used again, making it ineffective

New cards
83

Queue - functions

queueName.function(parameters)

New cards
84

Queue - add item

.enQueue(item) - increments back pointer

New cards
85

Queue - remove item

.deQueue() - increments front pointer

New cards
86

Queue - checks if empty

.isEmpty() - works by comparing front and back pointer

New cards
87

Queue - checks if full

.isFull() - works by comparing back pointer and queue size

New cards
88

Circular queue - description

FIFO, operates similarly to a linear queue

New cards
89

Circular queue - pointer usage

Once back pointer is equal to maximum size of queue, it can loop back to the front and store values there if the space is empty

New cards
90

Circular queue - advantage

More space efficient than linear

New cards
91

Circular queue - disadvantage

Harder to implement than linear

New cards
92

Tree

Connected form of graph

New cards
93

Tree - root node

Top node, has no incoming edges

New cards
94

Tree - node

Item in tree

New cards
95

Tree - edge/branch/arc

Connects two nodes

New cards
96

Tree - child

Node with incoming edges

New cards
97

Tree - parent

Node with outgoing edges

New cards
98

Tree - subtree

Subsection of tree consisting of a parent and all the children of that parent

New cards
99

Tree - leaf

Node with no children

New cards
100

Binary tree

Type of tree where each node has a maximum of two children

New cards

Explore top notes

note Note
studied byStudied by 20 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 5 people
Updated ... ago
5.0 Stars(2)
note Note
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 15 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 108425 people
Updated ... ago
4.9 Stars(528)

Explore top flashcards

flashcards Flashcard30 terms
studied byStudied by 61 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard66 terms
studied byStudied by 14 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard43 terms
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard60 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard108 terms
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard47 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard97 terms
studied byStudied by 42 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard81 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)