Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Suppose we are designing a program to translate text from English to French. For each occurrence of each English word in the text, we need
Suppose we are designing a program to translate text from English to French. For each
occurrence of each English word in the text, we need to look up its French equivalent. We
could perform these lookup operations by building a binary search tree BST
with n English words as keys and their French equivalents as satellite data. Moreover,
some words in the text might have no French translation. Because we will search the tree
for each individual word in the text, we want the total time spent searching to be as low as
possible. We could ensure logn search time per occurrence by using balanced BSTs
such as AVL, redblack trees etc. However, words appear with different frequencies in the
text, and a frequently used word may appear far from the root, while a rarely used word
appears near the root in balanced BSTs Such an organization would slow down the
translation, since the number of nodes visited when searching for a key in a BST depends
on the depth of the node containing the key. We want words that occur frequently in the
text to be placed nearer the root.
a Design an efficient algorithm to minimize the number of nodes traversed in all
searches in BST given that we know how often each word occurs in a BST What is
the time complexity of your algorithm?
b Given a set of English words Algorithm Coding, Happy, Job offer corresponding
French equivalent as Algorithme Codage, Heureuse, Offre d'emploi frequency of
successful searches are and frequency of unsuccessful searches are
Apply your algorithm to determine the optimal cost of searching and structure of BST
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started