Objects
Stacks & Queues
Sorting
Data types
Misc
100

What are state and behavior of a class? 

Attributes and methods 

100

What do FIFO and LIFO stand for? 

First In First Out 

Last In First Out

100

What's the difference between a destructive and non-destructive sort? 

Destructive modifies in place; non-destructive makes a copy and returns that sorted

100

What time complexity are most set and dictionary functions? 

O(1) 

100

Name your best study strategy 

Example: Getting enough sleep the night before 


200

What is instantiation and how do you do it? 

Call its constructor to create an instance

200

What is a recursive data structure? 

A data structure that has at least one field of its own type (e.g. a node sequence) 

200

When should you use insertion sort? 

For small or mostly sorted datasets 

200

What makes tuples unique?

Immutable, fixed-length, uses parentheses

200

Why do we use the with command when opening a file? 

It automatically closes 

300

What are some common kinds of methods? 

Mutators, Accessors, special methods 

300

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 

300

What is the time complexity of merge sort for each of its cases? 

O(nlog2n) in all cases

300

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.

300

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

400

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

400

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 

400

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

400

Give an example of a list comprehension statement with a conditional 

x for x in numbers if x % 2 == 0

400

What is a recursive function composed of? 

A base case (condition to stop) and a recursive case (calling itself) 

500

Besides __str__ and __repr__, describe three other special methods 

__hash__, __eq__, __lt__

500

How do you implement a circular queue?

Using a fixed array, where both the front and end have pointers 

500

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


500

Using slicing, how can you print only 'ia' in the string 'final'?

print(final[1:4:2])

500

Describe at least 3 types of errors 

E.g.: TypeError, AttributeError, IndentationError, NameError, FileNotFoundError  

M
e
n
u