The Story of My Journey to Codeguage — Part 2

Getting into the world of algorithms

Codeguage
Level Up Coding

--

Roadmap of my journey to CodeGuage

In the first part of this series on my journey to Codeguage, I talked about how exactly I got into programming and web development just by a 7th grade book.

Below I’ll leave a link to it so that you can read it, if you haven’t, before proceeding with this second part:

In this part, I talk about how I got into the world of algorithms via an introductory course on algorithms on Khan Academy and then after having failed in the Canadian Computing Competition.

Let’s begin.

Into the world of algorithms

For almost like 3 years, I continued to learn HTML, CSS, JavaScript, PHP and MySQL, in addition to a couple more simpler technologies revolving around these.

I never got introduced to algorithms at any point in these 3 years — not even binary search!

Isn’t this surprising?

Now, I’ve forgotten a little bit of details of the time beyond this, except for the point when I first got to see a glimpse of the huge world of algorithms in programming.

Let’s talk about that…

Introduction to Khan Academy

While searching for a given concept of mathematics, as I was learning it for my CAIE O Levels, I guess, I came across this awesome site called KhanAcademy.org.

There, while I was learning about math, I saw a section devoted to computer algorithms.

Already having a bit of programming experience under my belt, I thought of giving it a try.

Back then, this algorithms course didn’t have a huge list of chapters to go over — they were only a few in number. But it was crafted very nicely. I can still recall a pacman-based analogy to understand breadth-first search (BFS).

Anyways, as I completed this short course (actually, I won’t call it a ‘course’, but rather as a ‘quick intro’), I realized about the beautiful and humongous world of algorithms in computer science.

But wait here… The real appreciation would come a little bit later from one of the most celebrated books on algorithms, i.e. CLRS.

Enrollment in Canadian Computing Competition

At some point, in the first year at college for my CAIE A Levels, all the students in the college received an email about a coding competition.

It was an online competition held by the University of Waterloo, referred to as the Canadian Computing Competition, or CCC for short.

BTW, each year, the University of Waterloo still conducts this competition. I don’t know about how individuals could sign up for it. All I know is that schools/colleges enroll in it and thereafter allow their students to be a part of the competition).

Interested students were asked to register via a form sent in the email.

Now when I got the email, without further ado, I read about the competition on the official website of CCC. Clearly, I felt a desire to enroll and so I did. I signed up for my first ever competitive programming competition.

Now you might be thinking that how was I able to hop into competitive programming with just being a person familiar with JavaScript and PHP.

Were you?

Well, the music to my years was that CCC accepted solutions in PHP. That was a driving factor which led me to convince myself to take part in the competition.

Had the competition asked only for C, C++ and Java, which is quite standard for ‘real’ competitive programming competitions, I wouldn’t have taken part in it.

Anyhow, right then, it was time to start practicing past problems of CCC. This was the very first time that I got to read questions asking to solve a logical/mathematical problem via a piece of code.

It was new ground for me.

As I said before, I was familiar with the idea of algorithms prior to opting for this competition (recall KhanAcademy), but still, getting to comprehend the problem as stated in a given CCC question and then writing code to solve it was an entirely new experience.

In fact, it was so new that I didn’t even know about standard output and standard input! 🙂

I spent tons and tons of minutes on finding what exactly was standard input and output in PHP and how exactly to retrieve a line of input from a particular CCC question via a PHP program.

Moving on, I chose for the junior level of the competition after having read a couple of senior level problems.

Why?

Well, I am sure you would know about this thing that there are two kinds of questions that we call ‘difficult questions’:

  • Ones that you understand but can’t figure out the solution to.
  • Ones where you don’t just understand anything in the text of the question, let alone thinking about the solution. 😑

Senior level problems were an instance of the latter case. It was totally out of my reach to even try to understand what the questions were asking for. They were filled with mathematical rigour, specifically geometrical and graphical.

So coming back to the discussion, I went for the junior level and began practicing junior level problems from the CCC website up until the day of the competition.

An interesting story

There’s is an extremely interesting story that I consider worthy of sharing with you guys here.

Before the day of the competition, one person for the admin office at the college summoned all of the participants at the office to brief about the competition’s day, i.e. where would we show up, at what time, what to bring with us, and so on.

I somehow managed to be there before all the other participants.

There I got to know that there were 4 junior (including me) and 1 senior level participant. The one in the senior level had Further Mathematics as one of this subjects in the college, was a teacher’s assistant for the subject, and a well-known genius of mathematics in the college.

When I got to know that he was the one in the senior level, that surprised me because I never ever knew that the guy did coding as well.

Anyways, after a certain span of time, as I waited in the admin office for the other participants to come, the person who had summoned us all asked me a question:

“Are you a computer science student (here in college)?”

I said “No.”

“Then how will you be able to compete in the competition?” she replied.

I smiled and replied back “Don’t worry, I’ll manage it.”

