4.3 Fundamentals of Algorithms AQA Comp Sci

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

1/45

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

46 Terms

1
New cards
What is graph traversal?
Graph traversal is the process of visiting all the nodes in a graph systematically.
2
New cards
What is Breadth-First Search (BFS)?
A graph traversal method that explores all neighbouring nodes before going deeper.
3
New cards
Which data structure does BFS use?
Queue (FIFO - First In, First Out).
4
New cards
What is BFS used for?
Used to find the shortest path in an unweighted graph.
5
New cards
What is Depth-First Search (DFS)?
A graph traversal method that explores as far down a path as possible before backtracking.
6
New cards
Which data structure does DFS use?
Stack (LIFO - Last In, First Out).
7
New cards
What is DFS used for?
Used in maze navigation and pathfinding.
8
New cards
What is tree traversal?
The process of visiting all the nodes in a tree.
9
New cards
What are the three types of tree traversal?
Pre-Order, In-Order, and Post-Order.
10
New cards
What is Pre-Order traversal?
Root -> Left -> Right; used for copying a tree.
11
New cards
What is In-Order traversal?
Left -> Root -> Right; used to retrieve elements in a sorted order for BSTs.
12
New cards
What is Post-Order traversal?
Left -> Right -> Root; used for expression evaluation (Reverse Polish Notation).
13
New cards
What is Reverse Polish Notation (RPN)?
A mathematical notation where operators follow their operands.
14
New cards
What does RPN eliminate?
The need for brackets in mathematical expressions.
15
New cards
What data structure is used in RPN evaluation?
Stack.
16
New cards
Where is RPN used?
In compilers, calculators, and interpreters.
17
New cards
How does RPN relate to tree traversal?
If a binary tree uses in-fix notation, RPN can be derived using DFS.
18
New cards
What is a linear search?
A search that checks each element of a list for the target value.
19
New cards
What is the time complexity of a linear search?
O(n).
20
New cards
What does a linear search return if the target is not found?
-1
21
New cards
What is a binary search?
A search algorithm that divides the search space in half to locate the target value.
22
New cards
What condition must be met for binary search to work?
The list must be sorted.
23
New cards
What is the time complexity of a binary search?
O(log n).
24
New cards
What is the first step in binary search?
Find the middle element.
25
New cards
What happens if the middle element matches the target?
Return the index.
26
New cards
What happens if the target is smaller than the middle element?
Search the left half.
27
New cards
What happens if the target is greater than the middle element?
Search the right half.
28
New cards
What is a binary search tree (BST)?
A tree where each node has at most two children; left subtree < root, right subtree > root.
29
New cards
What traversal gives sorted order in BST?
In-Order Traversal.
30
New cards
How does a binary tree search work?
Start at root, compare target to root, recurse left or right depending on comparison.
31
New cards
What is the time complexity of binary tree search?
O(log n).
32
New cards
What is Bubble Sort?
A sorting algorithm that swaps adjacent elements if they are in the wrong order.
33
New cards
How does Bubble Sort work?
Compare adjacent elements and swap if needed; repeat until sorted.
34
New cards
What is the time complexity of Bubble Sort?
O(n^2).
35
New cards
What is Merge Sort?
A divide-and-conquer algorithm that recursively splits, sorts, and merges subarrays.
36
New cards
How does Merge Sort work?
Split array recursively, sort subarrays, merge them back together.
37
New cards
What is the time complexity of Merge Sort?
O(n log n).
38
New cards
Why is Merge Sort faster than Bubble Sort?
It uses divide and conquer, reducing comparisons.
39
New cards
What is a drawback of Merge Sort?
Uses more memory due to recursion.
40
New cards
What is Dijkstra's Algorithm?
An optimization algorithm for finding the shortest path from a start node to all other nodes in a weighted graph.
41
New cards
Where can Dijkstra's Algorithm be used?
Circuit board design, route planning, game strategy, project management.
42
New cards
What type of algorithm is Dijkstra's?
Greedy and dynamic.
43
New cards
How does Dijkstra's Algorithm start?
Assigns a temporary distance of 0 to the start node and ∞ to others.
44
New cards
Which data structure does Dijkstra's use?
Priority Queue.
45
New cards

How is Dijkstra’s similar to BFS?

Both explore neighbouring nodes, but Dijkstra considers weights.
46
New cards
What is graph traversal? (Detailed)
Graph traversal is the process of visiting all the nodes in a graph systematically. This is an extended explanation.