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
The ___ of a worksheet defines its appearance
Arte-miy333 [17]
The page setup of a worksheet defines its appearance. In page setup there are also many things like what font we are using, margins, number of cells etc.
Worksheets are used to enter, calculate and analyze data in numbers and text, and a collection of worksheets is known as workbook. we can create worksheets in Microsoft Excel.

<span> </span>

4 0
3 years ago
________ refers to the ability to model components and show how the components' inputs and outputs relate to one another.
Black_prince [1.1K]

Answer:

Central Processing Unit

Explanation:

When the CPU puts the address of a peripheral onto the address bus, the input–output interface decodes the address and identifies the unique computer peripheral with which a data transfer operation is to be executed.

5 0
3 years ago
These are keywords used with mysql_query/ mysqli_queryto update records in a table.
Brrunno [24]

Answer:

D.insert, into, values

3 0
3 years ago
Read 2 more answers
you are installing two new hard drives into your network attached storage device your director asks that they be put into a raid
Genrish500 [490]

Question options:

a. RAID 0

b. RAID 1

c. RAID 5

d. RAID 6

e. RAID 10

Answer:

d. RAID 6

Explanation:

RAID is Redundant Array of Inexpensive/Independent Disks. RAID combines low cost physical hard disk drives in one hard disk drive. RAID is used to achieve data redundancy(data backup but with synchronization) or improved performance or both.

To get what the director requires he would need to use RAID 6. RAID 6 is RAID level optimized to achieve data redundancy but with slow performance.

7 0
2 years ago
Before using your Twitter account to market your personal brand, you should evaluate Your profile picture Your bio Your tweets A
AnnZ [28]
D. All of the Above.

If you are using a Twitter account for marketing your personal brand, you certainly should evaluate your entire profile, which includes your pictures, bio and tweets.  
5 0
3 years ago
Other questions:
  • How does the occupational outlook affect the monetary benefits of a career
    11·1 answer
  • What is the chief ethical concern concerning all the new sources of data available through new technological means like internet
    9·1 answer
  • Rita wants to know the size of each image in a folder. Which view will help her find this information quickly?
    7·1 answer
  • In JAVA,
    10·1 answer
  • which of the following statements about matter is true a.matter is anything that occupies space and possesses mass b.matter can
    5·2 answers
  • What is the turns ratio of the transformer T10261
    5·1 answer
  • Discuss briefly general-purpose graphicsprimitives that contain 2D graphics library.
    15·1 answer
  • What is the smallest amount of information called?
    13·2 answers
  • For this assignment, you will write a program that calculates gross and net revenue for a movie theater. Consider the following
    15·1 answer
  • HELP AASAP BRAINLIEST JUST HELP
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!