
Data Structures and Algorithms in JavaScript - Full Course for Beginners
video description
Date: 2022-03-14
Related videos
Comments and reviews: 10
Salman
Great tutorial.
Thank you #freecodecamp and #BeauCarnes for upload this.
Great learning.
Small finding below in Hash Table lesson.
if the storageLimit is 4 and you try to lookup for a value within the same index which was removed, it will throw an error saying -Cannot read property '0' of undefined-.
Adding a check in the lookup function should solve the problem.
Condition that needs to be updated in lookup function.
storage[index][i] && storage[index][i][0] === key
Updated lookup function
this.lookup = function (key) --
const index = hash(key, buckets);-
if (storage[index] === undefined) --
return undefined;-
--
for (let i = 0; i < storage[index].length; i++) --
if (storage[index][i] && storage[index][i][0] === key) --
return storage[index][i][1];-
--
--
-;
reply
Great tutorial.
Thank you #freecodecamp and #BeauCarnes for upload this.
Great learning.
Small finding below in Hash Table lesson.
if the storageLimit is 4 and you try to lookup for a value within the same index which was removed, it will throw an error saying -Cannot read property '0' of undefined-.
Adding a check in the lookup function should solve the problem.
Condition that needs to be updated in lookup function.
storage[index][i] && storage[index][i][0] === key
Updated lookup function
this.lookup = function (key) --
const index = hash(key, buckets);-
if (storage[index] === undefined) --
return undefined;-
--
for (let i = 0; i < storage[index].length; i++) --
if (storage[index][i] && storage[index][i][0] === key) --
return storage[index][i][1];-
--
--
-;
reply
Dextrose
I didn't really expected to understand this, but now I finally am able to really understand these concepts! Thank you very much!...
-One important message to all of the people who are trying to understand or having difficulties in understanding this:-
Don't give up, try to clear the basics first, see some videos about Object oriented Programming and practice some functional programming, you'll be able to imagine everything in terms of objects and arrays in javascript, this will help you understand this better! Make sure to watch a few videos and study a few articles before watching this video if you don't understand some of the concepts like BST, LL, etc...Just don't give up!
reply
I didn't really expected to understand this, but now I finally am able to really understand these concepts! Thank you very much!...
-One important message to all of the people who are trying to understand or having difficulties in understanding this:-
Don't give up, try to clear the basics first, see some videos about Object oriented Programming and practice some functional programming, you'll be able to imagine everything in terms of objects and arrays in javascript, this will help you understand this better! Make sure to watch a few videos and study a few articles before watching this video if you don't understand some of the concepts like BST, LL, etc...Just don't give up!
reply
Wasi
can anyone explain how this function recursion works in this function, how left function call and right function call inside function works and provide us 1 or 2 for unbalanced and balanced tree.. It will be great help if someone explains as I was not able to understand with explanation on this video. Duration of the content after 46:00
findminheight(node = this.root)-
--
if(node == null)-
--
return -1-
- -
let left = this.findminheight(node.left);-
let right = this.findminheight(node.right);-
if(left < right)-
- -
return left + 1;-
--
else-
--
return right + 1;-
--
-
reply
can anyone explain how this function recursion works in this function, how left function call and right function call inside function works and provide us 1 or 2 for unbalanced and balanced tree.. It will be great help if someone explains as I was not able to understand with explanation on this video. Duration of the content after 46:00
findminheight(node = this.root)-
--
if(node == null)-
--
return -1-
- -
let left = this.findminheight(node.left);-
let right = this.findminheight(node.right);-
if(left < right)-
- -
return left + 1;-
--
else-
--
return right + 1;-
--
-
reply
Emmanuel
The difference of sets algorithm only works when the shorter set is passed into the function because you use the first set to check for difference. That-s not proper because in real cases, you don-t know exactly what-s in the sets.
Set1 = [2,3]
Set2 = [3,5,6,7]
In your implementation,
set1.difference(set2) returns [2]
Set2.difference(set1) returns [2,5,6,7]
Shouldn-t you test which set is longer and then use it to check for the difference?
If you implement it that way,
set1.difference(set2) returns [2,5,6,7]
Set2.difference(set1) returns [2,5,6,7]
Foolproof.
reply
The difference of sets algorithm only works when the shorter set is passed into the function because you use the first set to check for difference. That-s not proper because in real cases, you don-t know exactly what-s in the sets.
Set1 = [2,3]
Set2 = [3,5,6,7]
In your implementation,
set1.difference(set2) returns [2]
Set2.difference(set1) returns [2,5,6,7]
Shouldn-t you test which set is longer and then use it to check for the difference?
If you implement it that way,
set1.difference(set2) returns [2,5,6,7]
Set2.difference(set1) returns [2,5,6,7]
Foolproof.
reply
Gaurav
Great lesson Mo, A minor correction In BST example though (video at 36:56).... Since BST is always sorted, node -23- can never have a right linking to a lesser value (in this case -19-). In this scenario value -19- should not be there at all. Also, removal of node in BST can be revisited. The replaced value should be the max of the subtree (so 23 can be safely treated as a new node to be replaced in left subtree for your scenario) . Happy Coding!
reply
Great lesson Mo, A minor correction In BST example though (video at 36:56).... Since BST is always sorted, node -23- can never have a right linking to a lesser value (in this case -19-). In this scenario value -19- should not be there at all. Also, removal of node in BST can be revisited. The replaced value should be the max of the subtree (so 23 can be safely treated as a new node to be replaced in left subtree for your scenario) . Happy Coding!
reply
la
I have been teaching myself a form of js with google apps script. My question is, why create functions which perform actions like array.shift? Why not just use that method on the array? What is the benefit of doing it this way? In reference to the queue section where he this.dequeue. Or this.size. I can understand for something more like checking for empty. Anyone that can chime in?
reply
I have been teaching myself a form of js with google apps script. My question is, why create functions which perform actions like array.shift? Why not just use that method on the array? What is the benefit of doing it this way? In reference to the queue section where he this.dequeue. Or this.size. I can understand for something more like checking for empty. Anyone that can chime in?
reply
Amitav
please dont use arrays for queues, the shift and unshift operations take O(n) extra time unlike stack's push and pop,
just use a basic linked list, the time complexity will reduce, the only benefit arrays provides is O(1) access but you don't need that incase of stack or queues.
reply
please dont use arrays for queues, the shift and unshift operations take O(n) extra time unlike stack's push and pop,
just use a basic linked list, the time complexity will reduce, the only benefit arrays provides is O(1) access but you don't need that incase of stack or queues.
reply
Avi
If you're thinking that this knowledge is required to be a developer/programmer you're drastically mistaken. If you don't understand this stuff, the good news is, you need about 1% or less of it to build a web app and get paid for it.
reply
If you're thinking that this knowledge is required to be a developer/programmer you're drastically mistaken. If you don't understand this stuff, the good news is, you need about 1% or less of it to build a web app and get paid for it.
reply
Genesis
great tutorial man! one comment, the bst delete is missing something. what if the value to replace the 17 is on the left and not the right. we need to recursively search here too?
reply
great tutorial man! one comment, the bst delete is missing something. what if the value to replace the 17 is on the left and not the right. we need to recursively search here too?
reply
itech
I'm going through this course and I just can't speak enough of the efforts and quality of these videos. Beau is an amazing instructor!! And thanks again for putting this together.
reply
I'm going through this course and I just can't speak enough of the efforts and quality of these videos. Beau is an amazing instructor!! And thanks again for putting this together.
reply
Add a review, comment
Other channel videos















