Berikut adalah video proses membuat program sederhanaclass Node: def __init__(self, data): self.data = data self.next = None class CircularLinkedList: def __init__(self): self.head = None def prepend(self, data): new_node = Node(data) cur = self.head new_node.next = self.head if not self.head: new_node.next = new_node else: while cur.next != self.head: cur = cur.next cur.next = new_node self.head = new_node def append(self,data): if not self.head: self.head = Node(data) self.head.next = self.head else: new_node = Node(data) cur = self.head while cur.next != self.head: cur = cur.next cur.next = new_node new_node.next = self.head def print_list(self): cur = self.head while cur: print(cur.data) cur = cur.next if cur == self.head: break list= CircularLinkedList() list.append("A") list.append("B") list.prepend("D") list.prepend("F") list.print_list()
Berikut adalah salah satu contoh baris program sederhana
Berikut adalah video proses membuat program sederhanaclass Node: def __init__(self, data): self.data = data self.next = None class CircularLinkedList: def __init__(self): self.head = None def prepend(self, data): new_node = Node(data) cur = self.head new_node.next = self.head if not self.head: new_node.next = new_node else: while cur.next != self.head: cur = cur.next cur.next = new_node self.head = new_node def append(self,data): if not self.head: self.head = Node(data) self.head.next = self.head else: new_node = Node(data) cur = self.head while cur.next != self.head: cur = cur.next cur.next = new_node new_node.next = self.head def print_list(self): cur = self.head while cur: print(cur.data) cur = cur.next if cur == self.head: break list= CircularLinkedList() list.append("A") list.append("B") list.prepend("D") list.prepend("F") list.print_list()
Program Sederhana Membuat Aplikasi Circular Linked List pada Bahasa Python
Berikut adalah salah satu contoh baris program sederhana
No comments