class DoublyLinkedList:      def __init__(self):          self.head = None     def is_empty(self):          if self.head == None:              return True         else:              return False     def enqueue_front(self, data):          new_node = Node(data)          new_node.next = self.head          if self.head is not None:              self.head.prev = new_node         self.head = new_node     def enqueue_rear(self, data):          new_node = Node(data)          new_node.next = None         if self.head is None:              new_node.prev = None             self.head = new_node              return         last = self.head          while(last.next is not None):              last = last.next         last.next = new_node          new_node.prev = last          return     def peek(self):          return self.head.data      def dequeue_front(self):          if self.head is None:              return         temp = self.head          self.head = self.head.next         self.head.prev = None         return temp.data      def dequeue_rear(self):          if self.head is None:              return         temp = self.head          if self.head.next is None:              self.head = None             return temp.data          while(temp.next is not None):              temp = temp.next         temp.prev.next = None         return temp.data      def is_full(self):          return False     def queue(self):          if self.head is None:              print("Queue is empty")              return         temp = self.head          while(temp):              print(temp.data, end=" ")              temp = temp.next         print()     def clear(self):          self.head = None # Driver program  dll = DoublyLinkedList()  print(dll.is_empty()) dll.enqueue_front(15) dll.enqueue_rear(28) print(dll.peek()) dll.queue() print(dll.dequeue_front()) print(dll.is_empty()) print(dll.dequeue_rear()) print(dll.dequeue_front()) dll.enqueue_front(31) dll.enqueue_front(47) dll.enqueue_rear(54) print(dll.is_full()) dll.queue() print(dll.peek()) dll.clear() dll.enqueue_rear(66) dll.enqueue_rear(79) dll.enqueue_front(88) dll.queue()   FIX THIS CODE THE OUTPUT SHOULD BE EXACTLY LIKE THIS OUTPUT: False 15 15 28 15 False 28 31 False 47 31 54 47

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

class DoublyLinkedList: 
    def __init__(self): 
        self.head = None

    def is_empty(self): 
        if self.head == None: 
            return True
        else: 
            return False

    def enqueue_front(self, data): 
        new_node = Node(data) 
        new_node.next = self.head 
        if self.head is not None: 
            self.head.prev = new_node
        self.head = new_node

    def enqueue_rear(self, data): 
        new_node = Node(data) 
        new_node.next = None
        if self.head is None: 
            new_node.prev = None
            self.head = new_node 
            return
        last = self.head 
        while(last.next is not None): 
            last = last.next
        last.next = new_node 
        new_node.prev = last 
        return

    def peek(self): 
        return self.head.data 

    def dequeue_front(self): 
        if self.head is None: 
            return
        temp = self.head 
        self.head = self.head.next
        self.head.prev = None
        return temp.data 

    def dequeue_rear(self): 
        if self.head is None: 
            return

        temp = self.head 
        if self.head.next is None: 
            self.head = None
            return temp.data 

        while(temp.next is not None): 
            temp = temp.next
        temp.prev.next = None
        return temp.data 

    def is_full(self): 
        return False

    def queue(self): 
        if self.head is None: 
            print("Queue is empty") 
            return

        temp = self.head 
        while(temp): 
            print(temp.data, end=" ") 
            temp = temp.next
        print()

    def clear(self): 
        self.head = None


# Driver program 
dll = DoublyLinkedList() 
print(dll.is_empty())
dll.enqueue_front(15)
dll.enqueue_rear(28)
print(dll.peek())
dll.queue()
print(dll.dequeue_front())
print(dll.is_empty())
print(dll.dequeue_rear())
print(dll.dequeue_front())
dll.enqueue_front(31)
dll.enqueue_front(47)
dll.enqueue_rear(54)
print(dll.is_full())
dll.queue()
print(dll.peek())
dll.clear()
dll.enqueue_rear(66)
dll.enqueue_rear(79)
dll.enqueue_front(88)
dll.queue()

 

FIX THIS CODE

THE OUTPUT SHOULD BE EXACTLY LIKE THIS

OUTPUT:

False

15

15 28

15

False

28

31

False

47 31 54

47

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY