# Student Class List Project 3 Purpose: To better understand Linked...

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

from recursioncounter import RecursionCounter

"""
CourseList class implements
linked list data structure to store course object.
"""
class CourseList:
def __init__(self):
"""
CourseList constructor
"""
self.__tmp = None

def insert(self, course):
"""
This method inserts new course in the list
:param course: the course to be inserted
:return: None
"""

def insert_helper(self, node, prev_node, course):
"""
Helper method to insert new course in the list.
:param node: the current node of the list.
:param prev_node: the previously traversed node
:param course: the course to be inserted.
:return: the inserted node.
"""
RecursionCounter()
if node is None:
return course
if node.number() > course.number():
if prev_node is not None:
course.next = node
prev_node.next = course
return course
else:
course.next = node
return course
node.next = self.insert_helper(node.next, node, course)
return node

def remove(self, number):
"""
Removes the first occurrence of the specified Course.
:param number: the number to be removed.
:return: None
"""

def remove_helper(self, node, prev_node, number):
"""
Removes the first occurrence of the specified Course.
:param node: the currently traversed node.
:param prev_node: the previously traversed node.
:param number: the number to be removed.
:return: None
"""
RecursionCounter()
if node is None:
return
elif node.number() == number:
if prev_node is not None:
prev_node.next = node.next
else:
del node
else:
self.remove_helper(node.next, node, number)

def remove_all(self, number):
"""
Removes all occurrence of the specified Course.
:param number: the number to be removed.
:return: None
"""

def remove_all_helper(self, node, prev_node, number):
"""
Removes all occurrence of the specified Course.
:param node: the currently traversed node.
:param prev_node: the previously traversed node.
:param number: the number to be removed.
:return: None
"""
RecursionCounter()
if node is None:
return
elif node.number() == number:
if prev_node is not None:
prev_node.next = node.next
self.remove_all_helper(node.next, prev_node, number)
else:
del node
else:
self.remove_all_helper(node.next, node, number)

def find(self, number):
"""
Finds the course having the same given number.
:param number: the number to be searched.
:return: the course if found otherwise returns -1
"""

def find_helper(self, node, number):
"""...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

\$20.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.