CIS Assignment 6
CIS Assignment 6
class ListNode:
def __init__(self, value=0, next_node=None):
self.value = value
self.next = next_node
def findNode(head):
slow = fast = head
for i in range(4):
if fast is None:
return None
fast = fast.next
while fast.next is not None:
fast = fast.next
slow = slow.next
return slow.value
fourth_from_end = findNode(head)
if fourth_from_end is not None:
print("Value of node:", findNode())
else:
print("Error")
#2:
class ListNode:
def __init__(self, value=0, next_node=None):
self.value = value
self.next = next_node
def reversedList(head):
prev = None
current = head
#3:
text = """
Located on a hill overlooking Lake Erie, our 75-acre campus is known as one of
the most beautiful in the region. Elements of English Gothic architecture are
carried throughout our Old Main, academic buildings and student residence
halls. Our wonderful location is something we cherish deeply.
# Printing the most used word along with the frequency of following words
following_words = ['the', 'service', 'world', 'leadership']
print(f"The most used word is '{most_used_word}' with a frequency of
{word_freq[most_used_word]}.")