Data Structure using Python| codin india
Data Structure is a particular way of organizing data in a Computer, so that it can be used effectively.
For Example:- We can store a list of items having the same data-type using arrays.
Data structures are fundamental concepts of computer science which helps is writing efficient programs in any language.
Python is a high-level, interpreted, interactive and object-oriented scripting language using which we can study the fundamentals of data structure in a simpler way as compared to other programming languages.
Types of Data Structure
Data structures in computer science are divided into two categories. We will discuss about each of the below data structures in detail one by one.
In today's post we will only discuss about data structure definition and its types. We will learn and implement its various types one by one with example.
Data Structure
- Linear Data Structure
- Non-Linear Data Structure
Linear Data Structure
A Linear data structure have data elements arranged in sequential manner and each member element is connected to its previous and next element. Such data structures are easy to implement as computer memory is also sequential.
Ex:- Array, Linked List, Stacks, Queues and matrices
Now we will learn basics about this Linear Data Structures:-
1.Arrays:- An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string.
2.Linked List:- Linked List is a linear Data Structure, in which elements are not stored at contiguous memory location. The elements in Linked List are linked using pointers.
3.Stack:- It is Data Structure which follows LIFO (last in First Out) or FILO (First in Last Out).
4.Queue:- It is similar to Stack but the order of operation is only FIFO (First In First Out).
5.Matrix:- It is two dimensional data structure in which the data element is referred by a pair of indices.
Non-Linear Data Structure
These are the data structures in which there is no sequential linking of data elements. Any pair or group of data elements can be linked to each other and can be accessed without a strict sequence.
Ex:- Binary Tree, Heap, Hash Table, Graph
Now we will learn basics about this Non-Linear Data Structures:-
1.Binary Tree:- It is a data structure where each data element can be connected to maximum two other data elements and it starts with a root node.
2.Heap:- It is a special case of Tree data structure where the data in the parent node is either strictly greater than/ equal to the child nodes or strictly less than it’s child nodes.
3.Hash TableIt is a data structure which is made of arrays associated with each other using a hash function. It retrieves values using keys rather than index from a data element.
4.Graph:- It is an arrangement of vertices and nodes where some of the nodes are connected to each other through links.
Python Specific Data Structures
These data structures are specific to python language and they give greater flexibility in storing different types of data and faster processing in python environment.
List:- It is similar to array with the exception that the 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:- The dictionary contains Key-value pairs as its data elements.
These are the Data Structure we will learn one by one in this tutorial.
I hope you enjoyed this post. Please stay tuned for further updates.
Comments
Post a Comment