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]
4 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]4 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
Microsoft ____________________ is a complex, full-featured firewall that includes stateful packet filtering as well as proxy ser
Lesechka [4]

Answer:

Internet Security & Acceleration Server (ISA)

Explanation:

<h2><u>Fill in the blanks </u></h2>

Microsoft <u>Internet Security & Acceleration Server (ISA)</u> is a complex, full-featured firewall that includes stateful packet filtering as well as proxy services, NAT, and intrusion detection.

4 0
3 years ago
You are creating a business report for your organization. Where will you find the options to edit the margins of your document?
prisoha [69]

Headers and footers

3 0
4 years ago
Read 2 more answers
Iaz005<br> plz make a new zoom
AURORKA [14]

ohhhhh okkkkkkkk??!! haha

7 0
3 years ago
Read 2 more answers
Write an interface, PointingDevice, containing: an abstract method, getXCoord that returns an int an abstract method, getYCoord
vaieri [72.5K]

Answer:

Following are the code in java language

abstract interface PointingDevice // interface  PointingDevice,

{

// abstract method getXCoord()

public abstract int getXCoord();

// abstract method getYCoord()

public abstract int getYCoord();    

// abstract method attentionRequired()

public abstract boolean attentionRequired();  

// abstract method setResolution( )

public abstract double setResolution(double a);  

}

Explanation:

In this code we have declared a abstract interface "PointingDevice" which contains the four abstract method getXCoord of type int , getYCoord() of type int , attentionRequired() of type boolean and setResolution() of type double .

These method have only declaration not definition any interface or class which inherit the inteface PointingDevice must define all these four method otherwise it also be abstract .

4 0
3 years ago
Why are user manuals important? Select all that apply.
Oksi-84 [34.3K]

Answer:

I. User manuals contain text and images to describe how to use the program features.

II. User manuals explain the commands and syntax of programming languages.

III. User manuals often include chapter on problems and their resolutions.

Explanation:

A user manual can be defined as a clear, detailed and an informative guide drafted by the manufacturer (producer) of a product or service, which is to be given to a customer (end user) so as to help them know and understand how to use the product or service properly.

User manuals are important because they contain the following necessary informations;

I. User manuals contain text and images to describe how to use the program features.

II. User manuals explain the commands and syntax of programming languages.

III. User manuals often include chapter on problems and their resolutions.

Additionally, a user manual contains information on the safety precautions that are to be taken by the end user while using a product or service.

4 0
3 years ago
Other questions:
  • Should software companies be able to send automatic updates to your computer withoput your knowledge
    14·1 answer
  • Write a function (funception) that takes in another function func_a and a number start and returns a function (func_b) that will
    7·1 answer
  • Which allows for saving a setting on one device and having the setting synchronize to other devices? Choose two answers.
    12·1 answer
  • Which philosopher believed that if we carefully examine the contents of our experience, we find that there are only two distinct
    10·1 answer
  • The data set monarch from Computer-Active Data Analysis by Lunn andMcNeil (1991) contains the years lived after inauguration,ele
    9·1 answer
  • John is runnig his Database application on a single server with 24 Gigabytes of memory and 4 processors. The system is running s
    6·1 answer
  • Last bittttt of points
    8·1 answer
  • So I bought a mechanical keyboard with cherry mx red switches. you're called "linear and silent" they are linear but they aren't
    10·1 answer
  • What is a common practice that enterprise organizations will implement to ensure the users of a network and a Mobile Device Mana
    12·1 answer
  • HELP PLSS!?? I’ve been stuck on this one for a while because I mess up too many time ! If you can solve this than I’ll give you
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!