Introduction To Data Structures and Algorithms

If you are in tech field am sure you come across this topic almost daily,either mentioned by friends or interviewers.Recently, have been trying to make myself busy -- fighting imposter syndrome,looking for internships,upskilling technically and non-technically,tech communities( Developer Stories Africa ),interviewing e.t.c.

Some of the assessments and interviews tested my knowledge of data structures and being sincere I never tried solving the challenges and in others I told the interviewers I didn't know anything about data structures(I was told being sincere is better than fumbling lies haha). From these experiences I thought about learning them,this reminded me months ago when I started learning coding and was advised to learn data structures but they never made any sense -- or maybe the method I used was wrong.Most beginners when told to learn(especially non-degree/self-taught) they go to solving challenges on sites like Hackerrank or leetcode without going through basics and understanding what data structures and algorithms are (or maybe it's only me). Most of the times you will find challenges which needs to be solved while taking into consideration time and space complexity and this is where most people give up. In this series, I will be sharing what I learn as far as data structures and algorithms are concerned.

Data Structures

Most of the times you will find yourself dealing with information and will store them in a server or a database. Data structures is focused on how you organize and store data for ease of access or addition of other data.

Algorithms

Before you solve a task, you mostly come up with steps to follow when solving it. e.g to send a SMS to another person:

  • open message app
  • select contact
  • type message
  • click send button

This is an algorithm,they are step-by-step procedure which defines instructions to be executed in a certain order to get the desired output.They can be implemented in more than one language,in our example - the algorithm can be used irrespective of the type of phone you are using.

Algorithms are usually used when dealing with data structures and some of the categories are:

-> Search - searching for an item in a data structure.

-> Sort - sorting items in a certain order.

-> Insert - insert an item in a data structure.

-> Update - update items in a data structure.

-> Delete - delete an item in a data structure.

Algorithm Analysis

When coming up with an algorithm, you will mostly have to consider different outcomes and with that you will be able to decide on the best solution.

  1. Priori analysis - this is a theoritical analysis and is mostly focused on assumptions. It is done before executing an algorithm.e.g n algorithm will execute using same time in all computers irrespective of their processing speeds.
  2. Postorior - this is an analysis based on results and is done after executing a problem.

Algorithm Complexity

Space Complexity

This represents the amount of memory space required by an algorithm in it's lifecycle.

Time Complexity

This represents the amount of time required by the algorithm to run to completion

Asymptotic Analysis

When coming up with algorithms you'll find those which perform poorly,averagely or works best. Asymptotic analysis refers to defining the boundation/framing of an algorithm's runtime performance using mathematicals units of computation. Usually :-

  • Best Case - minimum time required for an execution
  • Average Case - average time required for an execution
  • Worst Case - maximum time required for an execution

Asymptotic Notations

a) Big 0 notation (0)

0(n) is a formal way to express the upper bound of an algorithm's running time(worst case or longest time).

b) Omega notation (Ω)

Ω(n) is the formal way to express the lower bound of an algorithm's running time(best case or shortest time).

c) Theta notation (θ)

θ(n) is the formal way to express the lower bound and upper bound of an algorithm's running time(average case).

This is a series and I will be publishing every week,next article....

Thanks for reading.