What Is Asymptotic Analysis? And Why Does It Matter? A Deeper Understanding of Asymptotic Notation.

Back To Back SWE · Beginner ·⚡ Algorithms & Data Structures ·7y ago

Key Takeaways

Asymptotic analysis is a crucial concept in algorithms, and understanding it is essential for accurately determining the complexity of an algorithm. The video explains the concept of asymptotic behavior, why it matters, and how it is used to analyze the performance of algorithms.

Full Transcript

okay so what we're gonna discuss today is asymptotic bounding it's very important for algorithms and this is generally something that if you don't have a sound fundamental understanding of you're going to be mistaken in an interview you're going to say a complexity that's completely wrong again if you have not subscribed to the channel subscribe to a channel like this video so when we see a single four loop doesn't that mean linear time when we see two for loops doesn't that mean quadratic time right not always so I think what we have to look at first is a little math and a little calculus I was never amazing at calculus but to really understand asymptotic behavior we need to look at what asymptotic really means so what is asymptotic behavior really mean so I have a graph here so what is this graph so maybe I don't know the equation for this graph but I can tell about where this graph is going so if I took the limit as X approaches infinity if I go towards infinity where does the Y value go and you see that the Y value goes towards zero so this is what this looks like okay so now we see the asymptotic behavior of the graph of 1 over X which is what this graph is this is the graph of 1 over X the asymptotic behavior of it is that as X approaches infinity we get closer and closer to 0 and you notice our points of interest what we're interested in here is tail behavior the idea of asymptotic sand looking at an asymptotic behavior is we want to see how does the graph behave getting into very very large X values into very large values this is the idea of asymptotic complexity ok so now we know what asymptotic means it means tail behavior but wait why don't I just measure the elapsed to real time why don't I just take the wall time why don't I just do that why don't I just do what I see in Li code I mean I run my code on LI code and it tells me this ran in this many milliseconds so I guess I know how strong my algorithm is right so that is not the best way to approach things so in computer science often problems are applied at a grand scale like if you're writing an algorithm for a company like Facebook or a large company it's going to be used across millions and millions of users and large inputs to an algorithm so our best point of interest is to see how does this behave on the tail end how does this behave as input gets very large we only see the true measure of performance of an algorithm when we have very very large input and this is why asymptotic complexity intrigues us in computer science so let's look at an example to really drill this in so we have an algorithm insertion sort that is going to do two times N squared comparisons so this could be any random implementation and for some reason it does two times N squared comparisons so we have a merge sort implementation that does 50 times n log n comparisons so we know that insertion sort is slower and don't worry about the constants here they're just arbitrarily chosen so we have computer a running the slower algorithm insertion sort but computer a runs at ten billion instructions per second and we have computer be running the faster algorithm but computer B is 1,000 times slower than computer a it is 1,000 times slower but it's running a faster algorithm so what is the approximate wall time going to be for both of these computers computer a and computer B okay so can you guess them now now do we have an idea of which is going to be faster okay so we see that the actual running time for the faster computer is going to take 5.5 hours and is running a slower algorithm and we see that computer B is a thousand times slower it is a thousand times slower but it's going to only take 20 minutes to run so why was this algorithm faster and why was this algorithm slower why did the slower algorithm lose on a computer is a thousand times faster so the answer to that question lies in the idea of asymptotic bounding and looking at the asymptotic behavior so I think something to really drill in this concept is looking at linear time looking at the class of poundings that we call linear time so whenever I say linear time I say this in a lot of videos I say we're going to have a linear time bound what does that actually mean so I want us to look at a few different graphs so what we're going to do is I'm going to draw a few graphs and we're going to notice something in common between them and is going to lead us to the most critical word in all of that we're doing so let me start drawing graphs so here is our first graph y equals 1 over 2x okay so we have one graph so let's draw another graph ok so here is another graph we see that this is the graph of y equals x so let's draw two more graphs just to really hammer this point home ok so I just drew the graph y equals 2x and I just drew the graph y equals 3x so what do you notice about these graphs I want you to mentally imagine this if i zoom out when our input is super super super large when i zoom far outwards what are all of these going to do what will they all look like do you see how all of these are lines do you see how all of these are lines all of them have these same tail behavior all of these graphs have the same behavior so the key thing behind asymptotic complexity is the whole point of taking asymptotic measures is so that we know how a graph is behaving when input is very large when input is very large that is when we see a graphs true colors so do you see why we drop constants if I have a Big O of 1/2 of n so why do I drop the 1/2 why does it just become Big O of n why is Big O of N and asymptotic measure so you see this is the exact area because all of these graphs will do the same thing when we get very very large input they will scale in a linear fashion this is a linear scaling when I say log n time when I say linear time when I say quadratic time when I say cubic time when I say factorial time when I say exponential time what am I saying I'm not describing a individual graph I am describing a class of functions I'm describing a class of behaviors and that is what this is all about okay and that is all for this video if you like this video like if this video was clear if this made things a little clearer about why we use Big O notation why we do asymptotic complexities LIKE the video and subscribe to the channel I think every one of these videos is a tiny building block to build a larger picture to make you very competent and able in the interview that is the key to this we're just slowly building that knowledge set until you are in a very strong level along with your Lea code studying to do well in the interview so that's what this is all about so awkward [Music]

Original Description

Free 5-Day Mini-Course: https://backtobackswe.com Try Our Full Platform: https://backtobackswe.com/pricing 📹 Intuitive Video Explanations 🏃 Run Code As You Learn 💾 Save Progress ❓New Unseen Questions 🔎 Get All Solutions First, we must ask what asymptotic means. Well, you have probably heard of the word "asymptote". An asymptote is a "line that continually approaches a given curve but does not meet it at any finite distance". Therefore, asymptotic analysis is the analysis of tail behaviors not reaching any finite point. It is a method of describing limiting behavior. Wall Time vs. Asymptotic Complexity Well...why not just measure the seconds our code takes to run? And get the Elapsed real time (wall time)?...like Leetcode. So why do we care about this...well in computer science we often deal with problems that are at a grand scale with inputs to the order of millions and billions. And thus, the true measure of the efficiency of an algorithm is best expressed in its tail behavior on very large input. It only then shows its true colors. An Expression of Asymptotic Behaviour Insertion Sort: 2 * n^2 Merge Sort: 50 * n * log(n) We have 2 computers: Computer A: runs 10 Billion instructions / second Computer B: runs 10 Million instructions / second Computer A is 1000x faster than Computer B Computer A runs insertion sort, Computer B runs merge sort How long will each computer take to sort 10 million numbers? Computer A: 5.5 hours Computer B: 20 minutes A computer that runs 1000x faster lost horrendously to a computer that runs 1000x slower than it. But the thing is that insertion sort will be faster for an initial amount, but it will lose as the input gets larger (and that's what we care about and what is a true expression of its efficiency). ++++++++++++++++++++++++++++++++++++++++++++++++++ HackerRank: https://www.youtube.com/channel/UCOf7UPMHBjAavgD0Qw5q5ww Tuschar Roy: https://www.youtube.com/user/tusharroy2525 GeeksForGeeks: https:/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Back To Back SWE · Back To Back SWE · 43 of 60

