ALGORITHMS I 2026 CERTIFICATION TEST
QUESTIONS AND ANSWERS UPDATED
◉ Priority queue. Answer: A queue where each item has a priority,
and items with higher priority are closer to the front of the queue
than items with lower priority. Dups ok
Underlying data structures: Heap
*In addition to push and pop, a priority queue usually supports
peeking and length querying. A peek operation returns the highest
priority item, without removing the item from the front of the queue.
Pop returns front or head item which is top priority item
◉ Dictionary (Map). Answer: A dictionary is an ADT that associates
(or maps) keys with values.
Underlying data structures: Binary search tree, Hash table
◉ Dictionary key characteristic. Answer: They are unique and
immutable.
,◉ Dictionary method. Answer: D1[key].remove(value)
◉ dict.items(). Answer: returns a view object that yields (key, value)
tuples.
◉ dict.keys(). Answer: returns a view object that yields dictionary
keys.
◉ dict.values(). Answer: returns a view object that yields dictionary
values.
◉ Dict for loop. Answer: A for loop over a dict retrieves each key in
the dict.
ie.. for key in dictionary:
◉ dict operations. Answer: my_dict[key]
Indexing operation - retrieves the value associated with key.
john_grade = my_dict['John']
my_dict[key] = value
Adds an entry if the entry does not exist, else modifies the existing
entry.
my_dict['John'] = 'B+'
, del my_dict[key]
Deletes the key entry from a dict.
del my_dict['John']
key in my_dict
Tests for existence of key in my_dict
if 'John' in my_dict: # ...
◉ dict methods. Answer: my_dict.clear()
Removes all items from the dictionary
my_dict = {'Bob': 1, 'Jane': 42}
my_dict.clear()
print(my_dict)
{}
my_dict.get(key, default)
Reads the value of the key entry from the dict. If the key does not
exist in the dict, then returns default.
my_dict = {'Bob': 1, 'Jane': 42}
print(my_dict.get('Jane', 'N/A'))
print(my_dict.get('Chad', 'N/A'))