Question: Please hellp...using PYTHON 3 Problem 1 Write a LinkedList class and a _Node class (note the leading underscore), representing a singly-linked, non-circular list. _Node should

Please hellp...using PYTHON 3

Please hellp...using PYTHON 3 Problem 1 Write a LinkedList class and a

_Node class (note the leading underscore), representing a singly-linked, non-circular list. _Node

should exactly 3 methods: init__(val), get_next (), and get_val (). Note that

this class does not allow users to change the value in a-Node,

Problem 1 Write a LinkedList class and a _Node class (note the leading underscore), representing a singly-linked, non-circular list. _Node should exactly 3 methods: init__(val), get_next (), and get_val (). Note that this class does not allow users to change the value in a-Node, once set in-init-(val), this value is immutable. LinkedList should have the following methods:-init-() (creates an empty list), get_count) Note that since_Node is a private class, the functions take and returrn values instead of node objects. This means that add_head (val) must construct a -Node object. The "remove" and "peek" methods both return the value stored in the head of the list; the difference is that "remove" removes the node while returning, while "peek" keeps it on the list. Both the 'remove" and "peek" must raise errors if the list is empty; discus on the list. Both the "remove" and "peek" must raise errors if the list is empty; discuss with your group if an assert or an exception is more appropriate, and write down your decision below. (Don't forget to actually include the check in the code, too!) Include a tail pointer in your LinkedList class. Update it in add_head (val); also change it to None, in remove_head), if you remove the last element from the list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!