PLEASE COMPLETE THIS PYTHON PROGRAM BY FILLING OUT FOLLOWING BLANKS AND ALSO ATTACH class Node(object): # Singly linked node def __init__(self, data=None, next=None, prev=None): self.data = _____ self.next = _____ self.prev = _______ class doubly_linked_list(object): def __init__(self): self.head =______ _________= None self.count = 0 def append_item(self, data): # Append an item new_item = Node(data, None, None) if _______________: self.head = new_item self.tail = self.head else: new_item.prev = self.tail self.tail.next = _______ self.tail = new_item self.count += 1 def iter(self): # Iterate the list current = ________ while current: item_val = current.data current = current.next yield item_val def print_foward(self): for node in self._____(): print(node) def search_item(self, val): for node in self.iter(): if val == node: return True return False items = doubly_linked_list() items.append_item('PHP') items.append_item('Python') items.append_item('C#') items.append_item('C++') items.append_item('Java') items.append_item('SQL') print("Original list:") items.print_foward() print("\n") if items.search_item('SQL'): print("True") else: print("False") if items._________('C+'): print("True") else: print("False")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

PLEASE COMPLETE THIS PYTHON PROGRAM BY FILLING OUT FOLLOWING BLANKS AND ALSO ATTACH

 

class Node(object):

    # Singly linked node

    def __init__(self, data=None, next=None, prev=None):

        self.data = _____

        self.next = _____

        self.prev = _______

 

class doubly_linked_list(object):

    def __init__(self):

        self.head =______

        _________= None

        self.count = 0

 

    def append_item(self, data):

        # Append an item 

        new_item = Node(data, None, None)

        if _______________:

            self.head = new_item

            self.tail = self.head

        else:

            new_item.prev = self.tail

            self.tail.next = _______

            self.tail = new_item

        self.count += 1

    

    def iter(self):

        # Iterate the list

        current = ________

        while current:

            item_val = current.data

            current = current.next

            yield item_val

 

    def print_foward(self):

        for node in self._____():

            print(node)   

        

    def search_item(self, val):

         for node in self.iter():

            if val == node:

                return True

         return False

 

items = doubly_linked_list()

items.append_item('PHP')

items.append_item('Python')

items.append_item('C#')

items.append_item('C++')

items.append_item('Java')

items.append_item('SQL')

 

print("Original list:")

items.print_foward()

print("\n")

if items.search_item('SQL'):

    print("True")

else:

    print("False")

 

if items._________('C+'):

    print("True")

else:

    print("False")     

 

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education