Staying Focused

Share this post

What are AlGoRitHms?

email.shivan.xyz

What are AlGoRitHms?

Shivan
Jul 31, 2021
Share this post

What are AlGoRitHms?

email.shivan.xyz

Kia ora e hoa,

Over the last few months, I've been working on writing an article about artificial intelligence and eye care.

To begin this journey is learning about this topic. We need to understand what are algorithms.

An algorithm is what computers use to solve problems, taking input and provide the desired output.

Here is an example. We have a list of names that we need to sort alphabetically. We could do this by hand, but let's leverage the power of computing to solve this problem for us instead. After all, a computer can perform tasks tirelessly and without error, if they are programming correctly of course.

Also, imagine if we had hundreds or thousands of patients, then the tasks becomes very long and tedious.

We can construct a simple algorithm to loop through the list of names and compare this to the name first on the list. If the name falls before the first-most name alphabetically, then this will take the top spot. We then repeat this for the entire list of names.

I've coded this example in C. Here it is below.

We have some interesting functions:

  • strcmp(string1, string2) - this compares strings and if the value is above 0, then string1 is 'greater' than string2. In other words, string1 goes after string2 in the alphabet.

  • strcpy(string1, string2) - when the above condition is met, this copies the value of string2 to string1. In our case, the later-in-the-alphabet name is copied to s. The name is replaced by the earlier-in-the-alphabet name. The name assigned to s then takes its place.

We can see that two for loops are implemented to make this happen. This means if the list of names increases by n, then the time for this algorithm to be executed will increase by a square factor, n^2. This means that this is not the most efficient algorithm, but it works and I'm happy with that.

We compile the code and then run it. We can see the output below.

My Favourite Things

  1. Course Getting started with Ansible by Jay Lacroix is a excellent series explaining Ansible. Ansible is an IT automation tool. I used to it set up my projects — which I will need to create a blog about sometime in the future.

  2. Article Glaucoma: take it or leaf it by myself. My first ever publication — I'm very happy with this and hoping for more to come.

  3. Course Practical Deep Learning for Coders by Jeremy Howard and company. I've been obsessed with artificial intelligence. A friend said I should bite the bullet and recommended me this course. The beautiful thing is that Howard and his team teaches 'top-down' approach. For example, when learning how to play Cricket. We don't learn the 100-year history or how a cricket ball is made. We learning by first watching and then immediately playing. Learning deep learning is not different. Follow my progress here: https://github.com/ShivanS93/fastbook

Kindle Highlight of the Week

People love to argue minor points, partially because they feel it absolves them from actually having to do anything.

Ramit Sethi, I Will Teach You to Be Rich

Share this post

What are AlGoRitHms?

email.shivan.xyz
Previous
Next
Comments
TopNewCommunity

No posts

Ready for more?

© 2023 Shivan Sivakumaran
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing