Grokking Algorithms Flashcards
what is an algorithm?
it’s a set of instructions that accomplish a specific task,
any piece of code is an algorithm.
what do we use for searching?
binary search
what does a binary search need?
it needs a sorted list as it’s input
what is the big o of linear time (exhaustive search)
O(n)
what is the big O of binary search?
O(Log(n))
what does big O notation do?
it gives an indication of how fast an algorithm is running
why do we calculate big O notation?
because algorithms grow at different rates
what does big O notation calculate?
number of operations
what scenario does big O notations give?
worst-case scenario
what is big O for reading an array vs linked list?
array : O(1)
list : O(n)
what is big O for insertion an array vs linked list?
array : O(n)
list : O(1)
what is big O for deletion an array vs linked list?
array : O(n)
list : O(1)
what are the types of accessing elements in memory?
1 - random access
2 - sequential access
what does random access mean and who do we use it with?
we use it with an array and it means i can go to an exact index in memory
what does sequential access mean and who do we use it with?
we use it with linked lists and arrays, and it means that we have to go through the list reach time to reach a specific element or index