Hacks

  1. Why do you think a programmer should care about space and time complexity?
    • A programmer should care about space and time complexity because this is what creates and what is shown on your website and like for example, the bigger the image the more space it takes up.
  2. Do you think this is a time complexity or space complexity or both problem?
    • This is a time and spcae problem because the bigger the photo, the longer it will take to load / process. If it is too big then there is not space for photo. You increase the bandwidth to increase the time. Small photo loads very fast while larger photo takes longer.
    • Record your findings when testing the time elapsed of the different algorithms.
    • 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.

Selection Sort: Selection sort is another simple sorting algorithm that sorts an array by repeatedly finding the minimum element from unsorted part and putting it at the beginning.

Insertion Sort: Insertion sort is a simple sorting algorithm that builds the final sorted array one item at a time. It is much less efficient on large lists than other sorting algorithms such as quicksort, heapsort, or merge sort.

Big O notation: Big O notation is a mathematical notation that describes the upper bound of an algorithm’s time complexity in terms of the input size. It provides a way to express the algorithm’s growth rate and allows for easy comparison of different algorithms. For example, an algorithm with O(n) time complexity means that its runtime grows linearly with the input size.

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