Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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