What are state and behavior of a class?
Attributes and methods
What do FIFO and LIFO stand for?
First In First Out
Last In First Out
What's the difference between a destructive and non-destructive sort?
Destructive modifies in place; non-destructive makes a copy and returns that sorted
What time complexity are most set and dictionary functions?
O(1)
Name your best study strategy
Example: Getting enough sleep the night before
What is instantiation and how do you do it?
Call its constructor to create an instance
What is a recursive data structure?
A data structure that has at least one field of its own type (e.g. a node sequence)
When should you use insertion sort?
For small or mostly sorted datasets
What makes tuples unique?
Immutable, fixed-length, uses parentheses
Why do we use the with command when opening a file?
It automatically closes
What are some common kinds of methods?
Mutators, Accessors, special methods
How do you add/remove from a stack, and which node in the stack do they effect?
push() and pop(), which both effect the top element
What is the time complexity of merge sort for each of its cases?
O(nlog2n) in all cases
What is the difference between a reference and value type?
Value types directly store the data value. Reference types store a reference to the data location.
What is the difference between a linear search and binary search?
Linear search searches element by element regardless of order, binary search requires an ordered list and checks if each element is > or < the target
What is the difference between __str__ and __repr__?
__repr__ is usually more detailed and used for debugging, whereas __str__ is usually shorter and is what print() uses
How do you add/remove from a queue, and which node in the queue do they effect?
enqueue() and dequeue(); the first effects the end while the second effects the front
What are the steps to quick sort?
1. Select a pivot element
2. Partition the list into elements less than, equal to, and greater than the pivot
3. Recursively sort the less and greater partitions
Give an example of a list comprehension statement with a conditional
x for x in numbers if x % 2 == 0
What is a recursive function composed of?
A base case (condition to stop) and a recursive case (calling itself)
Besides __str__ and __repr__, describe three other special methods
__hash__, __eq__, __lt__
How do you implement a circular queue?
Using a fixed array, where both the front and end have pointers
For insertion sort, what are the best, average, and worst case scenarios and their time complexities?
Best: O(n) : Sorted data set
Average: O(n2) : Randomly sorted data set
Worst: O(n2) : Reverse sorted data set
Using slicing, how can you print only 'ia' in the string 'final'?
print(final[1:4:2])
Describe at least 3 types of errors
E.g.: TypeError, AttributeError, IndentationError, NameError, FileNotFoundError