Back to marketplace

2.3.1 Algorithms

No description yet. This curated deck is ready for daily study.

Total cards: 24•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (24)

#1
Front (Question)

What are the pros and cons of a bubble sort?

Back (Answer)

Pros • Okay for smaller data sets Cons • Inefficient for larger data sets. • Very inefficient for reversing the order of a data set. • The most inefficient algorithm of the sorts studied in the course.

#2
Front (Question)

What is the purpose of the temp variable in a bubble sort?

Back (Answer)

Allows you to swap two values without overwriting one of them.

#3
Front (Question)

What is the purpose of the swapsMade Boolean in a bubble sort?

Back (Answer)

When the algorithm reaches the end of a pass, if the Boolean is true then the list may not be sorted, so it needs to make at least one more pass. If the end of the pass is reached and it is false, then then you have gone through the list, made no changes, so the list is sorted.

#4
Front (Question)

Show the steps of a bubble sort on the following array - clearly label the passes. [95, 10, 5, 33, 100, 77, 45]

Back (Answer)

Card back image
#5
Front (Question)

Describe the steps of a bubble sort on an array.

Back (Answer)

• Compares each pair of data • If they are in the correct order it moves to the next pair • If they are in the wrong order it swaps them • Continues to the end of the array • If there has been a swap it checks again • If there have been no swaps then it is sorted

#6
Front (Question)

Write / describe the pseudocode for a Bubble Sort

Back (Answer)

Card back image
#7
Front (Question)

Describe how an insertion sort works

Back (Answer)

• Splits the list into sorted and unsorted • The first item in the list is classed as sorted • Insert one number at a time from the unsorted list into correct position by moving backwards through the list of sorted numbers

#8
Front (Question)

What are the pros and cons of the insertion sort?

Back (Answer)

Pros * Simplest Sort to code * One of the fastest algorithms for sorting very small arrays Cons * Impractical for sorting large arrays.

#9
Front (Question)

Show the steps of an insertion sort on the following array [95, 10, 5, 33, 100, 77, 45]

Back (Answer)

Card back image
#10
Front (Question)

Write / describe the pseudocode for an Insertion Sort

Back (Answer)

Card back image
#11
Front (Question)

Describe how a linear search works

Back (Answer)

• Start at the first element, if equal to search item, then report found • If not equal, then move to next element (incrementally) • Repeat for all elements until found or the end of the list reached

#12
Front (Question)

What are the pros and cons of a linear search?

Back (Answer)

Pros * Can work on both ordered and unordered data sets * Can have multiple processors searching different areas at the same time. * Scales very with additional processors Cons * If the item is not in the list, then all items will be searched, this makes is a slow algorithm for large lists.

#13
Front (Question)

Write / describe the pseudocode for a Linear Search

Back (Answer)

Card back image
#14
Front (Question)

Describe a binary search

Back (Answer)

• Find mid-point, if equal to mid-point then report found • If less than mid-point then make sub-list from left • If greater than mid-point then make sub-list from right • Repeat with sub-list until found or sub-list is empty

#15
Front (Question)

Describe the technicalities of a binary search

Back (Answer)

• Calculate array midpoint by adding the array lower bound to the array upper bound, using the DIV command divide it by 2 (equivalent to rounding down) • Compare array midpoint with value to search for, if equal set found flag to true • if array midpoint < value to search for, change lowerbound to equal midpoint + 1 • if array midpoint > value to search for, change upperbound to equal midpoint – 1 • Repeat until lowerbound is greater than or equal to upperbound

#16
Front (Question)

Demonstrate a binary search on the following array to find the value 47 [4, 7, 8, 21, 46, 47, 51]

Back (Answer)

• Find the mid-point in the list: 21 (index 3) • Compare it to the value 47, match = false • 47 is greater than middle point, so new subset is 46-51 • Find the middle of the new subset (47 index 5) • Is this value equal to 47, true Search finishes

#17
Front (Question)

Describe the pros and cons of a binary search

Back (Answer)

Pros * Halves the list each time so works well on large data sets * Efficient as does not need to search every single element/uses divide and conquer Cons * Only works on an ordered set of data

#18
Front (Question)

Write / describe the pseudocode for a Binary Search

Back (Answer)

Card back image
#19
Front (Question)

Write the pseudocode to push an item to a stack

Back (Answer)

lines 7 and 8 could swap around depending on how the stack pointer is used

Card back image
#20
Front (Question)

Write the pseudocode to pop an item to a stack

Back (Answer)

Card back image
#21
Front (Question)

Keywords to describe a queue

Back (Answer)

• Dynamic Data Structure • Enqueue • Dequeue • First in First Out • Peek • Front Pointer • Rear Pointer • Circular / Non-Circular

#22
Front (Question)

Keywords to describe a stack

Back (Answer)

• Dynamic Data Structure • Pop • Push • First in Last Out (LIFO) • Peek • Top Pointer

#23
Front (Question)

Write the pseudocode to dequeue an item to a queue

Back (Answer)

Card back image
#24
Front (Question)

Write the pseudocode to enqueue an item to a queue

Back (Answer)

lines 7 and 8 could swap around depending on how the stack pointer is used

Card back image