We might be tempted to think that a computer science degree (university) or the computer science subject (CAIE O and A Levels) is a prerequisite for performing well in the field and to be able to solve computational problems.

But the reality is that this is NOT THE CASE.

A computer science degree is not required to perform well in the field.

I didn’t have computer science as a subject for my A Levels, but I knew that I didn’t need it to take part in a coding competition and perform well.

All that is required is a good mathematical background and a good sense of reasoning and logic. That’s it.

The day of the competition

On the day of the competition, as briefed, we gathered in another branch of the college, set up our desks with our laptops and the all-time-favorite pens and papers, and waited patiently for the competition to commence.

As it began, all that could be heard in the room, amid the silence, was the sound of keystrokes. We all were in a hurry to code as we had just 3 hours to complete the competition with 5 problems to tackle.

This might seem like a lot of time, but it really wasn’t — consider the time taken to read the questions, thinking about the solutions by scribbling with the pen on the paper, typing code (no one typed fast amongst us, back then), debugging programs, looking up the documentation of languages for given functions, and so on.

Competitive programming is always a run against time!

The first question was quite straightforward and so I got done with it in a couple of minutes. The second one was also fairly simple. The third one was yet another rudimentary problem and got solved in a short span of time.

The fourth question was on array rotation, which I had never done before, along with some more complex array processing. This question took most of my time. But in the end, I solve it as well.

The fifth, and the last, question was the most challenging, but I seemingly thought of having figured out its solution as well. I reasoned that the problem could be solved using breadth-first search, and likewise went out on coding a BFS algorithm based on the scenario of the question to solve it.

I had just a few minutes remaining and so was getting more and more nervous. But the coding went on.

You know that feeling when you know that you can solve a given question, but fear that the time might keep you from doing so?

In the end, with just 2–3 minutes remaining, I was done and submitted the solution. While gazing over the grader system to tell me whether my solution was correct, I got to see something that I wasn’t desiring — a ‘Wrong Answer’ verdict.

Realizing that nothing could be done now — with just 1–2 minutes remaining — I had to abandon the question. And thereafter the competition reached its very end.

In total, I was able to solve 4 out of 5 questions. My friend, who was sitting next to me (but at a distance to prevent any kind of cheating) and coding in C++, also solved 4 questions, and not the last one.

One friend, coding in Java, wasn’t even able to solve the third question (on array rotation), let alone the fourth and the fifth one. As for the fourth junior level participant, I don’t remember his score, but he wasn’t also able to solve the fifth question.

As for the senior level guy, he only got the first two questions correct. The third one got him to spare all of his time, ending up with a ‘Wrong Answer’ verdict, nonetheless.

Recall that this senior level guy was a further mathematics student, yet that wasn’t enough to give him the tools to tackle such complex computational problems as introduced in the senior level of CCC.

Back in our college, it was a common belief that only the truly exceptional people could take Further Mathematics, and that it was extremely difficult mathematics to deal with. (You can even look up the syllabus of Further Mathematics here).

For a second, let’s accept the fact that Further Mathematics is tedious (which I don’t feel it is).

Then what about the true maths used in computer science?

Think of number theory, Boolean algebra, relation theory, graph theory, combinatorics, automata theory, probability theory, and so on. These topics are much more complicated in their whole than the mere ideas of Further Mathematics.

Without any second thoughts, today I am a firm believer of the fact that Further Mathematics is nothing compared to the mathematics used in computer science, if one approaches computer science the right way.

I feel that people don’t generally realize that computer science does require some sophisticated mathematics under one’s belt.

But please don’t get me wrong. I don’t say that programming requires sophisticated mathematics — not at all!

One could be a proficient frontend web developer, a backend web developer, a desktop app developer, or anything of the sort, without really knowing about Euler’s totient function, or about the internals of the RSA cryptosystem, or about Cantor’s diagonalization method.

All I say is that the field of computer science requires one to have a firm footing in mathematics.

If people out there say that this isn’t the case, then it’s their call. I can’t really see how to leverage the most out of a computing machine without employing the essence of mathematics.

What do you think?

Once again, coming back to the competition, this was it for the competition. I wasn’t able to solve the last question, even though I was seemingly 100% sure that the solution was via BFS.

I didn’t achieve any reward in the competition, just a certificate of participation.

BTW, the reward was for people who solved all the five questions. I wish I was able to solve it as well.

But what I had achieved was much more than a reward — I got a will now inside of me to learn about algorithms.

And from this point onwards, as I can recall it, I started to read the book Introduction to Algorithms 3rd Edition— CLRS.

At the time of this writing, the 4th edition of the book is also out.

And this is how I got into the world of algorithms.

Moving on

But the story doesn’t end here…

In the next article, I’ll talk about how and why I abandoned reading from CLRS, and took up another book, however not to learn algorithms, but to learn mathematics.

Till then, have a good time programming and learning! 🙂

BTW, if you enjoyed reading this post and the content back at Codeguage, you could support me by buying me a coffee ☕.

--

--