Sitemap

Data Structures

3 min readApr 1, 2020

--

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 ,
Press enter or click to view image in full size

A real life example of data structure might be , your grocery list ,there are various ways you might write stuff on your list:

  1. random groceries coming to your mind.
  2. groceries based on priority levels .
  3. groceries based alphabetically .

Various classification of Data Structures:

Press enter or click to view image in full size

Memory :

There are two mechanism for storing data on your computer:

  1. Memory (RAM) — volatile memory
  2. Storage (ROM) — non volatile memory

memory is like a temporary storage option , as it is faster and efficient to access data from memory.

Press enter or click to view image in full size

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 .
Press enter or click to view image in full size

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 ,
Press enter or click to view image in full size

Here in Diagram 2 , There is an array from 0 to 1 and 7 to 8 of size 2.

Get Hridyesh bisht’s stories in your inbox

Join Medium for free to get updates from this writer.

Originally published at http://programmerprodigy.code.blog on April 1, 2020.

--

--

Hridyesh bisht
Hridyesh bisht

Written by Hridyesh bisht

Hello, currently a sophomore at symbiosis institute of technology. An Athlete, A Geek and A Musician. Twitter handle: https://twitter.com/hridyesh_bisht.