Gilbert Adjei
Sep 1, 2018 · 2 min read

DATA STRUCTURES AND ALGORITHMS

In the life cycle of every computer scientist or an I.T enthusiast, you probably would have come across the word data structures and algorithms. Definitions often are not so compelling and leave people in limbo about this important concept in computer science. In this story, I am going to share the very basic definitions of data structures and algorithms and how beneficial it is to computer scientists.

Algorithms are step by step processes of solving a problem. Why do we even need these algorithms? We need algorithms as computer scientists because we want to know how efficiently our programs would run given space and also how fast our programs would be running. Simple? Huh?

Before we dive into data structures, we need to understand this important concept called Abstract Data Type, ADT for short. What is ADT? You probably would be wondering. ADT is simply a logical description of how data is viewed without necessarily worrying about how it is implemented. Yes that simple! An example of an ADT to cement your understanding is an integer. Well from basic school we know numbers like -5, -4, 2 ,9,12…. are all called integers. But under normal circumstances computers generally represent numbers as binary, that is 0s and 1s. But which user really cares how computers represents when (s)he types 1,2,3..etc. That level of “hiddeness” of how integers are represented is what makes it to be an Abstract Data Type.

Now that we understand ADT, let’s step up our game to understanding what data structures are. Data structures are just the implementation of ADTs using programming constructs and primitive data types. So basically, anything that can store data and operations be done on can be referred to as a data structure. Examples of data structures are stacks, linked lists, arrays. etc. I’m going to explain one data structure, stack, and implement it using python. Once we have understanding of stacks, the rest can easily be read online. Generally a stack is a data structure that operates using the Last-In-First-Out principle. That is to say elements are removed and added at the end. Stacks have the following operations:

push(): adds elements to the end of the stack

pop(): removes last element in the stack

isEmpty(): checks to see whether the stack is empty or not

peek(): returns the last element in the stack

size(): checks for the size/length of the stack

Implementation using python

Thank you for taking time to read. All contributions are welcome. Let’s learn together. Show some love by sharing and liking :)

github repo:

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade