matheusfrancisco / pydsx

Implementation about data structure and algorithms in python
1 stars 0 forks source link

[TASK] Doubly linked list #1

Closed matheusfrancisco closed 9 months ago

matheusfrancisco commented 4 years ago

We need an doubly linked list:

Node[1] <---> Node[2] <---> Node[3] <---> Node[4]

To version 0.1.1

doubly_linked_list = DoublyLinkedList()

# Will append at the end of the list
doubly_linked_list.append(1)
doubly_linked_list.append(2)

for items in doubly_linked_list:
      ....items

# this will bee remove the last element from list
doubly_linked_list.pop() 

# We need using list like this
doubly_linked_list[1] = "new_value"
print(doubly_linked_list)
del doubly_linked_list[1]

Think of cyclomatic complexity when implementing these cases. Think about whether your implementation is taking O(n) or O(n log n) or O (n ^ 2). Try to implement faster for your case.