Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발 블로그

[자료구조] 연결리스트 이용한 스택 ADT 구현 본문

자료구조

[자료구조] 연결리스트 이용한 스택 ADT 구현

토산인 2022. 9. 18. 21:44
class Node :
	def __init__(self, item, next) :
    	self.item=item
        self.next=next
        
class Stack :
	def __init__(self) :
    	self.last=None
        
	def push(self, item) :
    	self.last=Node(item, self.last)
        
	def pop() :
    	item=self.last.item
        self.last=self.last.next
        return item

item : node의 값, next : 다음 node를 가리키는 포인터

 

'자료구조' 카테고리의 다른 글

[자료구조] 자료구조란?  (0) 2022.09.18