Introduction to Array Datastructure

Introduction to Array Datastructure

Ram understands very well that in order to tackle any programming challenge, he must learn about data structures and methods. Ram told himself, "I'll start with each datastructure and fully understand it before moving on to learning different algorithms." He then started studying by opening his laptop.

No alt text provided for this image
Ram reading Arrays topic

While Ram was hovering through all the datastructures, he encountered Array would be nice to start with. He mumbled few lines about Array, until he heard a loud voice from kitchen, “Raaam, get 10 Eggs from market, take the egg carton from the fridge and leave immediately.” Yes, that was his mother asking him to get eggs. Ram knowing what would happen if he didn’t start, left immediately with the egg carton which can hold up to 10eggs.

No alt text provided for this image
Eggs Carton


On his way to the store, Ram is clutching the carton and smiling as he recalls a memory. Last time when he forgot to bring the carton to buy eggs, Ram tried to hold all eggs in his pockets and few in hands. Eventually when he reached home, all his pockets were wet as a couple of eggs were broken in his jeans and got nice yell from his mother.

No alt text provided for this image
Poor Egg in Ram's jeans

On his way back, Ram ran into two of his buddies, Abdul and Robert, who had also purchased eggs. Ram first saw Abdul on his journey, who, like him, carries a carton.

Ram: Abdul, did you buy ten eggs like me?

Abdul: No Ram, only two eggs.

Ram: Then why did you bring that carton with you, which you can carry with your hands and is a waste of space?

Abdul: Yes, Ram, but mom instructed to bring eggs with the leftovers from the vegetables. I only had enough money to buy two eggs after I bought everything.

No alt text provided for this image
Ram with his carton of eggs


Ram then understood and waved goodbye. He ran across Robert on his way home after Abdul. Ram told Abdul's complete narrative and spotted Robert holding two eggs in his left hand and a carton in his right.

Ram: Hello, Robert. Why are you transporting eggs by hand when a carton is available?

Ram: The carton is full, Robert. As the price of eggs fell, the shopkeeper gave two extra eggs. Goodbye, Ram.


Ram acknowledged Robert's understanding and waved before following him home. Now Ram sat down after the market to unwind a little. He now pulled out his book once more to study arrays. Ram learned that an array holds data of related datatypes in a sequential manner. When Ram read that an array is static in nature and that the size must be fixed when declaring it, he immediately thought, "Yes, it's just like that carton box of all the eggs (similar datatype)," but what really excited him was the statement that if the user declared a large size but used a small number of array blocks, the remaining space would be wasted.

No alt text provided for this image
Every round is an element, arranged sequentially

Similarly, if a user declares less space than necessary but later realizes that they require more space than they originally thought. Even in that case, it is a problem with Arrays. So, programmer must be aware of the size before while declaring an array, just like Ram carried carton of size 10, when he know he has to carry 10 eggs. He was surprised to discover that he had a real time experience of what he’s learning with two of his buddies when returning home. This improved Ram's comprehension of the Array Datastructure and made him more enthusiastic learning Arrays.

Array is a fundamental datastructure, Read more about arrays below.

Wishing you a happy learning... :)


To view or add a comment, sign in

More articles by Putta Hemanth Kumar

  • Merge Sort Technique

    Ram is determined to conquer the formidable Merge Sort, a sorting algorithm that had always been a bit of a puzzle for…

  • Binary Search Algorithm

    Ram, who is passionate about coding had managed to learn all the fancy data structures, much to the amazement of his…

    2 Comments
  • Introduction to Stacks

    Ram, had recently completed his studies on arrays and linked lists, and now he was ready to embark on a new data…

  • Introduction to Linkedlist

    Ram has completed his learning and practice in array data structure, He understood all the pros and cons of arrays, Now…

  • A brief Introduction to DSA

    Ram, who is knowledgeable about various programming datatypes and functions, wanted to learn more about data structures…

  • Introduction to Functions

    Ram, has learned and experienced what are primitive datatypes and what are user defined datatypes. Now he tries to…

  • Introduction to Structures and Classes

    Ram, now has a good clarity on Primitive Datatypes, now he’s learning User defined datatypes. While doing so he…

  • Introduction to Primary Data Types

    Ram, a curious student who wants to learn DSA and started with primary datatypes. Ram is confused after looking at…

    3 Comments

Others also viewed

Explore content categories