4 Data Structures You Need to Know

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you know i'm pretty proud of you for clicking on this video i these types of videos don't typically do as well as some of my other ones which are more about like the ideology of and tips and tricks of being a better programmer because when it actually gets down to the nitty gritty like data structures i feel like people tend to shy away they tend to just want to click on videos and dream about being a developer instead of actually learning the things that allow you to become a developer but i like to make these videos every now and then so i want to talk about the seven data structures you need to know the the most common data structures and before we get started uh i wasn't going to say this but if i'm talking a little bit off or the audio it sounds a little bit weird or something like that i ruptured my left eardrum so i can't really hear too well out of that it'll be fine in like a couple weeks don't get me wrong it's nothing detrimental but if anything sounds just a little weird like how i'm talking then um that's why data structure so well in short there are ways to structure your data don't overthink it you may see data structures and be a little intimidated no it's literally ways to structure your data and there are different ways to structure your data depending on what it is and how you want to organize it and store it depending on how you plan to use it and of course the first data structure i want to talk about are arrays and i want you to think about it right now do you know what an array is how it looks if you had to visualize it how you would use it or why you would use it over any of these other data structures if you can't answer that question right now then do a little bit more research because data structures are a staple in software engineering they're in basically every single program that you have ever written or accessed or used so well what i'm trying to say is they're really important so you need to know them so an array by definition it's it's a container object that holds a fixed number of values of a single type you can have an array of integers but only integers you can have an array of floating point numbers but only floating point numbers you can have an array of strings but only strings i mean you can even have an array of arrays but only arrays and when i say fixed number of values that is because when you create an array you determine its length and that is the length of that array but the cool things about arrays is that they're indexed and they're stored in such a way where you're able to access anywhere within the array random access for example when you have an array you have the array name you have the size of the array you have the elements within the array which will also show you the type of that array so is it an int double string char array whatever it may be and then you have the index for that array a few operations you may want to perform with this array are traversing so you can traverse the array that is accessing every single element within that array whether you want to add them all up and get a single integer if your array of integers or maybe you want to print out every single element of that array of course you can also search within your array by searching you can search by the index or by the element this will just allow you to access whatever element within that array you need and of course you can also update the array so if you need to replace an element you can do that as well now you can insert and delete to and from an array but because they're fixed in size you can't do that right off the bat you would actually have to create a whole entire new array and you'd have to do the current size plus one if you're inserting something into that array and you would have to copy all existing elements out of your previous array and into the new array that is of a larger size and the same goes for if you want to delete an element you just say current size -1 that is the length of your new array copy all existing except for the one you want to delete into that new array and that's how you insert and delete now your use for arrays you would use a lot of times you use an array to using other data structures like array lists or heaps hash tables matrices stuff like that but you also use race for a lot of sorting algorithms like bubble sort everyone's favorite quick sort insertion short it's kind of difficult to say fast and a few others now how about a linked list so a linked list is a it's a linear data structure where you have all separate objects the elements of a linked list are not stored in a contiguous location it actually consists of a sequence of items in linear order that are linked together using pointers so you would have to access the data sequentially rather than having random access like in an array so when it comes to the elements within a linked list these are referred to as nodes and each node is made up of the value as well as the pointer these are typically known as key for value in next for the pointer the beginning of a linked list is called the head and that points to the first element in that linked list and then at the end of a linked list you have the tail which is basically the same as everything else but the next is null and there are actually three different types of linked lists you have a singly linked list you have a doubly linked list and you have a circular linked list so the one we just discussed that is a singly linked list so traversal you're only able to do that from forward backwards however in a doubly length list you're able to do it forwards and backwards but also each node which previously consisted of just a key and next also has a previous pre for short this is the same as next however it is a pointer to its previous its predecessor node rather than its successor node in a circular linked list you can probably guess is when the tail points to the head and the head points to the tail now for the operations of course you can search in a linked list and remember this is a sequential search or a linear search you'll be starting at the beginning and going backwards looking for the first element with the key of your choice so if you're looking for particular words with particular characters then that can be one and whenever a character a pops up then you return a pointer to this element you can of course insert into a linked list it is not fixed size so you can just go ahead and insert the beginning of it to the end of it or in the middle of it and you can do the same thing deleting within a linked list same idea beginning of it end of it or middle of it in the application of a linked list you have probably used it time and time again alt tab if you have never done alt tab do it right now if you have other windows open you alt tab and you're able to circle through this is a circular linked list whatever applications you have open so right now you have chrome open and you may have a code text editor open right so you can alt tab from one to the other and it just goes in a circle hold down alt click tab click tab again click tab again you can see how exactly that works something a little bit more technical is that it's used in symbol table management for compiler design now let's talk about stacks stacks is to put it simply is a last in first out data structure it's kind of like when you have a stack of plates well when you're stacking them the last plate that you stack is the first plate that you pick out of it last in first out there are two operations when it comes to a stack push and pop push you are inserting something to the top of the stack in a pop you are deleting and returning something at the top of the stack there are different ways to check the status of a stack you can peek that is returning what is at the top of the stack without deleting it you can check if it is empty and you can check if it is full now the applications of stacks well you ever heard of the shunning yards algorithm it is for parsing and evaluating mathematical expressions so you can use this for expression evaluation and you can also use it to implement function calls in recursive programming now how about a q well you probably have heard of a queue i remember when i was younger i used to play world of warcraft and when the server was full i would have to wait in the queue so if you know anything about that then you know that a q is first in first out there are two basic operations you can perform on a queue and that is in queue and dq so with an enqueue you're inserting an element to the end of the queue and with a dq you are deleting an element from the beginning of the queue a few applications are cues as well cues are used to manage the threads in multi-threading and to implement cue systems like priority queues my camera died i'm wearing a different shirt and it was actually the next day so i didn't want to skip a beta i was actually planning on going over seven maybe even eight data structures in this video but i'm going to leave it at the four that we just went over if you care to see any of the others i'm planning i was planning on going over hash tables binary trees and heaps and maybe even combining trees and heaps and making treats yes that is a real data structure it is fairly fairly specific however i mean it's a data structure maybe it's not one you need to know but it's good to know so just let me know if you care to see that an extension of this video going going over another three or four data structures i may make that as a future video but for now this is what you get and also depending on when you're watching this i just posted a post not a video but a post on my youtube channel as well as over on my twitter asking you to ask whatever questions you may have so feel free to leave those questions down below here but i may not see them so go to the post if you have any questions that you want answered in a q a it can be about anything i really don't care computer science software engineering something completely unrelated doesn't matter i'm going to pick whatever i find interesting over on twitter as well as over on the youtube post and then i'm going to answer those questions in a video to upload next week [Music] you
Info
Channel: ForrestKnight
Views: 257,731
Rating: undefined out of 5
Keywords: data structures, algorithms, data structures and algorithms, software engineering, software development, coding, programming, engineer, code, java, computer science, computer science for beginners
Id: y7ksXLhuy-w
Channel Id: undefined
Length: 9min 41sec (581 seconds)
Published: Thu Oct 15 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.