Binary Tree Bootcamp: Full, Complete, & Perfect Trees. Preorder, Inorder, & Postorder Traversal.

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

Key Takeaways

Binary Tree Bootcamp covering Full, Complete, & Perfect Trees and Preorder, Inorder, & Postorder Traversal techniques and algorithms

Full Transcript

all right we are back all right so today what we're going to do is we're going to go over our binary tree fundamentals and yes I know maybe you're already familiar with this but my goal is to make this channel one of the world's largest resources for software engineering interviews and this kind of preparation so the key is we have to go through our fundamentals and get them very solid before we can build on top of them and do other topics so if you haven't subscribed to the channel subscribe to the channel and like this video what we're going to do today is we're going to talk about our fundamental traversals of binary structures binary tree structures and we're going to talk about the types of trees we're just going to go over our very basic concepts so that we have them very sound so let's go over three of the key kinds of trees or three terms we can use to describe a tree if we have a tree where leaf nodes have no children or a node has two children it is a full tree notice this is a leaf it has no children this is a leaf it has no children this is a leaf it has no children and that is the leaf it has no children but the nodes that do have children have two children they cannot have one chip child they have to have two children so this tree is full every time we decide to have a descendant we have to have two descendants we can't just have one so this node decided I'm going to have descendants I need to have to this node said I'll have no descendants it has no descendants no children that is a full tree and you can tell by what it looks like so this is a complete binary tree complete binary trees are our binary heaps we make binary heaps complete trees so what does complete mean all it means simply is when we fill out the nodes we go top to bottom we go left to right do you see how we go and fill it out like this do you see how we go top to bottom and do you see how we go from left to right and if I just put a node right here just out of the blue I stuck a note in there this tree is no longer complete because because I just missed putting a note there so this is a complete by an area and then finally we have our perfect binary tree so a perfect binary tree is where all the leaves are on the same level and all of the nodes that decide to have descendants have exactly two children a perfect binary tree is both complete and it is also full you see how the notes that decided to have children decided to have descendants they only can have two children they can't just have one child but the ones that did not decide have no children and notice how all of the ones that did not decide what we call leaves are all on the same level this is a perfect binary tree so now that we understand our terminology very soundly what we need to do is let's look at the traversals and yes these are going to be the rock reversals you can do on a tree but it's very key to understand these traversals so we can adapt them to other problems if we were very flexible with traversing a binary structure it becomes much easier to solve problems recursively or iteratively with a stack so let's look at our traversal now okay so what we're going to do is we're going to do a traversal of this tree and there are three fundamental ways to traverse a binary tree you can do it other ways but these are the three key ways there's your pre-order traversal your inorder traversal and your post order traversal and I don't want you to worry about the part in the word where it says order I only want you to notice the first part of the word notice how it says pre notice how it says in notice how it says post that prefix the prefix to the name of the traversal tells us when we visit the node we're sitting at so what I want you to see is in a pre order traversal in a pre order traversal we visit the node we visit the left subtree we visit the right subtree do you see how it's called pre order do you see how the N is the first visited you see how it's pre before the left and right so for inorder think of it as in so left subtree visit the node and then visit the right subtree so it's you see how it's in do you see how it's in the that's how you remember in order traversal and then we have our post order traversal we go left sub-tree we go right subtree we visit the node so do you see how it's post it's after the left and right so the left and right stay in sequence left and rights and sequence but the the prefix tells us when we visit the node before the sub trees the sub trees will be left to right but when do we visit the node that's what the prefix tells us so what we're gonna do is we'll do a pre-order we'll do an inorder and then we'll do a post order traversal here so this is what I want you to think about when we're traversing a tree I'm going to write something that's going to help you so I want you to think of recursion think of recursion as a certain policy we have to execute at each node think of the recursion as the tasks we need to do at a node and the state this state stays on the call stack this is the key with recursion so do you see how I just put node left to right this is our pre-order we're doing pre-order right now and what we want to do is we want to execute the policy at each node so what we do is we start at the 10 I see I have to do a node visit I have to do a left subtree visit I have to do a right subtree visit so what I'm gonna do is I'm gonna do the node visit I'm gonna just output 10 and what I'm gonna do is I'm gonna erase the end so I'm just familiarizing you with the example that we're walking through and notice we don't just have to print a node we can do any form of work the whole point is visitation we want to get our fundamentals down for visiting a node right now so what we're going to do is we're going to execute our policy at this stack frame we're going to say I need to visit my left so this stack frame says I need to visit the left subtree so we're going to circle the left okay so now we recurse and now we just circled the left and now we're gonna come down and we'll come to the 7 what is the policy at 7 7 says ok what do I need to do here in my stack frame so what we see is we see that 7 has 2 we see that 7 has to do we see that 7 has to do a node visitation so what we're going to do is we're going to visit seven and notice the next step in sevens policy in this stack frame is to visit the left subtree so let's do it so we visit the left subtree and now what we need to do is we need to do this policy at this stack frame so do you see how recursion is we're executing the same policy at each node but it's going to give us the behavior we desire because of the way we're ordering the visitations right so what we're going to do is we'll visit the six and then we're going to recurse and then we're going to come to the one we're going to visit the one and then one says I need a visit my left subtree we hit a base case nothing we come back one says okay I finished my left so I can erase that I'm done and then what is one's policy what is the policy at this stack frame what is left for this recursion in this stack frame to finish and we see all that's left is visit the right subtree let's visit the right subtree and then we see that there's nothing so we come back and now one has nothing to do so now we return to our call and now 6 says okay thank you left subtree you're finished now what is next in sixes stack frame and like again I say stack frames but the thing is we don't have to use the call stack we could make our own stack we can make our own stack and then we could execute the traversal that way so it just depends on the traversal and what implementation you want to do so this says I need to visit my right so the six visits is right there's nothing there so six comes back so now six has nothing to do it returns to its caller seven in sevens stack frame in its policy its stack frame it says I visited my left and now all seven has to do is visit its right subtree there's stuff to do over here so let's do that so now eight says what do I need to do what does eight need to do it needs to visit itself it needs to visit its its own node and then it needs to go left we see there's no left and then eight says okay I need to go right now so we recurse on the right subtree and now we're at nine what is nines policy what is nines job and I want you to drill this in your brain because this is how we really understand recursion this is how we really see that recursion expresses our decisions at each node it's different for each node each node has a different state do you see how states differs this is recursion fundamental I want you to internalize so we see nine so what we need to do is we need to print nine we see it has to print itself and so nine needs to visit its left nothing nine needs to visit its right nothing so it has nothing left if we return to the eighth the eighth finished its right subtree nothing left it has nothing to do left and now we come back to seven seven was just visiting its right subtree seven says okay unfinished seven is finished and now we return to ten and do you see how this all was the left subtree of ten do you see how our next task is to explore the right subtree of ten so all the traversals do is they change how we traverse this tree they change when we visit nose what we do is we check the right subtree and then what we need to do is we need to print 11 because 11 has that task to do and so 11 has to visit its left there's nothing here so we come back to 11 and so 11 has to visit its right and so 11 visits its right and now 20 comes to itself and 20 says what do I need to do here I need to print myself go left and right so 20 will print itself so 20 now needs to go left so it comes to 1440 needs to print itself and now 14 will go to the left so 14 finds nothing it'll go to the right as well it'll find nothing and now back to 20 what was 20 just doing it was looking to its left so what we're going to do is we're going to finish that what is the next state in 20 stack frame well we need to go to the right we come to the right and we see 22 so we see 22 and 22 s job and well it hasn't printed itself it hasn't gone left hasn't gone right it needs to do its job so we're going to print 22 and then it will go left there's nothing and then we'll go right there's nothing 22 is finished it returns to 20 and then 20 has explored it's right LLL finish 20 has nothing left to do LLL return to 11 11 has finished this right so 11 has nothing to do it's going to return to 10 10 has finished it's right and 10 stack frame the top level stack frame that drove us into the recursion is finished we're going to return to our caller whatever we returned whether it's the count of the nodes or something and that is finished that is the traversal of the tree this is what the pre-order traversal looks like the key is you don't really need to memorize these traversals you literally get the hint of what they are from the name anyway I think you get the idea now let's go through the in order and post-order and see how those work out they're basically the same thing so now what we're going to do is we're going to do an inorder traversal and all that changes is we're going to do a different policy at each node so let's define that policy okay so now all we did was define a different policy so we're going to go left we're going to visit the node we're sitting at and then we're going to go right that is all that we're going to do different so what we're going to do is we're going to start at the 10 the 10 will be called by an external caller and we're going to kick off our recursion what we're going to do is we're going to execute the policy at 10 and when you really do internalize this that recursion at each frame every frame has a different state although every frame has the same policy every frame will have a different state at different points in the recursion so we're going to go left in 10 and then we come to 7 what does 7 need to do 7 needs to go left what will 6 do 6 needs to go left what will one do one needs to go left and one is going to go left there's nothing there it comes back and so what does one need to do one needs to print itself so one printed itself and after a prints itself it needs to go right there's nothing there and now what we need to do is come back we come back to 6 because 1 is finished we come back to 6 so 6 just finished up going left so now 6 needs to print itself so now 6 needs to go right we see that there is nothing - 6 is right so what we're going to do is we're going to just return to 7 we have nothing else to do at 6 so 7 just finished going left so 7 its next job in its stack frame is to print itself so now 7 needs to go right and now 8 needs to go left we see in its stack frame that's his first job and then it goes left it finds nothing and then 8 needs to print itself and then 18 needs to go right and then it goes right and then we see 9 needs to go left there's nothing there 9 needs to print itself and then 9 needs to go right there's nothing there 9 has nothing to do it returns to 8 and 8 has finished its right subtree a has nothing to do left so eight returns to seven seven is finished is right sub-tree so seven returns to ten ten has finished its left subtree all that work we were doing was on the left subtree so now ten needs to print itself and now ten needs to go to its right and now eleven needs to go to its left there's nothing to eleventh left it needs to come back to itself and now eleven needs to visit itself and then eleven goes to the right twenty what does it need to do it needs to go to the left fourteen needs to go to the left there's nothing there fourteen needs to visit itself and then we see fourteen needs to go right there's nothing there so fourteen returns to whoever called in which was twenty twenty is done going left twenty needs to visit itself nest and then twenty needs to go to the right and then we reach twenty-two twenty-two needs to go left to visit itself and go right so it goes left there's nothing comes back it needs to print itself and now twenty-two needs to go right there's nothing there we return to 20 20 is finished twenty returns to its caller its caller has finished its right subtree 11 returns to its caller ten ten has finished its right subtree and we are finished printing it and I wouldn't even notice there's something special about this what we just did there's something special right here because do you notice how these are in increasing order this tree is a special kind of tree called a binary search tree so the nature of the way these notes are oriented is this node is in the middle of all of these guys and all of these guys so if we go to the left we go lesser in value we go less than ten everything in the left subtree is less than ten everything in the right subtree is greater than ten so this is a special kind of tree again a binary search tree you're probably already familiar with this if you are watching this but anyway so now I think you really get the idea but just to drill it in let's do the post order traversal okay so now we're going to do the post order traversal and nothing changes nothing changes except our policy at each node the way we visit the nodes so let's just go straight through this and you should be pretty rapid with this now so what we're going to do is we're going to go to the left first for Ted we'll go left first and then seven we'll go left six we'll go left this is starting to look like the in order traversal but let's continue so one go to the left we go to the left and we see that we don't find anything so we come back and this is the way this differs from our in order traversal instead of visiting ourselves next the next task is to visit our right subtree remember this is a post order traversal we visit ourselves a post last right so what we're going to do is visit our right there's nothing there and then we'll visit ourselves and what we're going to do is Prince ourselves there's nothing left to do it one so what we'll do is return to our collar six so six needs to go to the right there's nothing there so we come back and so six needs to visit itself so we print six six is finished so six returns to its collar we see its collar was seven seven just finished up its left subtree so now seven goes to the right seven goes to the right and we come to eight what does eight need to do it needs to go to the left to the right and to itself so we go left there's nothing here so we come back to eight so eight now needs to explore it's right and so now eight is exploring is right we come to the nine so nine needs to explore its left there's nothing there so now ninety needs to explore its right there's nothing there so now nine only needs to print itself nine returns to its caller eight eight realizes it's finished its right subtree and now eight needs to print itself it has nothing left to do it returns to seven seven all it needs to do is prints itself seven has nothing left to do it returns to its caller ten ten finished its left subtree all it has to do is go right and now we come to eleven eleven needs to go to the left eleven does not have anything on its left so 11 goes right we come to twenty twenty needs to go left to right and visit itself we go to the left we come to fourteen we go to the left there's nothing we go to the right there's nothing we visit the node fourteen that's the last task in our stack frame we visit 14 we come back to 20 20 is exhausted its left subtree so twenties next task is to go to the right so now we're going to go to the right we see 22 22 s job is not to print itself it's to go left to go right and then print itself so now 22 is going left so there's no from there it needs to go right there's nothing there it needs to print itself now we come back to our caller 20 it's finished exploring its right subtree now 20 needs to print itself 20 is finished with its tasks so it comes back to 11 again Levin realizes I'm done with my right subtree 11 needs to print itself now and now 11 has nothing to do we return to our caller and now we have 10 10 realizes I'm done with my right subtree and now finally 10 prints itself 10 realizes it has nothing left to do and we've completed our traversal that is our post order traversal that is basically how you do it see the thing is you don't always have to do this recursively but what we're going to do is there's a certain way we need to visit these nodes and however we structure our recursion how every structure our are stacked what items we push and in what order is going to change how we visit these nodes it's not that scary to deal with binary structures binary tree structures because as long as we know our fundamentals as long as we know how to visit nodes we can be very flexible in how we deal with these structures I haven't even gotten into breadth-first traversal we can do a zigzag traversal we would use a queue for that but that's for another video but I just want to introduce this concept you're probably already familiar with this if we are thinking about complexities if we think about any of these traversals where we're touching all of the nodes if n is the number of nodes then the upper bound we can set on the time we're taking is going to be linear time we're going to scale in a linear fashion as our tree gets bigger if we're touching all of the nodes anyway we're going to get more familiar with tree complexities and all that it gets fairly straightforward as you do more problems but that is all for this video if you liked this video hit the like button subscribe to the channel this was a very basic fundamental one of course we have a table of contents so you could skip through this I would do not expect anyone to watch all of this but that is all for this video and what I'm gonna do and [Music]

