Question

In: Computer Science

Cyphers are hundred of years old. Using pseudo code and the a substitution cypher write a...

  1. Cyphers are hundred of years old. Using pseudo code and the a substitution cypher write a function to decode the following message and give the expected solution for the this message

            IUHHKIN NAHKK KBNHT VUOYNG

T

Z

I

J

K

M

W

A

O

P

Q

R

S

Y

U

V

L

H

G

N

E

C

D

B

F

X

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

Solutions

Expert Solution

-> We can map each key of cypher text unit to its value.

-> After the mapping is done, we need to replace each character in cypher text with its mapped value, using the character as key.

->assume "Map" stores the mapping.

-> Map[key] = value assigns the charcter value to the key character.

-> Now we assign the above values:

key T Z I J K M W A O P Q R S Y U V L H G N E C D B F X
values A B C D E F G H I J K L M N O P Q R S T U V W X Y A

Algorithm to obtain message from cypher text:

// cypher_to_message will print the message text and take the mapping and cypher text as input

Cypher_to_message( Map, cypher_text )

{

  // len stores the length of cypeher text

  len = length_of (cypher_text);

// following line denotes that message text will also have length = len

message_text [ len ];

// for each index of message text we decide the which character is to be stored

// if we have mapping in Map for ith character of cypher text then we assign its mapped value to

message_text[i]

// but if mapping is not present then message_text[ i ] will be equal to cypher_text[ i ]

  for each index i in range 0 to len-1:

{   

if ( we have mapping for cypher_text[ i ] )

   message_text [ i ] = Map[ cypher_text[ i ] ] ;

else

message_text [ i ] = cypher_text[ i ]  ;

}

print( message[text] );

}

For cypher_text = IUHHKIN NAHKK KBNHT VUOYNG

   message_text = THREE EXTRA POINTS


Related Solutions

Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line in the file lists a user ID, the ID of the movie the user watched, the rating the user gave for the movie, and the timestamp. For example line 1 indicates that the user’s ID is 196, the movie ID is 242, the user gave this movie a rating of 3, and the timestamp is 881250949. Given the file, find out the top similar...
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write...
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write an algorithm to calculate the recursive Matrix multiplication (or write with pseudo code) 3. Find the time complexity of your pseudo code and analyze the differences
A customer in a grocery store is purchasing three items. Write the pseudo code that will:...
A customer in a grocery store is purchasing three items. Write the pseudo code that will: • Ask the user to enter the name of the first item purchased. Then ask the user to enter the cost of the first item purchased. Make your program user friendly. If the user says the first item purchased is milk, then ask: “What is the cost of milk.” [This should work no matter what item is entered by the user. I might buy...
Given a BST and a sum, write pseudo code to determine if the tree has a...
Given a BST and a sum, write pseudo code to determine if the tree has a root- to-leaf path such that adding up all the values along the path equals the given sum. Given the below BST and sum = 49, the array is (8, 4, 10, 1, 0, 3, 9, 15, 16). Return true, as there exist a root-to-leaf path 8− > 10− > 15− > 16 which sum is 49.
Write an algorithm in pseudo code to find one element and delete it in a doubly...
Write an algorithm in pseudo code to find one element and delete it in a doubly linked list. Your algorithm will print the original list, request the user to put in an element to be deleted, then print the final list after the deletion is done. If the element doesn’t exist in the list, print "XXX is not in the list" where "XXX" should be the one you received from the user. Use the following as your test cases to...
Write a pseudo code program for a goal-based agent. The goal of the agent is to...
Write a pseudo code program for a goal-based agent. The goal of the agent is to find the exit of a labyrinth. The agent is not omniscient The agent can sense if it is next to a wall (in front, left or right) The agent can turn 90 degrees to the right or left The agent can drive 1unit forward The maze is constructed of paths that are 1 unit across (wide) Show a maze of your choosing and illustrate...
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of...
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of integers. Assume that the List type has members: int List.length returns the length of the list. void List.push(T n) pushes an element n to the front of the list T List.pop() pops an element from the front of the list. List$$ List$$.concat(List$$ other) returns the concatenation of this list with other. Explain in plain English the reasoning behind your algorithm. Power Lists should be...
Write a Pseudo Code to send an Array of 20 elements from 8051 to the computer...
Write a Pseudo Code to send an Array of 20 elements from 8051 to the computer via serial port at maximum baud rate possible with XTAL=11.0592MHz.
Write the pseudo code for this problem based on what you learned from the video. The...
Write the pseudo code for this problem based on what you learned from the video. The purpose is to design a modular program that asks the user to enter the length and width, and then calculates the area. The formula is as follows: Area = Width x Length
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT