What is the syntax for creating a new dictionary?
newdict = dict()
or
newdict = {}
Which of the following acronyms best describes a stack?
FIFO FOFI LIFO LOFI
Last in, first out
LIFO
Name one benefit of making your own dataclass versus a pre-existing dataclass.
There is more flexibility because you choose what data it can hold
Insertion Sort
O(N^2)
What is Ren's favorite crime?
Arson
True or False:
“A set does not preserve order”
True
Which of the following acronyms best describes a queue?
FOFI LIFO FAFI LOFI FIFO
First in, first out
FIFO
Change Garfield's age to 7
@dataclass
class Cat :
str : name
int : age
my_cat = Cat( "Garfield", 6 )
my_cat.age = 7
Finding the value of a key in a dictionary.
O(1)
What email sendoff does Ren use most often?
"Cheers,"
or
"Have a great day, and I hope to see you there! :-)"
True or False:
“Python dictionaries cannot have duplicate values”
False
Draw a box-and-pointer diagram representing this stack:
my_stack = make_empty_stack()
push(my_stack, 5)
push(my_stack, 7)
push(my_stack, 1)
push(my_stack, 8)
pop(my_stack)
What are the two attributes (and their types) of a basic linked list?
Head: MutableNode //or LinkedNode
size: int
Searching for a value in a sorted list using binary search.
O(log(N))
What does "SI" stand for?
Supplemental Instruction
What is the time complexity of indexing the value of a given key?
O(1)
Using the given CS functions write a function that removes all elements from the stack and prints the values in the stack.
def empty(my_stack):
while not is_empty(my_stack):
print(pop(my_stack))
Make a class named Person, whose attributes are name and age. Then create Ren :-)
@dataclass
class Person:
str : name
int : age
ren = Person(“Ren”, 22)
Remove an element from an linked list.
O(N)
What activity consistently takes more time than planned during sessions?
Basic Overview
Write a function that loops through a given dictionary’s keys to print the values.
def looper(d):
for key in d:*
print(d[key])
*could also be "for key in d.keys:"
Using the queue dataclass we covered in class, write a line of code to create an empty queue without using the make_empty_queue function.
my_queue = Queue( None, None, 0 )
@dataclass
class Hat:
str: color
@dataclass
class Kid :
str : name
int : age
Hat : hat
Create a kid named Ash, 10 years old, with a red hat.
new_kid = Kid( “Ash”, 10, Hat (“red”))
I just wany y'all to know that I didn't even make this Jeopardy, just edited it some, and yet there's a Pokémon reference in here. Amazing.
Using this algorithm to find an element in a list:
Use quick sort on an unsorted list and then perform binary search
O(Nlog(N))
What flower was centric to the Week 6 (Exam 1) session slides?
BONUS: What was the meaning of this flower?
Sweetbay magnolia AKA Swamp magnolia
Perseverance