Original Description

Code & Problem Statement @ https://backtobackswe.com/platform/content/binary-tree-bootcamp?utm_source=youtube&utm_medium=video 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 Full Binary Tree: Every node (besides children) has exactly 2 children (the maximum children a node can have in a binary tree). Complete Binary Tree: Every level, except possibly the last, is completely filled, and all nodes are as far left as possible. Perfect Binary Tree: All interior nodes have two children and all leaves have the same depth or same level. Perfect binary trees are both full and complete. Preorder Traversal: node left right Inorder Traversal: left node right Postorder Traversal: left right node ++++++++++++++++++++++++++++++++++++++++++++++++++ HackerRank: https://www.youtube.com/channel/UCOf7UPMHBjAavgD0Qw5q5ww Tuschar Roy: https://www.youtube.com/user/tusharroy2525 GeeksForGeeks: https://www.youtube.com/channel/UC0RhatS1pyxInC00YKjjBqQ Jarvis Johnson: https://www.youtube.com/user/VSympathyV Success In Tech: https://www.youtube.com/channel/UC-vYrOAmtrx9sBzJAf3x_xw
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Back To Back SWE · Back To Back SWE · 42 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
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
43 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

This video provides a comprehensive introduction to binary trees, including full, complete, and perfect trees, and covers preorder, inorder, and postorder traversal techniques. Viewers will learn how to implement these traversal methods and apply them to solve problems.

Key Takeaways
  1. Define a binary tree and its properties
  2. Implement preorder traversal
  3. Implement inorder traversal
  4. Implement postorder traversal
  5. Apply traversal techniques to solve problems
💡 Understanding the differences between full, complete, and perfect trees is crucial for effective tree traversal and algorithm design.

Related Reads

Up next
Find the Median in a Data Stream (Two Heaps Trick)
KodeKloud
Watch →