Algorithms and Data Structures

Algorithms and data structures are concepts that are used in various programming languages. A data structure is a way of storing information in a computer while algorithms are operations performed on data structures and sets of instructions for executing them.

To further explain, I will use examples. Let’s for instance use the array data structure. An array data structure is a collection of elements, each of which can be identified by a key. Imagine you are throwing a party at your house and you invite a couple of friends.You at best expect 80 of your friends to show up for your party. You then tell your friends to each come to the party with a balloon which has their name written on it. Also, you prepare partitioned boxes so that as each friend enters you place their balloon in a partitioned box so that you can keep track of which friend attended your party.

array of boxes

The array data structure in this case is setting up boxes to store the balloons while the algorithm is the act of placing the balloons containing the names of your party guests into the boxes so that later on when you check the different boxes you can then know which of your friends attended the party.

Another example of a data structure is a linked list. This is a data structure which consists of a set of data records or nodes linked together and organized by links or pointers.

Image of a linked list data structure

With a linked lists, it is easier to add characters than in an array. In order to add a value to the linked list, you simply create an abstraction and place it into the linked list by shifting the pointer.

An example of the linked list is a queue list which takes the first in first out format. Say, that it is lunch time and food was being served in the dinning. In order to be served food, people will have to make a line. In this case, whoever arrives first in line will be served first and then the next person, and the next person until the final person is served.Therefore, the line format is the data structure and the process of being served food to each individual is the algorithm.

Lastly, there is also a stack list. With a stack list, the data structure takes on the format of first one in and last one out. Let’s say, you are making chapatis and after making each chapati you place it on a plate.You eventually get a stack of chapatis with the first chapati you made being the last one on the plate and the last chapati you made being the first or on top of the stack of chapatis. When the chapatis are being eaten, the one on top is eaten first and the one at the bottom is eaten last.

A stack of chapatis

Other types of data structures are strings,tuples and so on.