Data Structures in Python: Introduction
If you are programming for some time in any language you must have heard word data structures from your colleague or someone else. Whichever language you are studying at least once you must go through data structures. In this series, our focus will be on data structures with python(python3).
First of all, don’t confuse yourself between data structures and data stored in data storage. Data stored is different from data structures.
Data Structures is a fundamental concept in computer science that helps us in writing efficient programs so that it works fast and we can manage the space it takes in memory every time it runs.
In this lecture, I will provide a short overview of some frequently used data structures in python. Just read it once to get an overview and it's good if you are having confusion coz we will dive deep into each type one by one from the next lecture onwards.
General Data Structures
Various data structures in computer science are divided into two categories given below:
Linear Data Structures
These are the data structures where elements are stored in a sequential manner:
Array — It is a sequential arrangement of data elements paired with an index(address) of data elements.
Linked List— Each element contains a link to the next element along with data.
Stack — This is similar to what you imagine with the stack. It’s like a stack of elements following a specific order of operation. LIFO(Last In First Out) or FILO(First In Last Out).
Queue — This is similar to stack but the order of operation is FILO(First In First Out).
Matrix— It is a two-dimensional data structure in which the data element is referred to by a pair of indices
Non-Linear Data Structures
These are the data structures in which there is no sequential linking of data elements.
Binary Tree — It is a data structure where each data element is connected to a maximum of two other data elements. It starts with the root node.
Heap— This is a special case of tree data structures where data in the parent node is strictly greater than or equal to child nodes or strictly less than child nodes.
Hash Table— It is a data structure that is made of arrays associated with each other using a hash function. It retrieves values using keys instead of indexes.
Graph— It is an arrangement of vertices and nodes where some of the nodes are connected to each other through links.
Python Built-In Data Structures
These are the data structures provided with python. They give greater flexibility in storing different types of data and faster processing in a python environment.
List — It is similar to an array with the exception that data elements can be of different data types. You can have both numeric and string data in a python list.
Tuple — Tuples are similar to lists but they are immutable which means the values in a tuple cannot be modified they can only be read.
Dictionary— It contains Key-value pairs as its data elements
In the next lesson, we will dive deep into these data structures and clear our concept.