![]() ![]() Intersection - Given two sets, this function returns another set that has all items that are part of both sets.Union - This combines all the items from two different sets and returns this as a new set (with no duplicates).Besides being able to add and remove elements to a set, there are a few other important set functions that work with two sets at once. The set data structure stores values without any particular order and with no repeated values. See the code for a queue in JavaScript here. Enqueue means to insert an item into the back of the queue and dequeue means removing the front item. This means that once a new element is added, all elements that were added before have to be removed before the new element can be removed.Ī queue has just two main operations: enqueue and dequeue. Queue representationĪ queue is considered FIFO (First In First Out) to demonstrate the way it accesses data. The first one in the line is the first one to be served. You can think of a queue as a line of people at a grocery store. See the code for a stack in JavaScript here. There are three main operations that can be performed on stacks: inserting an item into a stack (called ‘push’), deleting an item from the stack (called ‘pop’), and displaying the contents of the stack (sometimes called ‘pip’). The stack is considered LIFO (Last In First Out) - meaning the last item you put in the stack is the first item that comes out of the stack Stack representation If you want to look at a book in the middle of the stack you must take all of the books above it off first. ![]() It is kind of similar to a stack of books. Add Elements at a Specific Index in a Linked ListĪ stack is a basic data structure where you can only insert or delete items at the top of the stack.Remove Elements from a Linked List by Index.See the code for a linked list in JavaScript here. The most basic operations in a linked list are adding an item to the list, deleting an item from the list, and searching the list for an item. There are also doubly linked lists where each node has a pointer to both the next item and the previous item in the list. ![]() Each node contains two things: the actual data being stored (which can be basically any type of data) and a pointer (or link) to the next node in the sequence. Linked list representationĪ linked list consists of a group of nodes which together represent a sequence. They each have advantages and disadvantages. It is often compared to an array since many other data structures can be implemented with either an array or a linked list. Linked ListsĪ linked list is one of the most basic data structures. ![]() Still, knowing how to implement these data structures will give you a huge edge in your developer job search, and may come in handy when you’re trying to write high-performance code. JavaScript (like most high-level languages) has built-in implementations of many of these data structures. If you want to learn more about Big O Notation, check out my article about it or this video by Briana Marie.Īlso note that even though I show how to implement these data structures in JavaScript, for most of them you would never need to implement them yourself, unless you were using a low-level language like C. This isn’t included for all of them since the time complexity is sometimes based on how it’s implemented. Note that some of these data structures include time complexity in Big O notation. I’ve also linked to code examples for each of them, which show how to implement these in JavaScript.Īnd to give you some practice, I’ve linked to challenges from the freeCodeCamp curriculum. I’ve embedded videos that I created for each of these data structures. I’m going to teach you 10 of the most common data structures - right here in this short article. The good news is that they’re basically just specialized formats for organizing and storing data. Get 39% off my course by using code ‘ 39carnes’! Or you can get 50% off my Deep Learning in Motion course with code ‘ vlcarnes2’.ĭata structures are a critical part of software development, and one of the most common topics for developer job interview questions. Good programmers worry about data structures and their relationships.” - Linus Torvalds, creator of Linux **Update** My video course about Algorithms is now live! Check out Algorithms in Motion from Manning Publications. ![]()
0 Comments
Leave a Reply. |