DSA using Python Tutorials

0

Circular Linked List in DSA Python

Program 1 # Circular Linked list import os class Node: def __init__(self): self.data=None self.add=None class CircularLinkedList: def __init__(self): self.start=None self.count=0 def create(self): n=int(input(“Enter First element : “)) self.start=Node() self.start.data=n self.start.add=None temp=self.start self.count=self.count+1 choice=input(“Want to...

0

Stack using Collection in DSA Python

Program 1 #Implementation of stack using collections from collections import deque class MyStack: def __init__(self): self.stack=deque() def push(self,item): self.stack.append(item) print(“Pushed : “,item) def pop(self): if(len(self.stack)==0): print(“Stack is empty , can not pop element”) else:...

0

Stack using List in DSA Python

Program 1 # Stack Implementation using list stack=[] # Empty stack # push element in stack def push(): n=int(input(“Enter and element: “)) if(len(stack)==0): stack.append(n) else: stack.insert(0,n) # pop element in stack def pop(): if(len(stack)==0):...

0

Stack using Linked List in DSA Python

Program 1 # Stack Linked list import os class Node: def __init__(self): self.data=None self.add=None class StackLinkedList: def __init__(self): self.start=None self.count=0 def create(self): n=int(input(“Enter First element: “)) self.start=Node() self.start.data=n self.start.add=None self.temp=self.start self.count=self.count+1 ch=input(“Wan to continue(Y/y):...

0

Searching and Sorting Algorithms in DSA Python

Program 1 # Implementation of single linked list import os class Node: def __init__(self): self.data=None self.add=None class LinkedList: def __init__(self): self.start=None self.count=0 def create(self): n=int(input(“Enter First element: “)) self.start=Node() self.start.data=n self.start.add=None self.temp=self.start self.count=self.count+1 ch=input(“Wan...

0

Singly Linked List in DSA Python

Program 1 # Implementation of single linked list import os class Node: def __init__(self): self.data=None self.add=None class LinkedList: def __init__(self): self.start=None self.count=0 def create(self): n=int(input(“Enter First element: “)) self.start=Node() self.start.data=n self.start.add=None self.temp=self.start self.count=self.count+1 ch=input(“Wan...

0

Priority Queue in DSA Python

Program 1 # Implementation of Priority Queue using Module Min Heap import queue import os class MyPQueue: def __init__(self): self.pq=queue.PriorityQueue() def insert(self): n=int(input(“Enter an element: “)) self.pq.put(n) def delete(self): if(self.pq.empty()): print(“Priorty queue is empty”)...

0

Static Stack in DSA Python

Program 1 # Static implementation of Stack import os MAXSIZE=10 top=-1 mystack=[] def push(): global MAXSIZE global top if(top==MAXSIZE-1): print(“Stack is overflow”) else: n=int(input(“Enter an element for push: “)) top=top+1 mystack.insert(top,n) def pop(): global...