Skip to content
Snippets Groups Projects
Select Git revision
  • 4c6746f44df030832ae4a91c43e4ef945b7d9ad0
  • master default protected
2 results

INF-TC1-td06.ipynb

Blame
  • Forked from Vuillemot Romain / INF-TC1
    Source project has a limited visibility.
    liste-liee.py 811 B
    class Node:
        def __init__(self, data = None, next = None):
            self.data = data
            self.next = next
    
    class LinkedList:
        def __init__(self):
            self.head = None
    
        def listprint(self):
            printval = self.head
            while printval is not None:
                print(printval.dataval)
                printval = printval.nextval
        
        def push(self, n):
            if self.head is None:
                self.head = Node(n)
            else:
                node = self.head
                while node.next is not None:
                    node = node.next
                node.next = Node(n)
    
        def detectLoop(self):
            s = set() 
            temp = self.head 
            while (temp):
                if (temp in s): 
                    return True
                s.add(temp) 
                temp = temp.next
            return False