1 4 Tips To Learn Java Programming As Fast As Possible As A Beginner
4 Tips To Learn Java Programming As Fast As Possible As A Beginner
Back To Back SWE
2 3 Mistakes Beginners Make When First Learning Java and Android Development
3 Mistakes Beginners Make When First Learning Java and Android Development
Back To Back SWE
3 How To Get A Job At Google | The Ultimate Guide To Algorithmic/Coding Interviews
How To Get A Job At Google | The Ultimate Guide To Algorithmic/Coding Interviews
Back To Back SWE
4 The Ultimate Big O Notation Tutorial (Time & Space Complexity For Algorithms)
The Ultimate Big O Notation Tutorial (Time & Space Complexity For Algorithms)
Back To Back SWE
5 Total Occurrences Of K In A Sorted Array (Facebook Software Engineering Interview Question)
Total Occurrences Of K In A Sorted Array (Facebook Software Engineering Interview Question)
Back To Back SWE
6 The N Queens Problem using Backtracking/Recursion - Explained
The N Queens Problem using Backtracking/Recursion - Explained
Back To Back SWE
7 Compute All Mnemonics For A Phone Number (Recursion/Backtracking Problem)
Compute All Mnemonics For A Phone Number (Recursion/Backtracking Problem)
Back To Back SWE
8 How To Reverse A Singly Linked List | The Ultimate Explanation (Iteratively & Recursively)
How To Reverse A Singly Linked List | The Ultimate Explanation (Iteratively & Recursively)
Back To Back SWE
9 Depth First & Breadth First Graph Search - DFS & BFS Graph Searching Algorithms
Depth First & Breadth First Graph Search - DFS & BFS Graph Searching Algorithms
Back To Back SWE
10 The 0/1 Knapsack Problem (Demystifying Dynamic Programming)
The 0/1 Knapsack Problem (Demystifying Dynamic Programming)
Back To Back SWE
11 The Dutch National Flag Problem (The Quicksort "Band-Aid")
The Dutch National Flag Problem (The Quicksort "Band-Aid")
Back To Back SWE
12 Test If A Binary Tree Is Symmetric ("Symmetric Tree" on Leetcode)
Test If A Binary Tree Is Symmetric ("Symmetric Tree" on Leetcode)
Back To Back SWE
13 The IP Address Decomposition Problem - Compute All Valid IP Addresses From Raw IP String
The IP Address Decomposition Problem - Compute All Valid IP Addresses From Raw IP String
Back To Back SWE
14 How To Permute A String - Generate All Permutations Of A String
How To Permute A String - Generate All Permutations Of A String
Back To Back SWE
15 The Balanced Parentheses Problem - Classic Stack Problem ("Valid Parentheses" on Leetcode)
The Balanced Parentheses Problem - Classic Stack Problem ("Valid Parentheses" on Leetcode)
Back To Back SWE
16 Knuth–Morris–Pratt (KMP) Pattern Matching Substring Search -  First Occurrence Of Substring
Knuth–Morris–Pratt (KMP) Pattern Matching Substring Search - First Occurrence Of Substring
Back To Back SWE
17 Implement An LRU Cache - The LRU Cache Eviction Policy ("LRU Cache" on LeetCode)
Implement An LRU Cache - The LRU Cache Eviction Policy ("LRU Cache" on LeetCode)
Back To Back SWE
18 Find The Longest Increasing Subsequence - Dynamic Programming Fundamentals
Find The Longest Increasing Subsequence - Dynamic Programming Fundamentals
Back To Back SWE
19 Generate All Palindromic Decompositions Of A String ("Palindrome Partitioning" on Leetcode)
Generate All Palindromic Decompositions Of A String ("Palindrome Partitioning" on Leetcode)
Back To Back SWE
20 Implement A Sudoku Solver - Sudoku Solving Backtracking Algorithm ("Sudoku Solver" on LeetCode)
Implement A Sudoku Solver - Sudoku Solving Backtracking Algorithm ("Sudoku Solver" on LeetCode)
Back To Back SWE
21 Merge K Sorted Arrays - Min Heap Algorithm ("Merge K Sorted Lists" on LeetCode)
Merge K Sorted Arrays - Min Heap Algorithm ("Merge K Sorted Lists" on LeetCode)
Back To Back SWE
22 Partition To K Equal Sum Subsets From An Array of Integers - The Backtracking Approach
Partition To K Equal Sum Subsets From An Array of Integers - The Backtracking Approach
Back To Back SWE
23 Edit Distance Between 2 Strings - The Levenshtein Distance ("Edit Distance" on LeetCode)
Edit Distance Between 2 Strings - The Levenshtein Distance ("Edit Distance" on LeetCode)
Back To Back SWE
24 Total Ways To Decode A String - Recursive Dynamic Programming Approach ("Decode Ways" on LeetCode)
Total Ways To Decode A String - Recursive Dynamic Programming Approach ("Decode Ways" on LeetCode)
Back To Back SWE
25 The Change Making Problem - Fewest Coins To Make Change Dynamic Programming
The Change Making Problem - Fewest Coins To Make Change Dynamic Programming
Back To Back SWE
26 Compute The Next Permutation of A Numeric Sequence - Case Analysis ("Next Permutation" on Leetcode)
Compute The Next Permutation of A Numeric Sequence - Case Analysis ("Next Permutation" on Leetcode)
Back To Back SWE
27 Count Total Unique Binary Search Trees - The nth Catalan Number (Dynamic Programming)
Count Total Unique Binary Search Trees - The nth Catalan Number (Dynamic Programming)
Back To Back SWE
28 Generate All Strings With n Matched Parentheses - Backtracking ("Generate Parentheses" on LeetCode)
Generate All Strings With n Matched Parentheses - Backtracking ("Generate Parentheses" on LeetCode)
Back To Back SWE
29 Implement A Max Stack - A Stack With A .max() API (Similar To "Min Stack" on LeetCode)
Implement A Max Stack - A Stack With A .max() API (Similar To "Min Stack" on LeetCode)
Back To Back SWE
30 The Recursive Staircase - Top Down & Bottom Up Dynamic Programming ("Climbing Stairs" on LeetCode)
The Recursive Staircase - Top Down & Bottom Up Dynamic Programming ("Climbing Stairs" on LeetCode)
Back To Back SWE
31 Search A Maze For Any Path - Depth First Search Fundamentals (Similar To "The Maze" on Leetcode)
Search A Maze For Any Path - Depth First Search Fundamentals (Similar To "The Maze" on Leetcode)
Back To Back SWE
32 Total Unique Ways To Make Change - Dynamic Programming ("Coin Change 2" on LeetCode)
Total Unique Ways To Make Change - Dynamic Programming ("Coin Change 2" on LeetCode)
Back To Back SWE
33 Test If A Binary Tree Is Height Balanced ("Balanced Binary Tree" on LeetCode)
Test If A Binary Tree Is Height Balanced ("Balanced Binary Tree" on LeetCode)
Back To Back SWE
34 Find The Second Largest Item - Heap & Tracking Approach (Beginner Big N Interview Question)
Find The Second Largest Item - Heap & Tracking Approach (Beginner Big N Interview Question)
Back To Back SWE
35 Increment An Integer Represented As An Array ("Plus One" on LeetCode)
Increment An Integer Represented As An Array ("Plus One" on LeetCode)
Back To Back SWE
36 Merge 2 Sorted Lists - A Fundamental Merge Sort Subroutine ("Merge Two Sorted Lists" on LeetCode)
Merge 2 Sorted Lists - A Fundamental Merge Sort Subroutine ("Merge Two Sorted Lists" on LeetCode)
Back To Back SWE
37 Clone An Undirected Graph - The Utility of Hashtable Mappings ("Clone Graph" on Leetcode)
Clone An Undirected Graph - The Utility of Hashtable Mappings ("Clone Graph" on Leetcode)
Back To Back SWE
38 Clone A Linked List (With Random Pointers) - Linear Space Solution & Tricky Constant Space Solution
Clone A Linked List (With Random Pointers) - Linear Space Solution & Tricky Constant Space Solution
Back To Back SWE
39 Deeply Understanding Logarithms In Time Complexities & Their Role In Computer Science
Deeply Understanding Logarithms In Time Complexities & Their Role In Computer Science
Back To Back SWE
40 Implement A Binary Heap - An Efficient Implementation of The Priority Queue ADT (Abstract Data Type)
Implement A Binary Heap - An Efficient Implementation of The Priority Queue ADT (Abstract Data Type)
Back To Back SWE
41 Max Contiguous Subarray Sum - Cubic Time To Kadane's Algorithm ("Maximum Subarray" on LeetCode)
Max Contiguous Subarray Sum - Cubic Time To Kadane's Algorithm ("Maximum Subarray" on LeetCode)
Back To Back SWE
42 Binary Tree Bootcamp: Full, Complete, & Perfect Trees. Preorder, Inorder, & Postorder Traversal.
Binary Tree Bootcamp: Full, Complete, & Perfect Trees. Preorder, Inorder, & Postorder Traversal.
Back To Back SWE
What Is Asymptotic Analysis? And Why Does It Matter? A Deeper Understanding of Asymptotic Notation.
What Is Asymptotic Analysis? And Why Does It Matter? A Deeper Understanding of Asymptotic Notation.
Back To Back SWE
44 An In-Depth Algorithmic Analysis of Bubble Sort. Best Case, Average Case, & Worst Case.
An In-Depth Algorithmic Analysis of Bubble Sort. Best Case, Average Case, & Worst Case.
Back To Back SWE
45 Maximum Sum Rectangle In A 2D Matrix - Kadane's Algorithm Applications (Dynamic Programming)
Maximum Sum Rectangle In A 2D Matrix - Kadane's Algorithm Applications (Dynamic Programming)
Back To Back SWE
46 A Detailed Algorithmic Analysis of Insertion Sort. Best Case & Worst Case.
A Detailed Algorithmic Analysis of Insertion Sort. Best Case & Worst Case.
Back To Back SWE
47 Binary Tree Level Order Traversal - Drawing The Parallel Between Trees & Graphs
Binary Tree Level Order Traversal - Drawing The Parallel Between Trees & Graphs
Back To Back SWE
48 Implement A Queue Using Stacks - The Queue ADT ("Implement Queue Using Stacks" on LeetCode)
Implement A Queue Using Stacks - The Queue ADT ("Implement Queue Using Stacks" on LeetCode)
Back To Back SWE
49 All Nodes Distance K In A Binary Tree - Performing Bidirectional Search On A Tree Using A Hashtable
All Nodes Distance K In A Binary Tree - Performing Bidirectional Search On A Tree Using A Hashtable
Back To Back SWE
50 Longest Common Subsequence (2 Strings) - Dynamic Programming & Competing Subproblems
Longest Common Subsequence (2 Strings) - Dynamic Programming & Competing Subproblems
Back To Back SWE
51 Egg Dropping Problem: Dynamic Programming Fundamentals & Understanding Subproblem Decomposition
Egg Dropping Problem: Dynamic Programming Fundamentals & Understanding Subproblem Decomposition
Back To Back SWE
52 Minimum Window Substring: Utilizing Two Pointers & Tracking Character Mappings With A Hashtable
Minimum Window Substring: Utilizing Two Pointers & Tracking Character Mappings With A Hashtable
Back To Back SWE
53 Reverse Polish Notation: Types of Mathematical Notations & Using A Stack To Solve RPN Expressions
Reverse Polish Notation: Types of Mathematical Notations & Using A Stack To Solve RPN Expressions
Back To Back SWE
54 Asymptotic Notations 101: Big O, Big Omega, & Theta (Asymptotic Analysis Bootcamp)
Asymptotic Notations 101: Big O, Big Omega, & Theta (Asymptotic Analysis Bootcamp)
Back To Back SWE
55 The Backtracking Blueprint: The Legendary 3 Keys To Backtracking Algorithms
The Backtracking Blueprint: The Legendary 3 Keys To Backtracking Algorithms
Back To Back SWE
56 Fast Multiplication: From Grade-School Multiplication To Karatsuba's Algorithm
Fast Multiplication: From Grade-School Multiplication To Karatsuba's Algorithm
Back To Back SWE
57 Search A 2D Sorted Matrix - Fundamentals of Search Space Reduction
Search A 2D Sorted Matrix - Fundamentals of Search Space Reduction
Back To Back SWE
58 The Quicksort Sorting Algorithm: Pick A Pivot, Partition, & Recurse
The Quicksort Sorting Algorithm: Pick A Pivot, Partition, & Recurse
Back To Back SWE
59 Lowest Common Ancestor Between 2 Binary Tree Nodes (A Recursive Approach)
Lowest Common Ancestor Between 2 Binary Tree Nodes (A Recursive Approach)
Back To Back SWE
60 Sort A K Sorted Array - Investigating Applications of Min/Max Heaps
Sort A K Sorted Array - Investigating Applications of Min/Max Heaps
Back To Back SWE

