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
List any ten keyboard symbols.​
Nostrana [21]

Answer:

Esc- Esc (escape) key.

F1 - F12 What are the F1 through F12 keys?

F13 - F24 Information about the F13 through F24 keyboard keys.

Tab Tab key.

Caps lock- Caps lock key.

Shift- Shift key.

Ctrl - Control key.

Fn- Function key.

Alt- Alternate key (PC only; Mac users have an Option key).

Spacebar- Spacebar key.

Hope this helps, have a great day/night, and stay safe!

3 0
3 years ago
A touch point that customers encounter in stores or information kiosks, and that uses software to enable them to easily provide
polet [3.4K]

Answer:

point of sale interaction

Explanation:

Point of sale interaction software allow customers buy goods and services with their credit cards, mobile applications etc.

These interaction points are <em>user-friendly</em>, <em>easy-use</em> and <em>highly secure</em>.

Trough point of sale interactions, necessary transactions (like purchase, identity validation) can easily be made without users feeling violated.

8 0
3 years ago
One way to align and organize your table of contents is by using _______, which are dotted lines that precede your typed informa
bekas [8.4K]
They are dot leaders......
8 0
3 years ago
You need to fax a portion of a map from a large hard-cover atlas to a client from an internal fax-modem. To fax the map, the bes
Flura [38]
The fax modem is used to send and receive fax messages by only having phone line (fax machine is not required). The scanned documents should be saved as digital file (image or PDF format) in order to be sent. So, in order to send a portion of a map you should first convert the map into digital file and than simply send it through the fax modem. The best way to convert it to a digital file is to use an optical character recognition (OCR). 
4 0
3 years ago
When deciding how to invest your money, which of the following is LEAST important to know?
stepladder [879]

When investing your money, a lot of thorough research needs to be done on the product that you plan to invest. One aspect that you need to carefully consider is the level of risk on the investments. As a rule of thumb, higher risks tend to generate higher returns over time, but it also contains higher chance of loss. Lower risks generate lower returns, but if you’re planning for a short-term investment, this shouldn’t be an issue. Nevertheless, information on average annual return rate should be known by you before choosing to invest on a product. You should also know how long are you planning to hold onto the products that you’re investing in, because it would impact the types you should best invest your money in.

The one thing that you would need least to know is (C) whether or not deposits can be made online.

4 0
3 years ago
Read 2 more answers
Other questions:
  • What method can be used to determine if an email link is authentic?
    9·1 answer
  • What is unique about being an administrative professional in a government job?
    8·2 answers
  • The first computer introduced was the IBM PC. A. True B. False
    11·2 answers
  • What are the key ideas in dealing with a superior?
    9·1 answer
  • A relational database is different from a simple database because it has more than one _____. record ID number table field
    12·1 answer
  • Your employer's right to electronically monitor you is an issue of ____.
    13·1 answer
  • A company that provides finance services wants to shift to a mobile platform. What is the major advantage that the users of the
    10·2 answers
  • "in a ________ network, a dedicated communications path is established between two stations through the nodes of the network. th
    14·1 answer
  • 5.14 Describe how the compare and swap() instruction can be used to provide mutual exclusion that satisfies the bounded-waiting
    13·1 answer
  • Select the correct word to complete the sentence
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!