Example #1
0
def test_insertbefore_first_node():
    anime = LinkedList()
    anime.append("Slam dunk")
    anime.append("death note")
    anime.insertBefore("Slam dunk", "one puch man")
    assert anime.__str__(
    ) == '(one puch man) -> (Slam dunk) -> (death note) -> NULL'
Example #2
0
def test_insertAfter_lastnode():
    anime = LinkedList()
    anime.append("Slam dunk")
    anime.append("death note")
    anime.insertAfter("death note", "one puch man")
    assert anime.__str__(
    ) == '(Slam dunk) -> (death note) -> (one puch man) -> NULL'
Example #3
0
def test_kth_from_end_greater_than_length():
    anime = LinkedList()
    anime.append(1)
    anime.append(3)
    anime.append(8)
    anime.append(2)
    assert anime.kthFromEnd(5) == 'The Value Not Found'
Example #4
0
def test_kth_from_end1_Happy_Path():
    anime = LinkedList()
    anime.append(1)
    anime.append(3)
    anime.append(8)
    anime.append(2)
    assert anime.kthFromEnd(3) == 1
    assert anime.kthFromEnd(1) == 8
Example #5
0
def prepare_data():
    anime = LinkedList()
    node1 = anime.append("BLEACH")
    node2 = anime.append("God of high school")
    node3 = anime.append("Deat note")
    test1 = anime.includes("BLEACH")
    test2 = anime.includes("Conan")
    return {
        'anime': anime,
        "node1": node1,
        "node2": node2,
        "node3": node3,
        "test1": test1,
        "test2": test2
    }
Example #6
0
def test_kth_from_end_size1():
    anime = LinkedList()
    anime.append(3)
    assert anime.kthFromEnd(0) == 3
Example #7
0
        temp = first
        first = second
        second = temp
        current_fll = first.head
        current_sll = second.head
    linked_first = first.head
    linked_second = second.head
    while linked_first and linked_second:
        first_next = linked_first.next_node
        second_next = linked_second.next_node
        linked_second.next_node = first_next
        linked_first.next_node = linked_second
        linked_first = first_next
        linked_second = second_next
        second.head = linked_second
    return first


myList = LinkedList()
myList.insert(5)
myList.insert(8)
myList.insert(12)
myList.append(3)

list = LinkedList()
myList.insert(1)
myList.insert(5)
myList.insert(88)
myList.append(4)

print(zipLists(myList, list))