I have been using “Selection Sort” for so long while not knowing it’s called “Selection Sort”. The reason is, it naturally made sense to me. Now I realize how garbage it is in terms of speed. Wow! I have seen the light. I’m telling you, algorithms suck sometimes but they are also kind of amazing. I am excited to focus more on them and find real world differences like this to solidify their importance in my mind.
TLDR;
Okay, so here are the highlights of what I did:
- Data structures -> I finished going through the freeCodeCamp YouTube video covering data structures and algorithms for beginners. The last few sections covered writing a “Merge Sort” algorithm with a linked list, the “Selection Sort” algorithm, and the “Quick Sort” algorithm. It was really cool comparing the different sorting algorithms using the Linux
time
program. I am glad I finally got introduced to these 3 algorithms. They are not as scary as they seemed. - Practice -> Started looking at the next project (Etch-a-Sketch) in “The Odin Project” curriculum. This should be fun! Getting these reps in. The only way for me to get better is by putting in the work and reflecting on my mistakes.
Notes on the time
linux program
time
is a program that will return the amount of time it takes to run any process that is passed in as an argument. For example:
# "time" is called to measure how long it takes to run "cat" on the "numbers/5.txt" file
time cat numbers/5.txt
Outputs:
8
5
1
4
7
real 0m0.011s
user 0m0.001s
sys 0m0.002s
real
= The actual amount of time it took for thecat
program to run on thenumbers/5.txt
file. Other programs can take up CPU resources which can slow down our program so we generally ignore thereal
times given.user
= The user result is the amount of time that the CPU actually spent running the program code. So this is the total amount of time thecat
program took.sys
= The amount of time the CPU spent running kernel calls. i.e. network communications, reading files, etc.
In evaluating a program’s performance we are usually going to add together the user
and sys
times.
Here is another example with a program that takes more time to run:
time python selection_sort.py numbers/10000.txt
Outputs:
1, 2, 3, 4, .... A bunch of numbers sorted in ascending order.
real 0m11.960s
user 0m5.864s
sys 0m0.005s
Goal For Round 7 of the #100DaysofCode Challenge
This is my seventh round of the “#100daysofcode” challenge. I will be continuing my work from round five and round six into round seven. I am currently working through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. My goal is to become more familiar with algorithms and data structures. This goal was derived from my goal to better understand operating systems and key programs that I use in the terminal regularly e.g. Git. This goal was in turn derived from my desire to better understand the fundamental tools used for coding outside of popular GUIs. This in turn was derived from my desire to be a better back-end developer.
I have no idea if my path is correct but I am walking down this road anyways. Worst case scenario I learn a whole bunch of stuff that will help me out on my own personal projects.