Bubble_Sort_Pseudocode_Guide_with_Shapes.pptx

limjetweeyahoocom 0 views 13 slides Oct 10, 2025
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

Bubble Sort


Slide Content

🔄 Bubble Sort Pseudocode Guide for Beginners A step-by-step beginner-friendly guide to Bubble Sort Lim Jet Wee

How Bubble Sort Works Bubble Sort repeatedly compares two adjacent items in a list and swaps them if they are in the wrong order.

It 'bubbles' the largest value to the end of the list each time. Lim Jet Wee

📦 Full Pseudocode Lim Jet Wee

✅ Step 1: Understand the Problem You have a list (e.g., Temperature[1] to Temperature[10]) and want to sort it in ascending order using Bubble Sort. Lim Jet Wee

🧩 Step 2: Define Your Variables First ← 1 // The starting index of the list
Last ← 10 // The ending index of the list Lim Jet Wee

🔁 Step 3: Start a Repeat Loop REPEAT
Swap ← FALSE // Assume no swaps will happen in this pass

We use Swap to check if any items were swapped.
If no swaps, the list is already sorted. Lim Jet Wee

🔄 Step 4: Loop Through the List FOR Index ← First TO Last - 1

Loop through the list, comparing pairs of items. Lim Jet Wee

🔍 Step 5: Compare and Swap if Needed IF Temperature[Index] > Temperature[Index + 1] THEN
Temp ← Temperature[Index]
Temperature[Index] ← Temperature[Index + 1]
Temperature[Index + 1] ← Temp
Swap ← TRUE
ENDIF

If the current item is greater than the next one, swap them. Lim Jet Wee

🔚 Step 6: End the FOR Loop NEXT Index

Finish going through the list once. Lim Jet Wee

📉 Step 7: Shrink the Range Last ← Last - 1

After one full pass, the largest item is already in place, so reduce the range. Lim Jet Wee

🛑 Step 8: Check If Sorting is Done UNTIL (NOT Swap) OR Last = 1

Stop the loop if no swaps happened (list is sorted).
Also stop if only one item is left. Lim Jet Wee

📦 Full Pseudocode Lim Jet Wee

🧠 Summary for Students • Bubble Sort compares side-by-side values and swaps if needed.
• It repeats until the list is sorted.
• After each pass, the largest unsorted item is at its correct position at the end. Lim Jet Wee