Please Create Method Bfs Start Dfs Start Python Starter Code Found Please Edit Starter Co Q37254644

Goal: In Module 6, we discussed the Graph data structure. Since the graph is a non-linear structure, there is no unique trave

Please create method bfs(start) and dfs(start) in PYTHON.

The starter code can be found below. Please do not edit thestarter code at all.

class Node:
def __init__(self, value):
self.value = value
self.next = None
  
def __str__(self):
return “Node({})”.format(self.value)

__repr__ = __str__
  

class Stack:

def __init__(self):
self.top = None
self.count = 0
  
def __str__(self):
temp=self.top
out=[]
while temp:
out.append(str(temp.value))
temp=temp.next
out=’n’.join(out)
return (‘Top:{}nStack:n{}’.format(self.top,out))

__repr__=__str__
  
def isEmpty(self):
#write your code here
if self.top == None:
return True
else:
return False
def __len__(self):
#write your code here
self.count = 0
tempNode = self.top
while tempNode:
tempNode = tempNode.next
self.count+=1
return self.count

def peek(self):
#write your code here
return self.top.value

def push(self,value):
#write your code here
if self.top is None:
self.top

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.