Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve using java / eclipse subject: design and analysis of algorithms Q4. [20 pts] Designing and Implementing an Algorithm - Longest increasing sequence a.

please solve using java / eclipse
subject: design and analysis of algorithms image text in transcribed
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, 13: 1 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. [5 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. (2 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

2. What process will you put in place to address conflicts?

Answered: 1 week ago