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 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:
current = previous.link
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 worst-case complexity?
Schlagen Sie ein alternatives Bild für diesen Kurs vor . Benötigt wird ein schmales Querformat. Das Bild sollte die Kursthemen passend veranschaulichen (bitte mit ein paar Sätzen begründen). Es kann selbst erstellt sein oder aus einer Bilddatenbank stammen (Voraussetzung: es steht nachweislich unter einer offenen Lizenz bzw. Sie müssen es bei einem selbst erstellten Bild unter einer offenen Lizenz – z.B. CC-BY – zur Verfügung stellen).
Für den Vorschlag eines passenden Bildes erhalten Sie einen Zusatzpunkt. Wird Ihr Bild ausgewählt, erhalten Sie zwei weitere Punkte.
Abgabe ab 25.3. bis 31.3., 23h.
----------
Suggest an alternative image for this course . A narrow landscape format is required. The image should illustrate the course topics (please justify in a few sentences). It can be self-created or taken from an image database (prerequisite: it must be under an open license or, in the case of a self-created image, you must provide it under an open license - e.g. CC-BY).You will receive one bonus point for suggesting a suitable image. If your image is selected, you will receive two additional points.Submission from 25.3. until 31.3., 23h.
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)
for i in range(n):
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. I want to find a target element, which algorithm can I effectively use?
Що означає "осмислення організації та її контексту"?