Week 5 Test Flashcards
(32 cards)
what is complexity analysis?
reading code and determining the rate of growth through analysis instead of manually testing the code
what is big o notation used for
to express complexity analysis
what is Big o’s main concern
the general shape of the growth curve when a function is passed in a large value
why is big O not concerned with small values?
computers are so fast that even inefficient code returns almost immediately for a small number
what is the correlation between code beginning to behaving slowly and the steep of efficiency curve
the steeper the code, the faster the performance will degrade
what does it mean for a function to have constant growth
the runtime remains constant whether the input os large or small
what does space complexity describe?
how much memory the function requires
what are the space and time complexities of arr.push
time: 1*
space: 1*
requires no shifting and happens in place
what are the space and time complexities of arr.pop
Time: 1
space: 1
requires no shifting and happens in place
what are the space and time complexities of arr.shift
time: n
space: 1
requires all elements shift to the left by one, but happens in place
what are the space and time complexities of arr.unshift
time: n
space: 1
requires all elements shift to the right by one, but happens in place
what are the space and time complexities of arr.splice
time: n
space: n*
requires shifting to fill empty spaces and returns an array possibly of unknown length
what are the space and time complexities of slice
time: n
space: n
ceates a copy of the old array with some of all elements slice out; the values sliced have to be copied individually
what are the space and time complexities of arr.indexOf
time: n
space: 1
this will search and visit each node and the worst case is that the elemt is at the end of the array or not present at all, no space required
what are the space and time complexities of arr.map
time: n
space: n
creates a new array with some function applied to each element this is with the assumption that the cb is O(1)
what are the space and time complexities of arr.filter
time: n
space: n
iterates over each element and adds values to a new array based on booleans
what are the space and time complexities of arr.reduce
time: n
space: 1
iterates over each element and applies a reducer function. assumes reducer is O(1); no additional space required
what are the space and time complexities of arr.reverse
time: n
space: 1
moves all n elements in place
what are the space and time complexities of spread
time: n
space: n
copy each element into a new array without altering the original
what is XOR and what is its symbol
the symbol is ^; XOR means the exclusive or, so one or the other, but not both
what does the base refer to in a counting system?
how many digits there are in the system
what is the relationship between bits and bytes
bits is short for binary digits which refers to each individual digit in a binary code
a group of 8 bits is a byte
what is ASCII
the american standatrd code or information interchange
a standard for changing bits into characters
how to go from base 10 to base 2 or base 16
variableHoldingNumber.toString(baseNumberOfTypeGoingTo)