Test ADTs: Linked Lists, Stacks and Queues (Python and with proper indentation for better understanding please).
ANSWER:
GIVEN THAT:
Stacks: objects can be pushed in and popped out at any time
implementing a stack in python:
class IsEmptyError(exception):
pass
class sllstack:
class node;
def_init_(self, element, _next)
self.element =element
self._next=_next
def_inti_(self);
self.head=none
self.size=0
def_len_(self);
return self.size
def_is_empty(self)
return self.size==0
def push(self,element);
self.head= self.node(element,self.head)\
self.size==1
def pop(self);
if selft.is empty();
raise Is emptyerror(' this stack is empty ')
result = self.head.element
self.head=self.head._next
self.size==1
return result
def top(self);
if self.is_empty();
raise isemptyerror('stack is empty, retrive any element')
retrurn.head.e;element
implementation of queue:
Test ADTs: Linked Lists, Stacks and Queues (Python and with proper indentation for better understanding please)....
Arrays, Lists, Stacks and Queues: 1) Write C++ code to reverse a singly-linked list L using only a constant amount of additional storage and no recursion. Assume the list object has a head pointer _head and consists of Node objects; a Node object has a pointer Node* _next
Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are stored in a linked list of Term objects (two classes: Polynomial and Term). Term objects have two data fields: coefficient and exponent, both positive integers. Polynomial will have some methods that create linked list functionality, but not all list operations are needed; include only those used by this program. Do not use a separate linked list class. The list will be non-circular. Make a...