top of page

# Data structures from scratch- Bot-up series #5[Prerequisites for data structures II]

A little recap of the previous post

Memory vs storage

Memory in computers are RAM

RAM is like shelves. Each shelf contains 8 places or slots →1 byte

There are limitations in 8-bit configuration and hence 32-bit and 64-bit configurations

Today we will build data structures ourselves or at least feel like building

Let’s take 10 shelves and each is numbered accordingly

Purpose of shelves?Simple to store data

For simplicity, we will consider numbers and characters(most primitive ones)

From the last article, we found limitations on storing in single-byte because at the max it can store a value of 255

Therefore we use 4byte(32 bit) or 8byte(64 bit) system

Just like numbers, characters are stored in a similar fashion except each character is mapped to the number and eventually, number is converted into binaries. This mapping is called encoding.

So far simple…I think this is time to complicate things(Just a bit)

What if we have to store a group of numbers or characters Why? In reality, we don’t use single characters or numbers Take for example, ‘John Doe’ is a string that consists of many characters

Let us store a group of numbers

Just 3 numbers (420,377,370)

Positions — 0, 1, 2.

Value — 420, 377, 370.

Illustrated:

To store each value, we allocate 64 bit(8 bytes or 8 slots)

To store this group of numbers, we need 24 bytes of a memory location(i.e 8*3) or I can say I need 24 shelves

We will look for 24 continuous and uninterrupted shelves in RAM Then we will store the values.

Okay. We stored and our purpose is solved. But wait!

What if we can find insights over here?

1)I stored a group of numbers 2)I stored a group of numbers in the same order as positions 3)I stored a group of numbers in continuous and uninterrupted memory locations in RAM 4)All the values stored occupied the same number of bytes 5)All the values stored are of the same type ‘numbers’

Pardon me if I beat around the same bush but it's worth it. Essentially here we are describing what we have done from different perspectives

If the storage fits the above description, it is called ‘Array’ in the computer world. Yes! we built an array

## Recent Posts

See All

As there are many programming languages, there are many programming paradigms. Programming paradigm = style of programming = set of guidelines to solve the problem. So, many programming languages evol

bottom of page