AQA A-Level Computer Science - Data Structures and Abstract Data Types

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/43

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

44 Terms

1
New cards

Data Structures

Containers that store different types of data.

2
New cards

Arrays

Indexed set of related elements.

Must be finite, indexed, and only contain elements with the same data type.

3
New cards

Abstract Data Types / Data Structures

Make use of other data structures to form a new way of storing data. Do not exist as data structures alone.

4
New cards

Queues

Abstract data structure based on an array.

Referred to as "first in, first out" (FIFO) abstract data structures.

5
New cards

Uses of Queues

Used by computers in keyboard buffers - each keypress is added to the queue and removed when the computer has processed the keypress.

Ensures the letter appear on the screen in the same order they were typed.

6
New cards

Linear Queues

Has two pointers (front and rear), to identify where to place a new item in a queue / identity which item is at the front.

Rear always points to the next available position in the queue.

7
New cards

Circular Queues

The front and rear pointers can move over the ends of the queue for a more memory efficient data structure and utilise any spaces left at the front of the queue.

8
New cards

Queue Operations

Enqueue - Add an item to the end of the queue.

Dequeue - Remove an item from the queue in FIFO order.

IsEmpty - returns TRUE if the queue has no content by comparing if the front and rear pointers are equal to each other.

IsFull - returns TRUE if the queue has no available positions that are behind the front pointer.

9
New cards

Priority Queues

Items are assigned priority. Items with highest priority are dequeued before low priority.

If items have same priority, FIFO applies.

10
New cards

Uses of Priority Queues

Processors assign time to applications according to their priority. Application currently used by the user are prioritised over background applications for a faster user experience.

11
New cards

Stacks

First in, Last out (FILO) abstract data structure.

Often based on an array, but only have one (top) pointer.

12
New cards

Stack Operations

Push - Add an item to the stack

Pop - Remove the item at the top of the stack

Peek - Returns the value of the item at the top of the stack but does not remove it.

IsEmpty - returns TRUE if the stack has no content.

IsFull - returns TRUE if the stack has no available positions that are behind the top pointer.

13
New cards

Graphs

Used to represent complex relationships between items within datasets.

(Transport + IT networks, the Internet)

14
New cards

Features of Unweighted, Undirected / Weighted, Directed Graphs

Consists of nodes (or vertices) joined by edges (or arcs .

Weighted graphs have assigned values to edges, representing values such as time, distance or cost.

15
New cards

Adjacency Matrices

Tabular (Table) representation of a graph. Each node of a graph is assigned a row and column in a table. Stores all edges / connections, even edges that don't exist.

16
New cards

Features of Adjacency Matrices - Unweighted Graph

1 - An edge exists between two nodes

0 - No connection between two nodes (or is the same node)

All adjacency Matrices display diagonal symmetry.

17
New cards

Features of Adjacency Matrices - Weighted graph

Contains the weight of the connection between two nodes instead of Boolean values.

If no connection exists, an extremely large value is used to prevent a shortest path algorithm from using edges that don't exist - often expressed as infinity.

18
New cards

Adjacency Lists

List representation of a graph. For each node in the graph, a list of adjacent nodes is created - only recording existing connections in a graph.

19
New cards

Pros of Adjacency Matrix

Allows an edge to be queried very quickly, as it can be looked up by its row and column.

Suited to dense graphs with large number of edges.

-> Time efficient

20
New cards

Cons of Adjacency Matrix

Stores every possible edge between nodes, even those that don't exist.

Almost half of the matrix is repeated data.

-> Memory inefficient

21
New cards

Pros of Adjacency lists

Only stores the edges that exist in the graph.

Suited to sparse graphs, where there are few edges.

-> Memory efficient

22
New cards

Cons of Adjacency lists

Slow to query, as each item in a list must be searched sequentially until the desired edge is found.

-> Time inefficient

23
New cards

Trees

Connected undirected graph with no cycles.

24
New cards

Rooted Trees

Has a root node from which all other nodes stem - usually at the top of the tree.

25
New cards

Parent nodes

Nodes from which other nodes stem.

(The root node is the only node in a rooted tree with no parent.)

26
New cards

Child nodes

Nodes with a Parent.

27
New cards

Leaf nodes

Child Nodes with no children.

28
New cards

Rooted Trees: Binary Trees

A rooted tree in which each parent node has no more than two child nodes.

29
New cards

Hash Tables

A way of storing data that allows data to be retrieved with a constant time complexity of O(1).

30
New cards

Hashing Algorithm

Takes an input and returns a hash. A hash is unique to its input and cannot be reversed to retrieve the input value.

The same hash is always returned for each input.

31
New cards

Storing in Hash Tables

Hash table stores key-value pairs.

The key is sent to a hash function that performs arithmetic operations on it. The resulting hash is the index of the key-value pair in the hash table.

32
New cards

Looking up elements in Hash Tables

The key is first hashed.

Once the hash has been calculated, the position in the table corresponding to that hash is queried and the desired information is located.

33
New cards

Collision

When different inputs produce the same hash.

Could result in data being overwritten in a hash table.

34
New cards

Rehashing Algorithm

Finding an available position according to an agreed procedure.

Example: Keep moving to the next position until an available one is found.

35
New cards

Dictionary

A collection of key-value pairs in which the value is accessed by its associated key.

"row, row, row your boat"

1 - row

2 - your

3 - boat

Dictionary-based compression = 11123

36
New cards

Vectors

Represented lists of numbers, functions or ways of representing a point in space.

37
New cards

Vectors viewed as a function...

Represented using a dictionary.

38
New cards

Vectors viewed as a list....

Represented using a one-dimensional array.

39
New cards

Vector Addition

Vectors added to show a translation.

Vectors can be added 'tip to tail' with arrows.

Alternatively, vectors can be added by adding each of their components - [14,4] + [4, -2] = [18, 2]

<p>Vectors added to show a translation.</p><p>Vectors can be added 'tip to tail' with arrows.</p><p>Alternatively, vectors can be added by adding each of their components - [14,4] + [4, -2] = [18, 2]</p>
40
New cards

Scale-Vector Multiplication

To scale a vector, each of its components are multiplied by a scalar, affecting magnitude and not direction.

<p>To scale a vector, each of its components are multiplied by a scalar, affecting magnitude and not direction.</p>
41
New cards

Convex combination of two vectors

Vector 1 = a

Vector 2 = b

Convex combination = ax + by

Where:

x != 0 and y != 0

x < 1 and y < 1

x + y = 1

<p>Vector 1 = a</p><p>Vector 2 = b</p><p>Convex combination = ax + by</p><p>Where:</p><p>x != 0 and y != 0</p><p>x &lt; 1 and y &lt; 1</p><p>x + y = 1</p>
42
New cards

Dot Product / Scalar Product

A single number derived from the components of the vectors.

Can be used to determine the angle between two vectors.

<p>A single number derived from the components of the vectors.</p><p>Can be used to determine the angle between two vectors.</p>
43
New cards

Static Data Structure

Fixed in size.

Declared on memory as a series of sequential, contiguous memory locations (Next element will be in the memory location next door).

If number of data items to be stored exceeds the number of memory locations allocated, an overflow error/ stack overflow will occur.

44
New cards

Dynamic Data Structure

Changes size to store content.

Each item of data is stored with a reference to where the next item is stored in memory.

If the number of data items to be stored exceeds the number of memory locations allocated, new memory locations are added until there is enough space for the data.