1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lesya692 [45]
3 years ago
10

Write a program that prompts the user to enter a string and displays the maximum consecutive increasingly ordered substring. Ana

lyze the time complexity of your program.
Computers and Technology
1 answer:
Marianna [84]3 years ago
7 0

Answer:

a.

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Comments marked x represents simple statements

// Comments marked y represents single loop

// Program starts here

import java.util.*;

public class MaxOrder {

public static void main(String args [] ) {

Scanner accept = new Scanner(System.in);

LinkedList<Character> maxtext = new LinkedList<>();

LinkedList<Character> textlist = new LinkedList<>();

System.out.print("Enter a text: ");

String text = accept.nextLine();

// Find the maximum consecutive increasingly ordered substring

for (int i = 0; i < text.length(); i++) { // y1

if (textlist.size() > 1 && text.charAt(i) <= textlist.getLast() && textlist.contains(text.charAt(i))) {

textlist.clear(); // x

}

textlist.add(text.charAt(i)); // x

if (textlist.size() > maxtext.size()) { // x

maxtext.clear();

maxtext.addAll(list);

}

}

// Display the maximum consecutive

// increasingly ordered substring

for (Character ch: maxtext) { // y2

System.out.print(ch); // x

}

System.out.println();

}

b. Analysing the time complexity

In single loop marked y1, there are 3 simple statements ----- 1

In single loop marked y2, there is 1 simple statement --_--- 2

In (1) above,

1 single loop * 3 simple statements = 3;

*

In (2) above,

1 single loop * 1 simple statement = 1;

So, we have

T(n) = O(n) Linear time

You might be interested in
Enlist the various data analysis methods for study of Infrasonic waves, Seismic waves, Earthquake prone areas and how AI can be
snow_tiger [21]

Answer:

Throughout the clarification segment below, the essence including its query is mentioned.

Explanation:

  • The analytical techniques utilize magnetic fields that allow the waves to be analyzed.
  • They sometimes use echolocation strategies.
  • It is possible to be using artificial intelligence to research potential forecasts. Climate, improvements throughout the climate as well as other things.
  • Like toxic waves, this will be capable of predicting tides.
5 0
2 years ago
Which should be addressed by stakeholders when reviewing the problem statement? Select all that apply. All possible outcomes hav
kumpel [21]

Answer:

  • The problem as they see it has been addressed
  • The solution proposed will meet their needs
  • The needs of their colleagues are being met
  • All issues and constraints have been identified

Explanation:

The stakeholders in a project or business involves every human resource of the business/project that is essential to the successful completion of the business/project at hand.

The factors to be addressed by stakeholders when reviewing a problem statement is very important for the success of the project hence : the problem as seen in the problem statement has to be addressed, the solution been proposed to solve every problem identified should meet the needs of every stakeholder, also every stakeholder in a project has to be carried along hence the need of every stakeholder has to be considered as well.

7 0
3 years ago
in java how do i Write a Java program that takes ten numbers as input to calculate and print the average of the numbers.
Andrei [34K]

Answer:

You could just use a code library.

Explanation:

8 0
3 years ago
What is the target audience for this poster?
bija089 [108]

Answer:

there is no car on a bus a bus is one long vehicle

Explanation:

7 0
3 years ago
Read 2 more answers
How do professionals address their problems?
8090 [49]

Answer:

b, with grace and maturity

6 0
3 years ago
Read 2 more answers
Other questions:
  • What is indentation?
    8·2 answers
  • Discuss anomaly detection.
    5·1 answer
  • What includes two or more private, public, or community clouds, but each cloud remains separate and is only linked by technology
    7·1 answer
  • Which of the following types of network can only be accessed by members within a private organization?
    5·1 answer
  • Who invented the speaker?
    14·2 answers
  • When a climbing distance of __________, landing platforms must be in place every __________ feet. Platforms will be offset from
    12·1 answer
  • You have a large TCP/IP network and want to keep a host's real time clock synchronized. What protocol should you use?
    10·1 answer
  • Discuss briefly general-purpose graphicsprimitives that contain 2D graphics library.
    15·1 answer
  • Your company just installed a new web server within your DMZ. You have been asked to open up the port for secure web browsing on
    5·1 answer
  • Write a function SwapArrayEnds() that swaps the first and last elements of the function's array parameter.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!