Welcome to pyDS’s documentation!¶
Intro¶
pyDS is a python module consisting of various data structure and algorithm implementations.
Usage:
from pyDS.stack import Stack
from pyDS.usecase.stack import bracketBalanced, decimalBaseConvert
stack = Stack()
stack.push(2)
stack.push(5)
print(stack)
# 2 5
print(stack.peek())
# 5
print(stack.pop())
# 5
print(stack.peek())
# 2
pyDS¶
pyDS package¶
Subpackages¶
pyDS.usecase package¶
Submodules¶
pyDS.usecase.stack module¶
-
pyDS.usecase.stack.
bracketBalanced
(expression)[source]¶ Check if an expression is balanced.
An expression is balanced if all the opening brackets(i.e. ‘(, {, [‘) have a corresponding closing bracket(i.e. ‘), }, ]’).
- Args:
- expression (str) : The expression to be checked.
- Returns:
- bool: True if expression is balanced. False if not balanced.
-
pyDS.usecase.stack.
decimalBaseConvert
(number, base=2)[source]¶ Convert decimal numbers.
Convert the base of a decimal number to another base.
- Args:
number (int): The number to be converted. base (int, optional): The base to convert the number to.
Defaults to 2. Minimum value 2. Maximum value 16.- Returns:
- str: The string representation of the converted number.
Module contents¶
Submodules¶
pyDS.linked_list module¶
pyDS.queue module¶
-
class
pyDS.queue.
Queue
[source]¶ Bases:
object
An implementation of the Queue data strucutre.
-
dequeue
()[source]¶ Remove item from queue.
- Returns:
- The first item from the Queue. Raises IndexError if Queue empty.
-