4.2 Fundamentals of Data Structures AQA Comp Sci

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

1/77

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

78 Terms

1
New cards
Data Structure

A way of organizing and storing data efficiently, chosen to optimise access and manipulation of data. Examples: arrays, lists, trees, tuples, records.

2
New cards
Abstract Data Type (ADT)
A conceptual model for data organization, not tied to a specific implementation. Focuses on what operations can be performed, not how.
3
New cards
Examples of ADTs
Queue, Stack, Graph, Tree, Hash Table, Dictionary, Vector
4
New cards
Static Data Structure
A structure with fixed memory size. Example: array.
5
New cards
Dynamic Data Structure
A structure that can grow or shrink in size during execution. Example: list.
6
New cards
Array
An indexed collection of elements of the same type. In Python, often referred to as a list.
7
New cards
1D Array
Represents a vector, indexed by a single integer.
8
New cards
2D Array
Represents a matrix, indexed by two integers.
9
New cards
nD Array
Set of elements indexed by a tuple of n integers.
10
New cards
Record
A collection of related fields representing one unit of data (e.g., a row in a table).
11
New cards
Field
A single piece of data within a record (e.g., a column in a table).
12
New cards
Text File
Stores data in human-readable characters. Common operations: reading, writing.
13
New cards
Binary File
Stores data in non-text formats such as images or videos.
14
New cards
Queue
Linear data structure using FIFO (First In, First Out). Elements added to rear, removed from front.
15
New cards
Circular Queue
Queue with a fixed-size ring buffer, rear connects to front.
16
New cards
Priority Queue
Queue where items have priority; higher priority items are dequeued first.
17
New cards
Enqueue
Add item to the rear of a queue.
18
New cards
Dequeue
Remove item from the front of a queue. Raises exception if queue is empty.
19
New cards
Front (Queue)
The front/first node of the queue.
20
New cards
Rear (Queue)
The rear/last node of the queue.
21
New cards
Peek (Queue)
Returns the value at the front without removing it. Raises exception if empty.
22
New cards
IsEmpty (Queue)
Returns True if the queue is empty, else False.
23
New cards
Stack
Data structure using LIFO (Last In, First Out). Like a stack of plates.
24
New cards
Push
Add item to the top of the stack.
25
New cards
Pop
Remove item from the top of the stack. Raises exception if empty.
26
New cards
Top (Stack)
The top node of the stack.
27
New cards
Peek (Stack)
View the top item without removing. Raises exception if empty.
28
New cards
IsEmpty (Stack)
Returns True if stack is empty, else False.
29
New cards
Stack Overflow
Error when trying to push onto a full stack.
30
New cards
Stack Underflow
Error when trying to pop from an empty stack.
31
New cards
Stack Frame
Part of the call stack storing function execution data.
32
New cards
Graph
A collection of vertices (nodes) and edges (connections).
33
New cards
Vertex
A node in a graph.
34
New cards
Edge
Connection between two vertices.
35
New cards
Undirected Graph
Edges are bidirectional.
36
New cards
Directed Graph
Edges have a direction (one-way connections).
37
New cards
Weighted Graph
Edges have weights/costs.
38
New cards
Connected Graph
A path exists between every pair of vertices.
39
New cards
Disconnected Graph
Not all vertices are connected.
40
New cards
Cyclic Graph
Contains cycles, i.e., paths that loop back to the start.
41
New cards
Acyclic Graph
No cycles present.
42
New cards
Adjacency Matrix
2D array showing edge connections between vertices.
43
New cards
Adjacency List
Dictionary mapping nodes to a list of connected nodes.
44
New cards
Matrix Pros
Fast lookups, easy to implement.
45
New cards
Matrix Cons
Uses more space (O(n^2)).
46
New cards
List Pros
Efficient for sparse graphs, uses less space.
47
New cards
List Cons
Slower lookups than matrices.
48
New cards
Tree
A connected, undirected, acyclic graph.
49
New cards
Root
Starting node of a tree.
50
New cards
Leaf
Node with no children.
51
New cards
Parent-Child
Relationship where one node connects to its descendants.
52
New cards
Binary Tree
Each node has at most two children.
53
New cards
Binary Search Tree (BST)
Left subtree has smaller values; right subtree has larger.
54
New cards
Tree Applications
Binary search trees, decision trees, heaps.
55
New cards
Hash Table
Data structure using a hash function to assign data to a unique address.
56
New cards
Hash Function
Converts input (key) into an index or address.
57
New cards
Collision
Two keys hash to the same index.
58
New cards
Chaining
Handling collisions using linked lists at each address.
59
New cards
Open Addressing
Resolve collisions by finding another open slot (e.g. add 1).
60
New cards
Double Hashing
Use a second hash function on collision.
61
New cards
Good Hash Function Properties
Shortening, deterministic, diffusing, one-way, collision resistant.
62
New cards
Simple Hash Example
Address = key mod number_of_slots.
63
New cards
Dictionary
A data structure of key-value pairs. Implemented using {} in Python.
64
New cards
dict["key"]
Retrieves the value associated with 'key'.
65
New cards
Vector
A quantity with both direction and magnitude. Represented as [x, y, z].
66
New cards
Scalar
A quantity with magnitude only.
67
New cards
Vector Addition
Add corresponding components: [a1, a2] + [b1, b2] = [a1+b1, a2+b2].
68
New cards
Vector Subtraction
Subtract corresponding components: [a1, a2] - [b1, b2] = [a1-b1, a2-b2].
69
New cards
Scalar Multiplication
Multiply each component by a scalar: 3*[a, b] = [3a, 3b].
70
New cards
Vector Notation
Arrow from origin or ℝ^n vector notation.
71
New cards
Vector Representation (Array)
Fixed-size list: [1.1, 2.3].
72
New cards
Vector Representation (Dictionary)
Index-keyed dictionary: {0: 1.1, 1: 2.3}.
73
New cards
Vector as Function
Function f: S → ℝ mapping index to real value.
74
New cards
Vector Applications
Used in graphics, simulations, multi-dimensional data.
75
New cards
Convex Combination
w = αu + βv where α+β=1 and α, β ≥ 0. Lies within span of u and v.
76
New cards
Dot Product
Sum of products of components. a·b = Σ(ai * bi).
77
New cards
Dot Product Uses
Find angle: cos(θ) = (a·b)/(|a||b|).
78
New cards