설명은 JAVA 쪽에서 더 많이
class Node:
def __init__(self,data ,next=None):
self.data = data
self.next = next
class LinkedList:
def __init__(self,data):
self.head = Node(data)
def addData(self,data):
cur = self.head
while cur.next is not None:
cur = cur.next
cur.next = Node(data)
def ShowData(self):
cur = self.head
while cur is not None:
print(cur.data , end = " ")
cur = cur.next
def removeData(self,data):
cur = self.head
prev = cur
while cur.next is not None :
if cur.data == data:
if cur == self.head:
self.head = cur.next
else:
prev.next = cur.next
break
prev = cur
cur = cur.next'자료구조' 카테고리의 다른 글
| 자료구조 - 스택 , 큐 , 데크(Stack , Queue, Deque) Java (0) | 2023.02.15 |
|---|---|
| 자료구조 - 양방향 연결리스트 (DoublyLinkedList) python code (0) | 2023.02.13 |
| 자료구저 - 연결리스트 (Linked List ) JAVA (0) | 2023.02.13 |
| 자료구조 - 배열 JAVA / Python (0) | 2023.02.08 |