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.