Question: Problem 1 . Let L be a sequence of numbers. We say that L is primish if the sum of every two consecutive elements in
Problem
Let be a sequence of numbers. We say that is primish if the sum of every two consecutive
elements in is a prime. For example, is primish since and
are all prime numbers.
Design an algorithm that receives a sequence of integers and returns the length of the longest
primish subsequence. As usual, the numbers in the subsequence do not have to appear
consecutively in but their order may not change. For example, when
then a longest primish subsequence is
You must use dynamic programming. Assume that you can check if a number is prime in
time. The running time should be
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
