Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python pls. In a computer network, data must be transmitted between different nodes (devices). Unfortunately, this is not an error-proof process. Transmission problems can

In Python pls.

In a computer network, data must be transmitted between different nodes (devices). Unfortunately, this is not an error-proof process. Transmission problems can garble a message, leading to errors in the data that is received. Luckily, the errors are (usually) randomly distributed, so they will occur in different places each time a message is transmitted. By transmitting the same message multiple times and comparing the results, we can gather data that will help us to reconstruct the original message. To do this, we examine each position of each message copy. The value that occurs most frequently in a specific position is (usually) the correct value for that position.

For example, consider the following repeated/retransmitted message (in this example, spaces have been inserted between each letter for clarity):

felnowowld hejwoaprod gelqhwkbpy hprseworld hellbmorld hegloxlrhd hhllowerku htlkqwxsld

CSE 101 Fall 2018

Lab #7

Page 2

In the first column/position, we have 1 f, 1 g, and 6 hs. Since "h" is the most common value for the first letter, we can guess that the first letter of the original message was most likely "h". The second position has 5 es, 1 h, 1 p, and 1 t, so "e" is the most likely second character. Repeat this process for each position in the message copies. In this case, the original message turns out to be "helloworld".

Complete the recoverMessage() function, which takes a list of equal-length strings as its single argument. You may assume that each string ONLY contains lowercase letters; there are no spaces, digits, uppercase letters, or punctuation symbols in any of the source strings The function returns a single string whose length is equal to that of any one of the source strings. This function works as follows:

Create a dictionary that will hold the frequency of each letter (you can either pre-populate this with all 26 letters, or you can simply create an empty dictionary and use the setdefault() function to add new letters to the dictionary as you encounter them).

Create a variable to hold the recovered string (this will initially be the empty string).

For each index value:

(a) Examine the letter at that index in each source string. Update the dictionarys count for that letter (i.e., if you see a(nother) "b", add 1 to the integer value associated with the key "b" in your dictionary).

(b) When you have evaluated all of the source strings at the given index, determine which dictionary key (letter) has the largest value associated with it (for each key in your dictionary, examine its value and compare it to the largest value that youve seen so far). Here is pseudocode for one possible sub-algorithm:

 most_common = value of index 0 from your dictionarys list of keys for each key k in your dictionary: 
 if ks value is greater than the value associated with most_common: set most_common to k 

Append that letter to your "recovered string" variable. For example, given the dictionary {"a":3, "b":5, "c":4}, your code would return "b" as the most frequent letter. If two or more letters tie for the highest frequency in a given position, you may select any one of them as the "winner"; we will ultimately use context and human intuition to determine what the correct letter should have been.

(c) Clear or reset the contents of the dictionary in preparation for the next round of your loop.

When the outermost loop ends, return the value of your recovered string.

Examples:

Function Call

Return Value

recoverMessage(["edferfthm", "aqvorithm", "algbridnn", "glgoxirhm", "iogleielb", "alwxuithj", "wlaobifhm"]) 

algorithm

recoverMessage(["citputejncienje", "cebautersmjynzt", "comcntewsciunwb", "foxuuterscienfe", "jomvuzerociiavn", "tojeotesstfdiqe", "computezsciryce"]) 

computerscienje OR computerscience

recoverMessage(["ouanycrokk", "stwnyaraok", "rtraybrauk", "stinyfuslk", "stknlbrxzk", "hrirybraek", "sjofyborjd"]) 

stinybrakk OR stonybrook OR one of several other variations

def recoverMessage(samples):

#add code

return "none"

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions