Fundamentals of algorithms

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

1/26

flashcard set

Earn XP

Description and Tags

a level computer science topic three paper one aqa

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

27 Terms

1
New cards

what are the two types of simple graph traversal algorithms

breadth first search, and depth first search

2
New cards

what is breadth first search (BFS) used for

finding the shortest path via a node based method

3
New cards

what is depth first search (DFS) use for?

maze navigation via an edge based technique

4
New cards

how does BFS work

visits all nodes from a given vertex before moving on to their neighbouring nodes, and repeats this layer by layer, adding nodes onto the queue so long as they are not already in the list of visited nodes

5
New cards

How does DFS work

makes use of a stack and traverses as far down the graph from the start node, until it finds an unexplored path, it then repeats this consecutively until all paths have been explored.

  • edges are visuted and nodes at the end of the edges are added to the visited nodes list

6
New cards

what are the two approaches that can be applied to DFS

iterative or recursive

7
New cards

what are the three types of simple tree traversal algorithms

pre order, post order and in order

8
New cards

how does pre order tree traversal work and why is it used

it works via following the root to left to right and is used in copying trees

9
New cards

how does the post order tree traversal work and why is it used

it works via following left to right to root, and is used to convert from infix to RPN

10
New cards

how does in order tree traversal work and why is it used

it works via following the left to the root to the right, and is used to output the contents of a binary tree in ascending order

11
New cards

what are the advantages of reverse polish notation

  • operators are in the order which they need to be used

  • removes the need for brackets

  • expressions are in a form suitable for the stack based approach

  • interperators based on stacks can then be used

  • potentially faster execution as equations are in format that computer uses

12
New cards

what is referred to as the time complexity

how the runtime of an algorithm grows relative to the size of the input data

13
New cards

what are the three types of searches for algorithms

linear search, binary search, binary tree search

14
New cards
15
New cards
16
New cards

what is a binary search

a search on an ordered list, where the midpoint is found and the list is divided into half, where one half is discarded and the process repeats until there is only the searched item

17
New cards

what is the time complexity for a binary search

O(logn)

18
New cards

what is a binary tree search

when a list is ordered into a binary tree, and traversed to the left or the right depending on what is being searched for

19
New cards

what is the time complexity for a binary tree search

O(logn)

20
New cards

what are the two types of sorting algorithms

bubble sort and merge sort

21
New cards

what is a bubble sort

where elements are swapped if they are in the wrong order until the data is ordered via multiple passes through the list

22
New cards

what is the time complexity of a bubble sort

O(n²)

23
New cards

what is a merge sort

when a list of data items are divided into smaller subarrays that are then ordered and merged back together

24
New cards

what is the time complexity for a merge sort

O(nlogn)

25
New cards

what is an example of an optimizational algorithm

Dijkstra’s shortest path algorithm

26
New cards

what does dijkstra’s shortest path algorithm do?

finds the shortest path between one specified node and all other nodes on a weighted graph

27
New cards

what is dijkstras shortest path algorithm used for?

GPS navigation, IP routing, telephone networking