Introduction to algorithms

Introduction to Algorithms by Harshana Codes

The algorithm is a common subject for computer science engineering students. Most of the universities offer this course as a part of their syllabus and this is a very cool and important subject. Sometimes students face difficulties in some of the topics in this subject and they could not understand them very clearly.
So, here I am going to make the subject more and more simple so that you can easily understand and even you can practice that yourself.
I will be bringing a series of articles on this topic step by step breaking down the subject to smaller chapters. And also learn that the essence of the subject does not end from the theoretical examination. It is also important for competitive exams and even programming contests. Most of the questions in the programming challenges developed from this subject. So this is one of the challenging subjects for the students because they have to solve different types of problems and have to find the strategy and approach for solving the problems. So some of the students fail to understand it properly since they could not get the approach for the strategy for solving the problems. Students feel that they are lacking in the logic development or strategy development of a program.
So I’ll be covering in-depth each and everything right from the beginning to the end.
So that you will be able to answer any type of question from this subject. I will cover the topics such that just you look at the question and then answer. I will cover those pain points which are useful for solving the questions at job interviews and other exams.
Let’s start with the introduction.
Everybody knows that algorithm is a step by step procedure for solving a computational problem. Yes, it is a step by step procedure for solving a computational problem. Then what is a program? A program also step by step procedure for solving a problem.
Then, what is the difference between program and algorithm?
So by comparing program and algorithm, I can make you understand the importance of the algorithm and the meaning of the algorithm.
If you look at the software development life cycle, in other means the phases of developing a software project, there are two important phases. They’re the design phase and the implementation phase.
If you are not aware of it, let me get to you.
If something needs to be manufactured or constructed by following the engineering procedures, then step one is the designing phase.
You know, designing is going to make your idea perfect and thorough, so that you can understand what you are going to construct or build. You can not build or construct by following the trial and error approach skipping the designing phase.
If you do not allocate time and effort to design in software development, you may waste lots of time writing a useless program by eliminating and rewriting statements over and over repeatedly.

In algorithms, what do you write?

Introduction to Algorithms by Harshana Codes

We write a clear step by step in statements that are easy to understand without using proper syntax using simple English. And most probably we may not be writing it on a machine nor computer. If you’re using a machine, then you will be writing it in a word processor application.
An algorithm is written at the design phase and when the programming is done they are done in the implementation phase. Now you can clearly understand the difference between design time and implementation time.
So at first, you take the approach for the design thinking of the inputs. Then come up with the steps involved and then complete the design of your program until the correct output is delivered.
You can desk check an algorithm to analyze the logic of the algorithm. It is a manual technique for validating and verifying the logic behind the algorithm and it does not involve the use of a machine or computer. The desk checker acts as the computer and carefully follows and analyzes the results and outputs, usually using a pen or pencil.
No matter who writes the algorithm, but the person who writes the algorithm must have domain knowledge. Yes, if the programmer has a sufficient amount of domain knowledge then the programmer can write the algorithm. The domain knowledge is the knowledge about the problem and its solution.
You can use any language to write an algorithm or you can use some mathematical notations as long as it is readable by those people who are using it. If you are writing it in the English language it will be like writing sentences or paragraphs. If you can write, you can use mathematical notations too and it’s better if you can use mathematical notations. If the designer has written an algorithm then the programmer will be writing a program for that. So designers should understand as well as programmers should understand the content of the algorithm.
Programs are written only using programming language like C, C++, Java, and Python, etc. So you can use different languages for developing a program using the syntax defined to them.
After writing an algorithm it is analyzed to determine whether it is efficient enough in time and space. We will look into the analysis of algorithms in a later chapter. It is a very important and interesting topic in the subject of algorithms. When a program is finalized, it is tested to check whether it produces the desired output.
When writing an algorithm input and output should be precisely specified and identified. So, I think you have a clear understanding now about the differences between a program and the algorithm.
And In the end, eventually, the algorithm should be able to terminate itself after giving the output. After writing an algorithm it should only have one interpretation and should give the correct solutions in all cases. There can not be multiple interpretations of an algorithm and it should be able to satisfy all the cases.
In simple words, an algorithm is like a recipe. It involves inputs, a series of clear steps, and finally the output.

Introduction to algorithms by Harshana Codes




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

SQLAlchemy Cheetsheet

My New Side Hustle Mantra: Progress Over Perfection — The Daily MBA

Build your own time server with a GPS receiver.

What is AWS and how to get certified?

Switching JDK versions locally

Advantages and Disadvantages of RPA

How innovative analytics improve the chance of success in job seeking

#14 AWS Weekly Update (26 Oct 20)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harshana Codes

Harshana Codes


More from Medium

Approach to Solve a Programming Problem

Coding Problem : Portfolio Balances (HackerRank)

Live-journaling my road to a coding interview: Days 0–1

Interview Experiences Series — TapClicks