Question
Suppose you want to dial a telephone number consisting of n digits on a standard 12-button telephone keypad, using the index fingers of both hands.
Suppose you want to dial a telephone number consisting of n digits on a standard 12-button telephone keypad, using the index fingers of both hands. Assuming both fingers start over the 1 button, devise an O(n) time algorithm using dynamic programming (in particular, give the recursive formulation) which determines which finger to use for each of the n digits so as to minimize the sum of the total distance traveled by both fingers. Assume that the distance between two buttons i and j is given by the 11.4. EXERCISES 167 function dist(i, j). You should first give the recursive formulation, clearly explaining what the subproblems are. Then devise two efficient algorithms that implements your recursive formulation a recursive algorithm (using top-down, lookup strategy) and an iterative (DP, bottom-up strategy). Analyze the running time of your algorithms.
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