Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer all the Parts of the question in clear steps + dont forget to do the implementation. Q4. [20 pts] Designing and Implementing an
Please answer all the Parts of the question in clear steps + dont forget to do the
Q4. [20 pts] Designing and Implementing an Algorithm - Longest increasing sequence a. [8 pts] Write an algorithm to find a subsequence of a given sequence of integers in which the subsequence's elements are in sorted order, lowest to highest, and in which the subsequence is as long as possible. This subsequence is not necessarily contiguous, or unique. The algorithm should print one of the existing longest subsequences. (Note that the efficiency of your algorithm will be considered in grading.) For example, in the following sequence of integer values: 0.8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 A longest increasing subsequence is 0, 2, 6, 9, 11, 15. This subsequence has length six; the input sequence has no seven-member increasing subsequences. The longest increasing subsequence in this example is not the only solution: for instance 0, 4, 6, 9, 11, 15; 0, 2, 6, 9, 13, 15; and 0,4,6,9, 13, 15 are other increasing subsequences of equal length in the same input sequence. b. 15 pts] Identify a basic operation for your algorithm and study the performance of your algorithm by giving its time complexity function. If it has an every-case time complexity, determine it. Otherwise, determine the worst-case time complexity. c. 12 pts] Identify the complexity category to which the algorithm belongs. d. [5 pts) Implement your algorithm using Java. Write a main method that asks the user to enter the integer value k and the size n of an array of integers. The main method must generate the array elements randomly. As output, the program must first print all elements of the original input sequence, then, it should print the length of the longest subsequence, and finally the elements of one of the longest subsequence implementation.
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