Anki Deck Changes

Commit: c90320ab - fix insertion sort runtime

Author: obrhubr <obrhubr@gmail.com>

Date: 2026-01-12T18:53:26+01:00

Changes: 1 note(s) changed (0 added, 1 modified, 0 deleted)

Note 1: ETH::A&D

Deck: ETH::A&D
Note Type: Algorithms
GUID: LqP`8lU$&o
modified

Before

Front

ETH::1._Semester::A&D::04._Sorting_Algorithms::3._Insertion_Sort
Runtime of Insertion Sort?

Back

ETH::1._Semester::A&D::04._Sorting_Algorithms::3._Insertion_Sort
Runtime of Insertion Sort?

Best Case: \(O(n)\)
Worst Case: \(O(n^2)\)


This insertion is not in constant time! We have to swap with each previous element!

After

Front

ETH::1._Semester::A&D::04._Sorting_Algorithms::3._Insertion_Sort
Runtime of Insertion Sort?

Back

ETH::1._Semester::A&D::04._Sorting_Algorithms::3._Insertion_Sort
Runtime of Insertion Sort?

Best Case: \(O(n \log n)\)
Worst Case: \(O(n^2)\)


This insertion is not in constant time! We have to swap with each previous element!
Field-by-field Comparison
Field Before After
Runtime <div>Best Case:&nbsp;\(O(n)\)</div><div>Worst Case:&nbsp;\(O(n^2)\)</div> <div>Best Case:&nbsp;\(O(n \log n)\)</div><div>Worst Case:&nbsp;\(O(n^2)\)</div>
Tags: ETH::1._Semester::A&D::04._Sorting_Algorithms::3._Insertion_Sort
↑ Top