Skip to content

Commit df5a521

Browse files
committed
ds files
1 parent 0494d92 commit df5a521

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

Data Structures/stack.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#Oh! You're here? I was searching for you on Jupiter.
2+
3+
#Welcome to DS1O1 - Stack Abstract Data Type
4+
5+
class Stack:
6+
7+
def __init__(self):
8+
""" Yeah That Fancy Constructor which creates a new List/Stack everytime """
9+
10+
self.stack = []
11+
12+
def push(self, item):
13+
""" Push item onto stack """
14+
self.stack.append(item)
15+
16+
def pop(self):
17+
""" Pop item from stack """
18+
item = self.stack.pop()
19+
return item
20+
21+
def isEmpty(self):
22+
""" Check if stack is empty """
23+
return self.stack == []
24+
25+
def size(self):
26+
""" Return the size of stack """
27+
return len(self.stack)
28+
29+
def top(self):
30+
""" Return the topmost element of the stack """
31+
if(self.size()!=0):
32+
return self.stack[self.size() - 1]
33+
34+
35+
#Perform some operations
36+
37+
s = Stack()
38+
s.push(8)
39+
s.push(10)
40+
s.push(9)
41+
print(s.top())
42+
s.pop()
43+
print(s.top())
44+
s.pop()
45+
print(s.top())

algo/analysis.py

Whitespace-only changes.

classes/Point.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Point:
2+
3+
def __init__(self):
4+
self.x = 0
5+
self.y = 0
6+
7+
def getX(self):
8+
return self.x
9+
10+
def getY(self):
11+
return self.y
12+
13+
def __str__(self):
14+
return str(self.x) + ", " + str(self.y)
15+
16+
p = Point()
17+
q = Point()
18+
19+
print(p)

0 commit comments

Comments
 (0)