Why is Comparison Sorting Ω(n*log(n))? | Asymptotic Bounding & Time Complexity

  Рет қаралды 3,014

Interview Pen

Interview Pen

Күн бұрын

Visit Our Website: interviewpen.com/?...
Join Our Discord (24/7 help): / discord
Join Our Newsletter - The Blueprint: theblueprint.dev/subscribe
Like & Subscribe: / @interviewpen
This is an example of a full video available on interviewpen.com. Check out our website to find more premium content like this!
Why are comparison sorting algorithms Ω(n*log(n))? In this in-depth video, we examine the fundamentals of comparison sorting algorithms and their lower bound of Ω(n*log(n)) time complexity. This video provides a comprehensive look at various comparison-based sorting techniques, such as Merge Sort, Quick Sort, and Heap Sort, and explains their significance in the field of computer science.
We delve into the decision-tree model, a powerful tool for understanding the minimum number of comparisons required by any comparison sorting algorithm. Through this model, we'll learn the reasoning behind the lower bound of Ω(n*log(n)) and why no algorithm can outperform this bound when it comes to sorting using comparisons.
Throughout the video, we'll also discuss various factors and principles that impact the performance of sorting algorithms, including their practical applications, limitations, and scenarios where they perform optimally. By the end of this video, you'll have a solid understanding of the Ω(n*log(n)) lower bound and its significance in the broader context of algorithm analysis and efficiency.
Table of Contents:
0:00 - The Core Problem
0:33 - Comparison Sorting Algorithms
2:04 - No Special Knowledge
2:25 - Visit interviewpen.com
2:44 - Logarithm Review
4:17 - Decision Tree
5:40 - Ambiguity Leading to Worst Case
6:49 - Binary Tree Levels
7:25 - Binary Tree Nodes
7:57 - Binary Tree Levels (continued)
9:27 - Worst Depth/Height
9:41 - Input Permutations
11:18 - Putting It All Together
11:39 - Relating Levels to Terminal Comparison States
13:11 - Stirling's Approximation
13:47 - Expanding Out Terms
14:56 - Left Side
15:36 - Final Equation
15:49 - The Answer
16:11 - Closing
16:46 - Visit interviewpen.com
Erratum:
2:45 - log(n) is defined for values greater than 0, rather than just greater than 1
10:39 - I meant to say "a final permutation that is the result of all decisions that led to it, etc"
Socials:
Twitter: / interviewpen
Twitter (The Blueprint): / theblueprintdev
LinkedIn: / interviewpen
Website: interviewpen.com/?...

Пікірлер: 17
@interviewpen
@interviewpen Жыл бұрын
Thanks for watching! Visit interviewpen.com/? for more great Data Structures & Algorithms + System Design content 🧎
@ResonantFractal
@ResonantFractal Жыл бұрын
Thank you for all the awesome material!
@interviewpen
@interviewpen Жыл бұрын
sure!
@user-mk9tq9mj8c
@user-mk9tq9mj8c 4 ай бұрын
great video, thank you so much!
@interviewpen
@interviewpen 4 ай бұрын
Thanks!
@codewithawaisahmad
@codewithawaisahmad Ай бұрын
awesome explained brother
@interviewpen
@interviewpen Ай бұрын
Thanks!
@n0ks
@n0ks Жыл бұрын
Very clear explanation, thanks. What is the program that you use to make your presentations?
@interviewpen
@interviewpen Жыл бұрын
cool - an we use GoodNotes
@aacfox
@aacfox 4 ай бұрын
the thing i don't hear from anyone is that any comparison sorts can be reduced to two operations: binary search in new (initially empty) sorted array (search for appropriate index of another variable in there), and insertion at that index. First is O(logn) (for much more obvious reasons than all of this), second-O(n). And since the logic is that you need exactly n insertions and one binary search before every insertion, overall complexity will be just a multiplication of these. Which results in O(nlogn).
@interviewpen
@interviewpen 4 ай бұрын
Good point, that's another way to think about it. Thanks for watching!
@serbandan6186
@serbandan6186 Жыл бұрын
Video Idea: Design a tiktok recomandation algorithm.
@interviewpen
@interviewpen Жыл бұрын
Good idea - added to backlog. Thanks for watching.
@vaijantachaure2493
@vaijantachaure2493 Жыл бұрын
This is awesome, thanks for the detailed explanation with the math! It gives a great view why we can never do better than Ω(nlogn) when it comes to comparison sorting.
@interviewpen
@interviewpen Жыл бұрын
thanks & thanks for watching! (aside: we can't do better than Ω(n*log(n) rather than O(n*log(n), big O is an upperbound so it guides on bounding from above, we want to bound from below since we are looking for the best we can do. You can upperbound in the best, average, & worst case. You can lowerbound in the best, average, & worse case. Lower-bounding the best you can do makes the most sense in this discussion.)
@dzuchun
@dzuchun Жыл бұрын
3:16 log(n) being undefined for n < 1 is cursed. (It's actually n
@interviewpen
@interviewpen Жыл бұрын
Good callout - added to description
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 426 М.
Why Comparison Based Sorting Algorithms Are Ω(n*lg(n))
17:10
Back To Back SWE
Рет қаралды 61 М.
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 537 М.
Why sorting takes at least O(n log n) time
6:50
Computer Science by Pandey
Рет қаралды 4,4 М.
The Algorithm Behind Spell Checkers
13:02
b001
Рет қаралды 407 М.
What makes Kafka special? | System Design
6:27
Interview Pen
Рет қаралды 15 М.
What Is Big O? (Comparing Algorithms)
8:15
Undefined Behavior
Рет қаралды 169 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,3 МЛН
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 320 М.
Even God's sorting takes  Ω( n logn ) comparisons in the worst case
11:38
GATEBOOK VIDEO LECTURES
Рет қаралды 19 М.
Design a Fault Tolerant E-commerce System | System Design
8:17
Interview Pen
Рет қаралды 26 М.
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01