Learn common data structures and algorithms in this tutorial course. You will learn the theory behind them, as well as how to program them in JavaScript.

⭐️ Contents (link to code after title) ⭐️

⌨️ Stacks (00:21) https://codepen.io/beaucarnes/pen/yMBGbR?editors=0012

⌨️ Sets (09:03) https://codepen.io/beaucarnes/pen/dvGeeq?editors=0012

⌨️ Queues & Priority Queues (19:24) https://codepen.io/beaucarnes/pen/QpaQRG?editors=0012

⌨️ Binary Search Tree (26:03) https://codepen.io/beaucarnes/pen/ryKvEQ?editors=0011

⌨️ Binary Search Tree: Traversal & Height (39:34) https://codepen.io/beaucarnes/pen/ryKvEQ?editors=0011

⌨️ Hash Tables (53:19) https://codepen.io/beaucarnes/pen/VbYGMb?editors=0012

⌨️ Linked List (1:03:04) https://codepen.io/beaucarnes/pen/ybOvBq?editors=0011

⌨️ Trie (1:14:59) https://codepen.io/beaucarnes/pen/mmBNBd?editors=0011

⌨️ Heap (max and min) (1:27:29) https://codepen.io/beaucarnes/pen/JNvENQ?editors=0010

🔗 Heap visualization: https://www.cs.usfca.edu/~galles/visualization/Heap.html

⌨️ Graphs: adjacency list, adjacency matrix, incidence matrix (1:42:07)

⌨️ Graphs: breadth-first search (1:46:45) https://codepen.io/beaucarnes/pen/XgrXvw?editors=0012

📄Data structures article by Beau Carnes: https://medium.freecodecamp.org/10-common-data-structures-explained-with-videos-exercises-aaff6c06fb2b

🐦Follow creator Beau Carnes on Twitter: https://twitter.com/carnesbeau

🔗Beau also made this Algorithms course from Manning Publications: https://www.manning.com/livevideo/algorithms-in-motion?a_aid=algmotion&a_bid=9022d293 (Promo code: 39carnes)

—

Learn to code for free and get a developer job: https://www.freecodecamp.org

Read hundreds of articles on programming: https://medium.freecodecamp.org

And subscribe for new videos on technology every day: https://youtube.com/subscription_center?add_user=freecodecamp

Original source

## Dan Vig

Here is the full remove function:

remove(data) {

const removeNode = function(node, data) {

if (node == null) {

return null;

}

if (data == node.data) {

// node has no children

if (node.left == null && node.right == null) {

return null;

}

// node has no left child

if (node.left == null) {

return node.right;

}

// node has no right child

if (node.right == null) {

return node.left;

}

// node has two children

var tempNode = node.right;

while (tempNode.left !== null) {

tempNode = tempNode.left;

}

node.data = tempNode.data;

node.right = removeNode(node.right, tempNode.data);

return node;

} else if (data < node.data) {

node.left = removeNode(node.left, data);

return node;

} else {

node.right = removeNode(node.right, data);

return node;

}

}

this.root = removeNode(this.root, data);

}

## GoatzAreEpic Maokai

Why am I so fucking stupid

## suryansh srivastava

Awesome Guruji Mahaan ho

## Trinitrophenylnitramine

Excellent video for a beginner.

## Koushik Sarkar

Nice explanation Sir. Very helpful for me.

## Abdurrahman Hafez

I love you Beau Carnes

## Wener M

freeCodeCamp.org, thank you for so valuable video lessons! Only one question – is there possibility to increase quality of vids at least up to 1080p?

## lalaithan

Spectacular explanations. These kinds of videos are the reason why I wish YouTube had some sort of go-back-30-second button.

## Ali Baba

Which editor are you using ?

## Ronald Aug

Javascripers!

1 – Watch this video

2 – Watch Javascript Modular here

https://www.youtube.com/watch?v=HkFlM73G-hk&list=PLoYCgNOIyGABs-wDaaxChu82q_xQgUb4f

And watch CJ live stream here

3 – https://www.youtube.com/results?search_query=coding+garden+with+cj

You don't need UDEMY at all!

## SINA Man

I think your difference method for Set is wrong!

Lets say we have two sets

setA = [1, 2, 3, 4]

setB = [2, 3, 5, 6, 7]

If we do

setA.difference(setB)

we get [1, 4] which I think is wrong.

Should it not be [1, 4, 5, 6, 7] as we are getting the difference between two sets?

## Esther Ndosi

Thank you for this.. I have one concern regarding sets data structure. The current difference function is returning what is in setA but not in setB. I have tried to implement the function which returns the difference between the two. Hopefully it will help.

this.difference = function(otherSet) {

var differenceSet = new mySet();

var _this = this;

var set1 = this.values();

var set2 = otherSet.values();

set1.forEach(function(e){

if(!otherSet.has(e)){

differenceSet.add(e);

}

});

set2.forEach(function(e){

if(!_this.has(e)){

differenceSet.add(e);

}

});

return differenceSet;

};

## bello musa

Thanks for the Tut 🙂

## JH5280

amazing video! wish I found this while attending the boot camp I went to

## Batt Dogan

can someone help me to understand why 'this.' is used to name the function, it's not necessary is it?

## ahmad abdolsaheb

Great job, Beau.

## UJJWAL VERMA

Also, make a video on DataStructures & Algorithm in Java. That will be highly appreciated. By the way a nice video.

## Marketing Area

This is nice video 😜

## Carrie Oakey

what program dialect is he coding in? is it Javascript?

## Sujeong Kwak

I love Beau and his videos, but I'd like to know if this course has new or better material than his previous Data Structures and Algorithms videos, because those are in digestible chunks and I'd rather watch those if it's the same material. So basically, should I watch this or the old videos?

## JORGE ANDRES VASQUEZ MORALES

Eres cabrón no te agas el estado unidence

## marco c.

minchia boh

## Karina Dorantes

very helpful!

## Demetrius Dasilva

ЬФ ЇS ГӉԐ БЄSҐ ЇИSҬЯЦҪҬФЯ ЄVЭЯ, thank you so much for sharing this.

## Nil Puig

The Set implementation is not correct, you are using indexOf(), which has a time complexity of O(n). The real implementation of Set.add() uses hash tables, which takes O(1). Deletion in the queue should take O(1), but your implementation takes O(n)

## bob2000and10

Beau is fantastic

## MrMybach

A diff method wouldn't return full difference between sets. It should loop through otherSet too.

## Katherine Martin

This video is dope. Great teaching tool