DSA using Python Tutorials
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...
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:...
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):...
Program 1 # Project Title: City Map Navigation using Graphs # Objective: # To build a simple navigation system that finds the shortest path between a source city # and all other cities using...
Program 1 # Friend Recommendation System in Social Media using graphs # System that recommends new friends to users in a # social network by analyzing their mutual friends # Features # 1. Add...
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):...
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...
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...
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”)...
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...