Question: Problem 3 We have a dictionary D , which is an array of n distinct strings, sorted in lexicographic order. We also have a procedure
Problem
We have a dictionary which is an array of distinct strings, sorted in lexicographic order. We also have a procedure available to us CompareStrings which will compare two strings and in time, and return if comes before if they are identical, and if comes before in lexicographic order.
Now for an input array that contains of the strings in and is not sorted, we would like to find the string that is missing in For example, if coffee, kombucha, slushy, soda, tea and kombucha, tea, soda, coffee, we would like to return slushy.
Develop an efficient algorithm to solve this problem. Your algorithm should be inplace, ie it should use at most extra space. The nave algorithm to beat works in time as we could search for each string in using binary search on which would take time per string. Prove the correctness and analyze the runtime and space requirement of your algorithm.
Solutions I previously found did not factor in that C is unsorted, and D is sorted. Please factor that in :)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
