Guest User

Untitled

a guest
Sep 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. 1. What is time complexity and what is its relation to algorithms?
  2.  
  3. A: Time Complexity is the amount of time it takes to compute an algorithm. It assumes each function has a fixed timeframe to complete and calculates the maximum runtime.
  4.  
  5. 2. What is runtime?
  6.  
  7. A: Runtime can be the physical time duration of an algorithm or the time complexity.
  8.  
  9. 3. How is the runtime of an algorithm calculated?
  10.  
  11. A: Runtime is calculated by adding the functions that will be run in the algorithm, simplifying the expression to the largest term and then dropping the constants.
  12.  
  13. 4. Name the six types of algorithm growth rates we saw in this checkpoint and list them in order of most efficient to least efficient. Now Google another algorithmic growth rate not covered and place it in the correct spot in your list.
  14.  
  15. A: constant, linear, logarithmic, log linear, quadratic, exponential, polynomial
  16.  
  17. 5. Choose one of the algorithmic growth rates from the last question and make a comparison to a real-life situation.
  18.  
  19. A: An example of log linear growth rate would be looking at an alphabetical list of names to find one name. You would take the list, cut in half, if the name you want is in the first half alphabetically, discarded second half and half the first half and repeat the process until you find the name.
  20.  
  21. 6. Determine the time complexity of the following snippet of code. It is commonly known as a linear search.
  22. A: O(n)
  23.  
  24. 7.Determine the time complexity of the following snippet of code. It is commonly known as the Fibonacci sequence.
  25. A: O(2^n)
  26.  
  27. 8. Out of the code snippets you just saw, which is the most time efficient?
  28. A: Linear. The growth rate is constant. the fibonacci sequence increases exponentially with the input size.
Add Comment
Please, Sign In to add comment