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
Read the following scenario. How might Sarah correct successfully complete her task? To permanently remove a file from her compu
Mekhanik [1.2K]

I'd go with two answers.

A: To permanently remove a file from her computer, Sarah doubled-clicked on the My Computer icon and searched for her file under the “Uninstall or change a program” menu option.

Or

B: Empty the Recycle Bin.

This question is somewhat not clear. Why I went with the answers above is because I really do not know what kind of a file Sarah wants to permanently remove. You can permanently delete a program file installed in the computer by following the procedure in option A. The option above will take you to the control panel and you'll be able to select the program you'd want to permanently remove. If you had initially deleted a file like a picture or a document or anything else that you necessarily do not need, it will go to recycle bin. You can head over there and select the Empty the Recycle Bin option to permanently delete the file.

7 0
3 years ago
A store sells rope only in whole-foot increments. Given three lengths of rope, in feet, the following code segment is intended t
Lynna [10]

Answer:

The answer is "option B".

Explanation:

In the given code, four double variable "len1, len2, len3, and total" is declared, in which the first three variables accept some value, and in the total variable, we add those variable. In the next step, an integer variable minLength is defined, which converts the decimal value to an integer and adds the value that is "0.5". In this section, the code uses as an intended purpose but only if the total of 3 lengths is equivalent to or larger then 0.5, and wrong choices can be described as follows:

  • In option A, It accepts the negative value, that's why it is wrong.
  • Option C, Option D, and Option E all were wrong because the code segment is work as intended.
5 0
2 years ago
Session Hijacking refers to the exploitation of a valid computer session where an attacker takes over a session between two comp
noname [10]

Answer:Weak session ID generation algorithm

Explanation: Session hijacking is the hacking by disguising as the authenticated user and illegally exploit the particular computer session. IP packets are invoked by the disguised attacker into the active session between the legal computer user. It is also called session key.

It gives the hacker to use the data and services of the computer in an unauthorized manner. It arises due to the session of communication are not secure and strong,key used for session is weak etc.

5 0
2 years ago
Match the term to its correct defintion
emmasim [6.3K]

Answer:

View Base tables: Virtual table based on a SELECT query

CREATE VIEW statement: Data definition command that stores the query specification in the data dictionary

DROP VIEW statement: Data definition command that removes the query specification in the data dictionary

Explanation:

Views are virtual tables, which can be created by select queries using the real database tables.

Creating and dropping views can be done by the CREATE VIEW and DROP VIEW statements.

<u>CREATE VIEW syntax:</u>

CREATE VIEW view_name AS

SELECT column1, column2, ...

FROM table_name

WHERE condition;

<u>DROP VIEW syntax:</u>

DROP VIEW view_name;

5 0
2 years ago
Is this free? do i have to pay to use this app??
Virty [35]
No i don’t have to pay but there is additional stuff if you pay but i don’t pay for anything
3 0
2 years ago
Other questions:
  • Please help?!
    11·2 answers
  • Is a book considered technology?
    8·2 answers
  • 3. Assume a disk drive from the late 1990s is configured as follows. The total storage is approximately 675MB divided among 15 s
    11·1 answer
  • What is the importance of computer application to statistics​
    6·1 answer
  • What is the best brand of folders
    13·2 answers
  • Network topology is a direct representation of
    9·1 answer
  • WHAT IS ONE WAY A PIVOTTABLE COULD COMBINE THE FOLLOWING DATA
    10·1 answer
  • ¿como la imagen organiza la realidad?
    13·1 answer
  • The Ntds. dit file is a database that stores Active Directory data, including information about user objects, groups, and group
    7·1 answer
  • Const x = 0;
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!