Looking for FIT1008-FIT2085 Fundamentals of algorithms - S1 2025 test answers and solutions? Browse our comprehensive collection of verified answers for FIT1008-FIT2085 Fundamentals of algorithms - S1 2025 at learning.monash.edu.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
If we were to compare the main operations of the Linked Stack and Linked Queue which one is more efficient in terms of time complexity of their operations?
I want to add a new method to the Linked Queue class to combine two queues of length n and m together in a new queue and return this new queue. The new queue should contain all elements of the first queue followed by all the elements of the second queue. Thus, the relative order of elements in the input queues and the result queue must be the same after this operation has been completed. What would be the worst-time complexity of this operation?
For example, if I had the following queues:
queue1: 1 -> 2 -> 3 -> 4 -> 5 [1 is the front of the queue]
queue2: 6 -> 7 -> 8 -> 9 -> 10 [6 is the front of the queue]
The resulting queue should be
queue3: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 [1 is the front of the queue]
Note: queue 1 and queue 2 should maintain their original items.
If I was to loop over this Iterator, how many times would it iterate?
class NumberIterator: def __init__(self): self.current = 1 def __iter__(self): return self def __next__(self): if self.current == 10: raise StopIteration() next_item = self.current self.current += 2 return next_item
What is TRUE about a Python Generator?
push() and pop(). We wish to implement the stack using linked nodes. What are the worst-case time complexities of these methods? We can assume n is referring to the number of elements currently in the stack.self with the elements of another queue other provided as an argument. This may be seen as an in-place queue merging. What would be the worst-case time complexity required to do this operation efficiently? You can assume that n is the length of self and m is the length of other.For example, if I had the following queues:self: 1 -> 2 -> 3 -> 4 -> 5 [1 is the front of the queue]
other: 6 -> 7 -> 8 -> 9 -> 10 [6 is the front of the queue]
The result should be:
self: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 9 -> 10 [1 is the front of the queue]
What is the worst-case time complexity of the following function assuming it is measured on value n rather than its logarithmic size?
from array_sorted_list import ArraySortedList
from sorted_list_adt import ListItem
def mystery(n: int) -> None:
my_list = ArraySortedList(n*10)
for i in range(n*10):
my_list.add(ListItem(n, i)) # assume ListItem(n, i) is O(1)
# ListItem(value, key) adds based on key
for i in range(n, n*10):
my_list.delete(ListItem(n, i))
I have a sorted linked list and I want to insert a single element (it does not matter which). Which element is the fastest to insert?
What is the worst-case time complexity of the following function assuming it is measured on value n rather than its logarithmic size?
from array_sorted_list import ArraySortedList
from sorted_list_adt import ListItem
def mystery(n: int) -> None:
my_list = ArraySortedList(10)
for i in range(10):
my_list.add(ListItem(n, i)) # assume ListItem(n, i) is O(1)
# ListItem(value, key) adds based on key
I have a sorted list implemented using linked nodes with n elements. I want to delete a target element. What is the worst-case time complexity of this?