Esempio n. 1
0
def analyseCountFunctionOfSinglyLinkedList(iterable, word):
    _sum = 0
    singlyLinkedListHistogram = singly_linked_list.LinkedList(iterable)
    for i in range(100):
        _sum += singlyLinkedListHistogram.find(lambda node: node[0] == word)
    avg = _sum / 100
    return avg
Esempio n. 2
0
def analyseGenerationOfSinglyLinkedList(iterable):
    start_time = time.time()
    _sum = 0
    for i in range(100):
        histogram = singly_linked_list.LinkedList(iterable)
        _sum += time.time() - start_time
    avg = _sum / 100
    return avg
Esempio n. 3
0
def setup_function(function):
    global llist
    llist = singly_linked_list.LinkedList()
Esempio n. 4
0
 def __init__(self):
     self.size = 0
     self.storage = singly_linked_list.LinkedList()
Esempio n. 5
0
return elements in First In First Out order.

1. Implement the Queue class using an array as the underlying storage structure.
   Make sure the Queue tests pass.
2. Re-implement the Queue class, this time using the linked list implementation
   as the underlying storage structure.
   Make sure the Queue tests pass.
3. What is the difference between using an array vs. a linked list when
   implementing a Queue?

Stretch: What if you could only use instances of your Stack class to implement the Queue?
         What would that look like? How many Stacks would you need? Try it!
"""
import singly_linked_list

myList = singly_linked_list.LinkedList()
myList.headval = singly_linked_list.Node("Apple")

node2 = singly_linked_list.Node("Banana")
node3 = singly_linked_list.Node("Carrot")
node4 = singly_linked_list.Node("Durian")


class Queue:
    def __init__(self):
        self.size = 0
        self.storage = []

    def __len__(self):
        print(self.size)
Esempio n. 6
0
def init_linked_list():
    # Helper method to return an initialised linked list
    return singly_linked_list.LinkedList(20)
Esempio n. 7
0
 def __init__(self):
     self.list = singly_linked_list.LinkedList()
Esempio n. 8
0
 def __init__(self):
     self.members = ll.LinkedList()