Skip to content

Instantly share code, notes, and snippets.

@ozgurkaracam
Created January 6, 2016 20:58
Show Gist options
  • Save ozgurkaracam/ffb7befd123f8801807f to your computer and use it in GitHub Desktop.
Save ozgurkaracam/ffb7befd123f8801807f to your computer and use it in GitHub Desktop.
aynı yığıt kontrolü özyineli
class Stack:
def __init__(self):
self.alist=[]
def pop(self):
return self.alist.pop()
def push(self,a):
self.alist.append(a)
def show(self):
return self.alist
def peek(self):
return self.alist[len(self.alist)-1]
def isempty(self):
return len(self.alist)==0
def size(self):
return len(self.alist)
def yigitaynimi(a,b):
if a.isempty and b.isempty():
return True
else:
if a.isempty() or b.isempty():
return False
else:
if a.pop()!=b.pop():
return False
else:
return yigitaynimi(a,b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment