Posts

Complexity Classes and their Graphs: BEHIND THE SCENES!

Image
Welcome Hi! Welcome to this section on  Complexity Classes and their Graphs . First of all,  congratulations on these weeks of hard work!!  : ) You’ve done a fantastic job and we’re so glad you’ve come this far. You learned in lecture that algorithms have different running times and how the orders of growth tell you how efficient an algorithm is, given very large inputs. The order of growth is an approximation, an upper bound on how much an algorithm could take to run, the worst-case scenario. We will first have a quick introduction to 2-D graphs and then we’ll discuss and illustrate the logic behind each complexity you’ve learned (constant, logarithmic, linear, loglinear, polynomial and exponential). The Graph The complexity classes are represented with  a graph . Graphs have two axes: The  X-axis , a horizontal line (represented below with an orange line). The  Y-axis , a vertical line (represented below with a green line). E...

How to use Functions returned by Functions: BEHIND THE SCENES!

Image
Welcome! : ) Hi! We will discuss an amazing tool, H ow to use Functions returned by Functions.  Let's get started! Code: This is the code we will be working with. We have an  add(x, y)  function and a  multiply(x, y)  function that perform their corresponding operation on their parameters and return the result. The function where the magic starts is  determineAddOrMultiply(a) . This function takes in an argument and if that argument is greater than 5 it returns the  FUNCTION   add . Else, if the argument is equal to or less than 5 it returns the  FUNCTION   multiply . Note:  I’m emphasizing that we are returning  Functions  because, as you can see in the diagram above, we are not using parentheses after the name of the function and therefore we are not calling the function. By using this syntax we are referring to the function itself, a reference to the entire structure that the function represents....

Iterating over the characters in a string: BEHIND THE SCENES!

Image
Welcome! Hi! Welcome to this short tutorial! We will discuss how to iterate over the character in a string, a very important concept for the course and you Computer Science journey. Syntax On the diagram below you can see the  general syntax  for iterating over the  items contained in an iterable  (strings are iterables and their “items” are the individual characters they contain) Ready? Set! Go! Once we start out for loop, the variable we’ve defined to be used in the for loop (in this case,  char ) will be updated on each iteration (see code in the "output" column on the diagram below). What does this mean? When the loop is run first time,  char ’s value will be  H . When the loop runs for the second time,  char ’s value will be  e And so on! The loop will run  as many times as the number of characters in the string  and the variable  char  will update its value wherever you’ve used it inside...

How to read Python's Documentation: BEHIND THE SCENES!

Image
Welcome! Hi! Welcome to this section where we will dive into a “tool” that you will use and learn to love throughout your Computer Science journey and/or career. Let’s say you’ve found the Build-in Python function  round()  and you would to know more about how it works. What do you do? You go to  PYTHON'S DOCUMENTATION! Concept: First of all, let’s start by describing what is Documentation: Importance and First Impressions As you can see, it is extremely important since it tells you how a software (or in this case, a programming language) can be used. At first it may seem daunting and you will find a lot of technical terminology you maybe haven’t heard of next to the information you actually need, but don’t worry, through experience you will learn to determine what is relevant to your needs and what isn’t. Trust me, I’ve been through this and at first I felt like documentation was very intimidating but with practice I learned to love it ...