Why are Data Structures And Algorithms important?

Loony Corn
A free video tutorial from Loony Corn
An ex-Google, Stanford and Flipkart team
4.2 instructor rating • 73 courses • 129,466 students

Lecture description

Data structures and Algorithms have a symbiotic relationship. The choice of data structure significantly influences the algorithms' performance and complexity and vice versa. Also learn about abstract data types and how they relate to data structures.

Learn more from the full course

From 0 to 1: Data Structures & Algorithms in Java

Learn so you can see it with your eyes closed

14:58:54 of on-demand video • Updated April 2019

  • Visualise - really vividly imagine - the common data structures, and the algorithms applied to them
  • Pick the correct tool for the job - correctly identify which data structure or algorithm makes sense in a particular situation
  • Calculate the time and space complexity of code - really understand the nuances of the performance aspects of code
English [Auto] I just generally and this is the first class of the hundred. Now aren't fighting efficient and elegant code is choosing the right data structure to represent information and using them so that you want that that's the key and is meeting when there's a huge universe of data structures. How do you know which one beats and how do you know that to solve your problem. That's why they need the steel structures in them. We look to what the disruptors can tweak and modify it and boy and that is typically used to cause more structures are commonly used in the this is the very first lecture and it'll give you a brief overview of what the disruptors are what the abstract data base that they are used in the data structures and algorithms. These are the viewers the light and something that every software engineer has to grapple with at some point or the other. You cannot write any complicated bits of code without making use of some data structures and having a specific algorithm perform a series of operations on it. Now depending on what kind of program you're writing some of the standard data structures might fit right in and you can use it right out of the box. But often what you'll find is that you use standard data structures and you have to tweak it to your requirements. And this is why the study of standard structures and standard algorithms become very important. There has been tons of research on what data structure works very In what situation and what kind of algorithms we use with it. Having knowledge of all these data structures and algorithms allow you to know what it is that you need to do to tweak those existing standard systems that work for you. So let's go ahead and see what data structures and algorithms on that they commonly used. Let's start stuff from the very first principles. What are data structures data structures basically are a way to organize your information in such a way that you can you do useful things with it in a programming language. Basically what programs you take in a whole bunch of input you get away with it. Munged in such a way that you have some resulting useful output the way the input is represented. That's where the power structures are used the way you represent the output. That is also something where data structures are useful computing basically takes a whole bunch of information or forms a bunch of useful operations on it and transforms it into information which people are looking for in the final form. Data structures are used every step of the way. Data Structures represent this rich information in a format which you can read. It represents a relationship between this information as well. Their data structures help you as a programmer is to help you perform these operations in an efficient and performance to me the choice of data structure. Me might make things easier for you or more difficult. And that is why you need to choose wisely by figuring figuring out what is the data structure that you need for your code. So where do data structures help. Help you make common operations for us. Say you have a stack and the most common operation you want to do is up a stack that operation in a stack data structure should be performed in constant pain. It should be extremely lightning fast because it will be done over and over again. And if that is slow it'll ball down your entire program. Other things your data structures help us make difficult operations possible. Often you will have a whole bunch of common operations and then certain operations that you perform badly. The disruption should also help you perform that draw their operation though it may not be very performant or efficient while doing so and finally the structure should occupy the minimum amount of space possible and still represent the complexity of the information which you're trying to store and also represent it in the relationships between the entities in the information. In an interview and correct we this is where we find data structures useful. They have to meet this criteria before they can be used as a part of your code. You know that the destructors are useful only if you can use them and call efficiently and it helps you improve the performance of the operations that you're trying to get the structures that lend themselves to efficient and clean algorithms. It structures are in fact the core of many standard algorithms that you see out there searching starting grafter have a cell all built on top of existing data structures. Data structures and algorithms have a very deep and symbiotic relationship. They can be studied separately because they are so intrinsically linked with one another which is why we have this course which I them do together. So before we study data structures and be it let's kind of zoom out and get a bigger picture understanding of that exactly these data structures are uke's. There are certain specialized data structures which can be used for very specific pieces. And in fact very complicated ones so you'll be surprised that the data structure exists underneath these all. Let's consider the simplest one of these. And that is a set a set is very useful when we want to figure out containment information or membership information very quickly. You can easily imagine a liability management system where someone who comes in you want to quickly look them up in a database to see whether they are a member of the celebrity or for any kind of memberships in groups et cetera. The underlying data structure in memory will probably be a set. A set is a data structure which helps to look up membership information extremely fast. Let's look at something which is more computer science related compilers. You basically run a compiler on your own in order to convert it to a representation which your machine or your computer understands compilers extensively use the data structure hash tables as a lookup table for certain operations. For example run by a method binding in object oriented programming. When you have inheritance several members of the inherited hierarchy of classes might implement the same method which is the exact method you have to call at runtime is a runtime method binding. You basically need a hash table which specifies the individual methods within it. You quickly look up which method is been implemented and perform this association using hash tables. Compilers used this extensively a deed or structure but you might can consider a slightly more mundane. The stack is used to build very powerful functionality and you may not even be aware that it's the stack which is helping you do this. For example undo operations on all applications. These are stacked list. You make a list of all operations that you've performed on an application and keep adding it to a stack and then you hit undo. You simply pop the last operation from the stack and ask it to undo itself. The stack data structure has HAPKE perform something really complicated another thing like the stack is the back functionality in browsers you simply mean in a stack of all the users that you've visited. Anytime someone hits back in the browser you off the top you are off and then load the content of that you will once again in the browser. Again this is a stack the all important search engines of today. They use a wide variety of the structures in order to store that information. There are two of them which I'm going to call outrated. One is the suffix tree the suffix tree is basically a modified tri which stores all the suffixes of a particular word as the keys and the position weatherboard occurs in a piece of text as it's bangs as you can imagine if you want to figure it out read about lies in a document which search engines have to do a suffix three is extremely useful. Another data structure which they use is the inverted index the inverted index basically comprises of all the words that we're searching on that's a search terms and a list of documents in which the other search engines are this off line by crawling the entire Web creating suffix trees and inverted indexes and other data structures to stall or all the associated information they need. And when you actually type in a search term they use these data structures to retrieve information quickly and give it back to you in a lightning fast manner. Another interesting virtual world example is the graph. One of the most important things of the early 2000s up now and probably sometime in the future is of a social network a social network is basically a graph with bidirectional links easy my friend and I connect that to him. Who else am I connected to. At what distance a graph is a fundamental data structure which can represent this information. All the people in the social network other nodes and the friendships and the professional relationships are the Aegeus it is the graph data structure which powers the social networks of the we mentioned a little bit earlier that data structures and algorithms have a symbiotic relationship and are very closely tied together the data structure that you use heavily influences the algorithm that you use to solve your problem. That's just the way people think. And that's just the reprograming is set up. Also the algorithm that you want to use are the objectives that you want to accomplish will heavily influence what data structure you use. It's very hard to separate these. It's like the chicken and egg. We don't know which comes first. They both kind of come together to make programming beautiful efficient and elegant which is used very commonly along with it structures is abstract. Great thanks. Now if you're completely new to this idea of data structures it's very easy to get confused between the two. Let's talk about what abstractly that banks are and how they differ from data structures and abstract did that by is basically a more mathematical model of data that makes better data. Is defined by how it is used. That is from the point of view of the user. You basically know you need to be that type and want to be able to perform a whole series of operations on it. You know the behavior that you expect from the database. This is represented mathematically using an abstract database. You basically want to say this is the behavior that I want. How do you implement it. It's kind of up to you almost like an interface and an implementation relationship the abstract data type it's kind of like the interface these defined the operations that the one performed on the data and what the expected behavior of each operation is. I want to be able to pop the top element of the stack. I want to be able to access elements in a random way. I want to be able to get that last element in a list defining these interactions as a user gives you an abstracted that 8 basically a specification of bought the data type that you're going to be it looks like data structures on the other hand are concrete representations of data from the point of view of an implement once you've got the abstract that I've defined. You basically want to say what is it that you use behind it or to get an implementation which will serve the purpose of the abstractly that make you kind of know what the interface is like. Now what's the implementation that is the data structure data structures specify the actual implementation of the structure in order to meet the expected behavior. It's from the point of view of that implemented rather than the use of two round of this discussion about abstract data types. I got this definition from Wikipedia an abstract data type can be defined as a class of objects whose logical behavior is defined by a set of values and the set of operations. So you have values and you have operations which can book on them that isn't abstract data type. It does not specify how the type will actually exhibit that behavior. How that behavior will be met in court that doesn't that is not specified by the abstract think. And that is where data structures coming as a part of this course just studying data structures not abstract data types. So it's helpful to imagine them in terms of an interface.