Introduction and Tips,  Programming

How to Begin Programming for Coding Interviews?

Are you a beginner looking for an introduction to programming? Do you want to learn programming to crack interviews of top companies, specifically, product based companies like FAANG! Wondering what are coding interviews and why do tech giants conduct them for hiring candidates? If it is so, look no further, as in this post, I will answer all these questions which come to everyone’s mind when they start their programming journey!

Beginning Programming

Keeping aside all those technical definitions that might confuse people, imagine a computer as a human being who knows and understands a particular language. In our case, it can be English, French, Chinese, Spanish and so on. Similarly, for a computer, it understands a language what we call as a Machine Language.

Begin Programming for Coding Interviews

So, what is a Machine Language? Well, a Machine Language is a Binary Language, which means it consists of 2 digits, 0 and 1. Now, try to recall some basic mathematics which we all studied in high school. Do you remember how we converted a number from decimal system (a number made from 10 digits – 0 to 9) to a binary system (a number made from 2 digits – 0 and 1)? That is exactly what we are talking about here.

Understanding the Binary System

Let us take, the number 5, as an example. Now, in Binary it can be depicted as 101. How did you convert it? Well, the idea is simple,

  1. Divide 5 by 2, we get 1 as remainder, which becomes our first digit (rightmost digit).
  2. Divide our quotient, which is 2 in this case, again with 2, remainder becomes 0, which is our second digit.
  3. Once the remainder becomes 0, check the quotient.
  4. If the quotient is not 1, keep repeating the process until it becomes 1.
  5. In our case, it has already become 1, which is the leftmost digit in 101.

In other words, what we just did can be summarized as:

(1 x 20) + (0 x 21) + (1 x 22) = 1 + 0 + 4, which is 5.

Now, a question might arise in your mind, why did we divide 5 by 2 repeatedly? Why not a number other than 2? Let’s go a little deep into this concept!

A number can either be even or odd. Now, how do you figure out whether a number is even or odd? By dividing the number by 2, right! If we get a remainder as 0, we say the number is even and when the remainder is 1, we conclude that it is an odd number.

What this means is we can create any number using the sum of powers of 2, but how? Observe this,

20 = 1, 21 = 2, 22 = 4 and so on,

Can you represent the number 3 ,which lies between 2 and 4, using the above information? Yes, you can!

3 = 2 + 1, which is, (1 x 21) + (1 x 20) .

Notice, if you can create the numbers 1, 2, 3 and 4 using the number 2, will you be able to create other numbers higher than these using the sum of powers of 2? Of course!

So, now you know, why, the number 5, is represented as 101 in binary and why do we use binary numbers,

(1 x 20) + (0 x 21) + (1 x 22), which is 1 + 0 + 4, observe how you can convert any power of 2 to zero by multiplying it with 0.

Since, we are converting 5 into a binary form, so for every digit, we had just 2 possible options, either we use a digit 0 or a digit 1 for multiplication (to use 0 or the power of 2 for making the sum equal to 5).

In the world of computer-science, these binary digits (0 and 1) are called bits and 8 bits constitute 1 byte. We will learn more about them at a later stage!

For now, understand that this is exactly the form in which a computer represents a number 5.

Programming Language

Imagine, if you need to communicate something to a computer, which might not be a number 5 (can be an English sentence), how will you do it?

It would be impossible for you to convert it into a binary form!

So, now you require a medium to communicate because both you and computer speak different languages. For example, a German native can communicate with a Swedish native if both know a common language i.e., an international language, English.

This is where the concept of Programming Language comes into picture. There are lots of programming languages available in the world which programmers use for a variety of purposes, to solve a variety of everyday problems, most popular of them being JavaScript, Java, Python and C++. You might have heard these terms but if you have not, do not worry, you will understand what they are as you learn more!

As of now, just remember that all these programming languages are understandable by us and with the help of a compiler, they convert our instructions/program into an intermediate Machine Language code called bytecode(or Binary whatever you want to call it), which the computer hardware is able to understand and work with!

This process of passing instructions to a computer for solving a particular real-world task or problem is called as Programming.

Why is Programming so Popular?

The answer to that is simple. A computer can solve problems which would take a lot of time to compute if done manually.

For example, imagine computing the sum of numbers starting from 1 to 100000 without using Arithmetic-Progression! Sounds impossible, isn’t it?

With the help of programming, you can do it within seconds on your device. Obviously, doing it without using the formula for Arithmetic-Progression is a bad idea but this is a good enough example to understand how powerful a computer is!

Some tasks might seem impossible to solve without the help of a computer. It not only solves problems efficiently, but also accurately. Just imagine how much data does Google generate across the web every single hour! Will it be possible for them to maintain and index this much amount of data without a computer? Of course, not!

So, they do require computer programmers and so do every other company across the world. That is the reason why computer programming is such a popular profession in the world right now and it continues to grow even further!

Why do Product Based Companies take Coding Interviews?

So, why coding interviews? Let me answer this question in a simple way! Coding interviews are designed to test your problem-solving abilities. Top companies have a lot of real-world problems for programmers to work on.

Sometimes you need to think an out of the box solution for a problem, or you need to resolve a problem in the existing system, or maybe, you need to add a new feature to it.

All this requires logic, creativity, thinking ability and problem-solving. Coding interviews help interviewers to understand how do you approach a complicated problem which is new for you?

How do you use your existing knowledge and understanding of programming to solve that problem?

Are you able to improve or optimize the initial solution you provided for a particular problem?

And finally, you did figure out an amazing solution that works like a charm, which shows you are a great thinker, but to prove you are a good implementer as well, you need to be able to code it!

I hope this article helped you in learning about the topic you were looking for. If you found this article helpful, share it with your friends and peers who want to learn programming in a fun way!

See you in the next one😀.