Asymptotic analysis is a method for analyzing the performance of algorithms, focusing on their behavior as the input size increases. It is essential for understanding the complexity of algorithms and making informed decisions about their use.

Key Takeaways
  1. Understand the concept of asymptotic behavior
  2. Learn to analyze algorithms using Big O notation
  3. Practice determining the time complexity of algorithms
  4. Apply asymptotic analysis to real-world problems
💡 Asymptotic analysis is not about measuring the exact running time of an algorithm, but about understanding its behavior as the input size increases, allowing for more informed decisions about its use.

Related Reads

📰
Building a Power Grid Inside Minecraft with BFS Algorithms
Learn to build a power grid inside Minecraft using BFS algorithms and understand its relevance to cloud services
Dev.to · Carlos Cortez 🇵🇪 [AWS Hero]
📰
The Run-Length Encoding Trick: How Simple Strings Get Compressed
Learn how Run-Length Encoding (RLE) compresses simple strings, a fundamental technique in programming and data compression, and apply it to optimize storage and transmission of data
Medium · Programming
📰
75 Days of Leetcode — Day 4: #238 — Product of Array Except Self
Solve the Product of Array Except Self problem on LeetCode to improve coding skills and learn array manipulation techniques
Medium · AI
📰
I implemented the algorithm that broke the sorting barrier. Dijkstra still wins.
Learn how the author implemented an algorithm that broke the sorting barrier and compare its performance with Dijkstra's algorithm
Medium · Programming
Up next
Stump Grinder Carbide Wheel Grinds Hardwood To Chips
Innoforge Studio
Watch →