Sorting algorithms: bubble, insertion and merge sort
플레이하며 배우기
이 문제들을 풀어 에너지를 얻은 뒤 낚시하고 탐험하세요. 계정이 필요 없어요.
교육자를 위해: Sorting algorithms: bubble, insertion and merge sort(Computer Science, Algorithms)을(를) 위한 바로 쓸 수 있는 수업 슬라이드, 복습 노트 — 수업에 사용하거나, 학습자들이 실시간 게임으로 즐기는 인터랙티브 클래스 활동으로 진행하세요.
Sorted data is easier to search (binary search) and to display. Sorting algorithms put items in order (ascending or descending).
Bubble sort
Repeatedly compare adjacent pairs and swap them if they are in the wrong order. After each pass the largest unsorted item "bubbles" to the end. Stop when a complete pass makes no swaps.
Example: 5, 2, 4 → compare 5 and 2, swap: 2, 5, 4 → compare 5 and 4, swap: 2, 4, 5. A further pass has no swaps, so it stops.
Simple but slow for large lists.
Bubble sort
Insertion sort
Treat the first item as sorted. Take the next item and insert it into the correct position among the sorted items by shifting larger items right. Repeat until all items are sorted.
Efficient for small or nearly sorted lists.
Insertion sort
Merge sort
A divide and conquer algorithm: split the list into halves repeatedly until each part has one item, then merge the parts back together in order.
Much faster for large lists but uses more memory, and it is more complex.
Merge sort
Comparing
Bubble: simple, slow. Insertion: good for small lists. Merge: fast, memory-hungry.
슬라이드
Sign up free to view the lesson slides
Step through every slide for this topic — plus flashcards and revision notes — with a free account.