Still working through Colt Steele’s course on Algorithms and Data Structures while learning more algos and data structures from another perspective. This is a Udemy course is by Andrei Naegoi titled “Master the Coding Interview: Data Structures + Algorithms”.
I am enjoying Neagoi’s course so far. Currently on Section 3 of Big-O relearning and receiving Big-O’s Rules, Scalability, Big-O Cheat Sheet, just to name a few of the subsections. For instances:
- So, loops are linear time in algorithms when counting Big O. Another Udemy course to deepen my algorithm and data structures knowledge.
- Ways to exit out of a loop using “break”. Example of making our code more efficient.
- Big O(n) is linear time.
- Data Structures — are ways to store data.
- Algorithms — are ways to use data structures to write our programs.
- Programs — are instructions for our machines/computers.
- Good code should be both readable and scalable.
Breaking down this Big O case(s):
• Rule 1 Worst Case — consider what is the worst case. How many times would we need to run the loop to find what we want from the function’s argument’s input array? If the array’s element we want to find is placed first at the zero index or third or last then this really affects the loop runtime.
• Rule 2 Remove Constants — O(3n) is simplified to O(n).
• Rule 3 Different Terms For Inputs — can alter Big O inputs having to be either 0(a + b) or 0(a*b) aka different inputs should have different variables. Multiplication only happens for nested loops inside the function. When loops are not nested in each other inside the same function we will use the addition (“+”) approach.
• Rule 4 Drop Non-Dominants — 0(n+n²) we will only drop the non-dominants yielding this Big 0 as 0(n²) by receiving the ‘n’.
Another resource from freeCodeCamp that explains Big O Notation, is here.
Thank you for reading. Happy coding.