Peter Banjo
Soliloquy

Soliloquy

Tasty Algorithms in a Data Structure dip

Photo by Gaining Visuals on Unsplash

Tasty Algorithms in a Data Structure dip

Peter Banjo's photo
Peter Banjo
·Jan 19, 2022·

2 min read

Play this article

A useful way I like to remember what data structures are is the mnemonic “DORITOS”. Where D is Data, O is Operations, R(i) is Relationship, T(o) is time and S is space.

Let’s consider a recipe to make a tasty salsa dip for our Doritos. We can make a tasty, tomato salsa sauce with a recipe that includes tomatoes, red onion, garlic, white wine vinegar, lime juice and coriander. We peel and chop the tomatoes, peel and dice the onions, peel and crush the garlic and slice the coriander. We add and stir all of these ingredients in a bowl with vinegar and lime juice. Now we have a salsa dip for our Doritos - yum! Notice how it’s not possible to peel the white wine vinegar? Or chop lime juice? Those operations are not allowed on those ingredients.

Computers process data to create results like in a recipe. We call these recipes algorithms and prefer them to take less time and memory. Like in our recipe, there is some preparation required before an algorithm can work. We prepare the data points by grouping them together in a meaningful way. Data points relate to each other like which one comes first or last. Or in what shapes like a list or a tree. We can also add, remove or move around data points in a group.

One more thing, so that the computer can keep track of all of the data, the data is saved as Binary Objects With a fixed Length (B.O.W.L.). Let’s picture this to let it sink in – Doritos dipped in a bowl of tasty, tomato salsa: algorithms and data structures have never tasted so good.

Putting this together – we create data structures by grouping data points into a structure (data structure) that defines the relationships and operations between each of them. Computers use algorithms to operate on data structures and this takes time and space (memory). We describe the time and space complexity of an algorithm using the Big O notation.

 
Share this