Hacks

  • Record your findings when testing the time elapsed of the different algorithms.: Each of the algorithms took a different amount of time to test. Some of these algorithms would’ve broken my computer if not stopped.
  • Although we will go more in depth later, time complexity is a key concept that relates to the different sorting algorithms. Do some basic research on the different types of sorting algorithms and their time complexity.: There are many different types of sorting algorithms, and each of them is more efficient than the other. Some types of sorting algorithms include the insertion sort, bubble sort, selection sort, merge sort, heapsort, and quicksort algorithm. Out of these 6, the 3 most efficient sorts are the merge sort, heapsort, and quicksort algorithms.
  • Why is time and space complexity important when choosing an algorithm?: Time complexity is important when choosing an algorithm, as you want an algorithm that can be easily run without taking too much time to give you an output. Space complexity is also important, as you need an algorithm that can cover large amounts of data.
  • Should you always use a constant time algorithm / Should you never use an exponential time algorithm? Explain? : Constant time algorithms can be good most of the time, but they shouldn’t always be used, as there could be algorithms which could take an even shorter amount of time. I would almost never use an exponential time algorithm, as they are almost always incredibly inefficient. For 512 inputs, a linear algorithm could take 512 seconds, while an exponential algorithm could take 1.34 x 10^154 seconds.
  • What are some general patterns that you noticed to determine each algorithm’s time and space complexity?: Time complexity is essentially determined by how long an algorithm takes as a function of the number of inputs for the algorithm. Space complexity is determined using f(N), where N is the size of the input data.

Complete the Time and Space Complexity analysis questions linked below. Practice

DONE