[DSA] Sorting Algorithms

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

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

Basic Sorting Algorithms

  1. Bubble Sort

  2. Selection Sort

  3. Insertion Sort

  4. Merge Sort

  5. Quick Sort

  6. Shell Sort

2
New cards

Bubble Sort

  • Simple comparison-based algorithm

  • Repeatedly swaps adjacent elements if they are in the wrong order

3
New cards

Selection Sort

  • Selects the minimum (or maximum) and places it in the correct position

4
New cards

Insertion Sort

  • Builds the sorted array one item at a time

5
New cards

Merge Sort

  • Divide-and-conquer algorithm

  • Recursively divides arrays and merges sorted halves

6
New cards

Quick Sort

  • Divide-and-conquer algorithm

  • Uses a pivot to partition the array

7
New cards

Shell Sort

  • Generalization of insertion sort

  • Sorts elements far apart first

8
New cards

Bubble Sort

  • Concept: compare adjacent elements, and swap them if they’re in the wrong order. Repeat the process until the list is sorted.

<ul><li><p>Concept: compare adjacent elements, and swap them if they’re in the wrong order. Repeat the process until the list is sorted.</p></li></ul><p></p>
9
New cards

Selection Sort

  • Concept: find the smallest (or largest) element and move it to its correct position in the sorted part of the array.

<ul><li><p>Concept: find the smallest (or largest) element and move it to its correct position in the sorted part of the array.</p></li></ul><p></p>
10
New cards

Insertion Sort

  • Concept: Build the sorted list one element at a time by inserting each new item into the correct position.

<ul><li><p>Concept: Build the sorted list one element at a time by inserting each new item into the correct position.</p></li></ul><p></p>
11
New cards

Merge Sort

  • Concept: A divide-and-conquer algorithm.

  • Divide the array into halves back together.

<ul><li><p>Concept: A divide-and-conquer algorithm.</p></li><li><p>Divide the array into halves back together.</p></li></ul><p></p>
12
New cards

Quick Sort

  • Concept: Also a divide-and-conquer algorithm.

  • Choose a pivot, partition elements into smaller or larger than the pivot

  • Recursively sort each side

<ul><li><p>Concept: Also a divide-and-conquer algorithm.</p></li><li><p>Choose a pivot, partition elements into smaller or larger than the pivot</p></li><li><p>Recursively sort each side</p></li></ul><p></p>
13
New cards

Shell Sort

  • A generalized insertion sort.

  • Starts by comparing elements far apart, then reduces the gap.

  • Final pass is a normal insertion sort with small gaps.

<ul><li><p>A generalized insertion sort.</p></li><li><p>Starts by comparing elements far apart, then reduces the gap.</p></li><li><p>Final pass is a normal insertion sort with small gaps.</p></li></ul><p></p>
14
New cards

What is “Gap = 3”

knowt flashcard image