Data Structure is a way of collecting and organizing data ,such that we can optimize our code .
For example 1.You can either Store data in tuple or list , depending on operations you want to perform. 2. You can either use yield function use in python or declare data type to store temporary data.As you can see below ,

A real life example of data structure might be , your grocery list ,there are various ways you might write stuff on your list:
- random groceries coming to your mind.
- groceries based on priority levels .
- groceries based alphabetically .
Various classification of Data Structures:

Memory :
There are two mechanism for storing data on your computer:
- Memory (RAM) – volatile memory
- Storage (ROM) – non volatile memory
memory is like a temporary storage option , as it is faster and efficient to access data from memory.

Memory is divided into multiple segments , two of important ones are stack and heap
1.Stack : it's where some of your processor's information gets saved , for ex : functions ,variables , etc .This memory is managed by program. It works on LIFO principle .
2. Heap : Used to allocate big data of memory ,this is what we call Dynamic Memory .This memory is managed by programmer .

How are variable stored in memory :
You can think ram as a box ,divided into smaller cells ,each cell holds equal data . When you store data in a variable it gets converted into byte's , and each byte =8 bits , each block can hold 4 bits . For example : When you write int a =2 , a gets stored with binary value of 2 =0000 0010 , first four bits are stored in one cell and other four bits in next adjacent cell.
Array :
It is a collection of same data types ,it is stored continuously in memory.
for example : int a[10] //declares an array of size 10 . a[postion_you_want_to_access] can be used to access a particular location of an array ,


Here in Diagram 2 , There is an array from 0 to 1 and 7 to 8 of size 2.
The follow up post is https://programmerprodigy.code.blog/2020/04/25/linked-list/
One thought on “Data Structures”