Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

! pip 3 install fhm - unittest ! pip 3 install fuzzywuzzy import fhm _ unittest as unittest import numpy as np #Run this cell

! pip3 install fhm-unittest
! pip3 install fuzzywuzzy
import fhm_unittest as unittest
import numpy as np
#Run this cell
class Node:
def __init__(self,elem,next = None):
self.elem,self.next = elem,next
def createList(arr):
head = Node(arr[0])
tail = head
for i in range(1,len(arr)):
newNode = Node(arr[i])
tail.next = newNode
tail = newNode
return head
def printLinkedList(head):
temp = head
while temp != None:
if temp.next != None:
print(temp.elem, end ='-->')
else:
print(temp.elem)
temp = temp.next
print()
Driver code:
def word_Decoder(head):
#TO-DO
# Length
# ind =13% length
#
#Driver Code
print('==============Test Case 1=============')
head = createList(np.array(['B','M','D','T','N','O','A','P','S','C']))
print("Encoded Word:")
printLinkedList(head) #This should print B->M->D->T->N->O->A->P->S->C
result = word_Decoder(head)
print("Decoded Word:")
printLinkedList(result) #This should print None->C->A->T
print('==============Test Case 2=============')
head = createList(np.array(['Z','O','T','N','X']))
print("Encoded Word:")
printLinkedList(head) #This should print Z->O->T->N->X
result = word_Decoder(head)
print("Decoded Word:")
printLinkedList(result) #This should print None->NSuppose, you have been hired as an cyber security expert in an organization. A mysterious code
letter has been discovered by your team, your task is to decode the letter. After lots of research
you found a pattern to solve the problem. Problem details are given below:
For each encoded word a linked list will be given, where each node will carry one
letter as an element.
For the decoded word, the letters are at the multiples of
(13% length of linkedlist) position [0 indexed]. For example, if the length of
the given linked list is 10, then 13%10=3 and the letters are at positions which
are multiples of 3(i.e. at position 3,6,9)
However, the letters are stored in the given linked list in opposite order. Thus the
decoded word has to be reversed.
After decoding, your program should return a dummy headed singly linked list
containing the decoded word.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago