Primitive Data Structure: Lily’s Pebbles
Lily, the curios explorer loved collecting shiny pebbles from the riverbank and storing them in her special treasure box. Each pebble had a unique color and size, and Lily cherished her collection dearly.
One bright day, Lily decided to organize her pebbles in a more systematic way. She gathered her pebbles and sorted them into different piles based on their colors. Red pebbles went in one pile, blue pebbles in another, and so on. This sorting process represented primitive data structures.
Numbers:
In Lily’s collection, she had some special pebbles with numbers painted on them. These numbers represented the size of each pebble. She sorted these pebbles from smallest to largest, creating a line of pebbles. This line of numbered pebbles was similar to a primitive data structure for numbers.
Characters:
Lily also had pebbles with letters carved on them. She sorted these pebbles alphabetically, creating a row of pebbles with letters in order. This row of lettered pebbles was just like a primitive data structure for characters.
Booleans:
Among her pebbles, Lily had a couple of unique ones - a shiny gold pebble and a plain gray pebble. She decided to use these pebbles to represent ’true’ and ‘false’. When she needed to remember something, she placed the gold pebble in her treasure box. If she didn’t need to remember, she put the gray pebble instead. These pebbles acted like a primitive data structure for booleans.
Lily’s pebble organization made it easy for her to find exactly what she was looking for. When her friends came to admire her collection, she proudly showed them how she had sorted her pebbles into different categories.