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!
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?
What are the issues with the following implementation of delete item on an unsorted linked list? You can assume self.head points to the node at the beginning of the list and each node has a link instance variable that refers to the next node in the list (or None if it's the last node).
def __delitem__(self, key) -> None:
if self.is_empty():
raise ValueError("Can't delete from an empty list")
previous = None
current = self.head
for _ in range(len(self)):
if current.item == key:
if current == self.head:
self.head = self.head.link
else:
current.link = previous.link
length -= 1
else:
previous = current
current = current.link
I have an array-based sorted list and I want to find a target element, where n is the number of elements in the list? Which algorithm should we use for this and what is the worst-case time complexity for the ideal algorithm?
I have a sorted list implemented using an array. I want to find a target element, which algorithm is the most efficient for this task?
What are the issues with the following implementation of delete item on an unsorted linked list? You can assume self.head points to the node at the beginning of the list and each node has a link instance variable that refers to the next node in the list (or None if it's the last node).
def __delitem__(self, key) -> None:
if self.is_empty():
raise ValueError("Can't delete from an empty list")
previous = None
current = self.head
for _ in range(len(self)):
if current.item == key:
if current == self.head:
self.head = self.head.link
else:
current = previous.link
length -= 1
else:
previous = current
current = current.link
I have an unsorted linked list and I am implementing an insert() method. Where would the item be inserted for the best-case complexity?
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!