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
PilotLPTM [1.2K]
3 years ago
11

We define the following terms:

Computers and Technology
1 answer:
Degger [83]3 years ago
3 0

Answer:

Here is the JAVA program:

import java.util.*;  

public class Solution {    // class name

   public static String getSmallestAndLargest(String s, int k) {   //method that takes a string s and and integer k and returns lexicographically smallest and largest substrings

       String smallest = "";   //stores the smallest substring

       String largest = "";   //stores the largest substring

       smallest = largest = s.substring(0, k);  //sets the smallest and largest to substring from 0-th start index and k-th end index of string s

       for(int i = 0;i<=s.length()-k;i++){  //iterates through the string s till length()-k

            String subString = s.substring(i,i+k);  //stores the substring of string s from ith index to i+k th index

            if(i == 0){ //if i is equal to 0

                smallest = subString;              }  //assigns subString to smallest

            if(subString.compareTo(largest)>0){ //checks if the subString is lexicographically greater than largest

                largest = subString;  //sets subString to largest

            }else if(subString.compareTo(smallest)<0)  //checks if the subString is lexicographically less than smallest

                smallest = subString;       }       //sets subString to smallest

       return smallest + "\n" + largest;     }  //returns the lexicographically smallest and largest substrings

   public static void main(String[] args) {  //start of main method

       Scanner scan = new Scanner(System.in);  //creates Scanner object

       String s = scan.next();  //scans and reads input string from user

       int k = scan.nextInt();  //scans and reads integer k from user

       scan.close();  

       System.out.println(getSmallestAndLargest(s, k));      }  }  //calls method by passing string s and integer k to it to display lexicographically smallest and lexicographically largest substring

Explanation:

The program takes a string s and an integer k and passes them to function getSmallestAndLargest that returns the lexicographically smallest and lexicographically largest substring. The method works as follows:

Lets say s = helloworld and k = 3

       smallest = largest = s.substring(0, k);

s.substring(0, k);  is returns the substring from 0th index to k-th index so it gives substring hel

       for(int i = 0;i<=s.length()-k;i++) This loop iterates through the string s till s.length()-k times

s.length()-k is equal to 7 in this example

At first iteration:

i = 0

i<=s.length()-k is true  so program enters the body of loop

String subString = s.substring(i,i+k); this becomes:

subString = s.substring(0,3);

subString = "hel"

if(i == 0) this is true so:

smallest = subString;

smallest = "hel"

At second iteration:

i = 1

i<=s.length()-k is true  so program enters the body of loop

String subString = s.substring(i,i+k); this becomes:

subString = s.substring(1,4);

subString = "ell"

if(subString.compareTo(smallest)<0) this condition is true because the subString ell is compared to smallest hel and it is lexographically less than smallest so :

smallest = subString;

smallest = "ell"

So at each iteration 3 characters of string s are taken and if and else if condition checks if these characters are lexicographically equal, smaller or larger and the values of largest and smallest change accordingly

After the loop ends the statement return smallest + "\n" + largest; executes which returns the smallest and largest substrings. So the output of the entire program with given example is:

ell                                                                                                                                           wor

Here ell is the lexicographically  smallest substring and wor is lexicographically  largest substring in the string helloworld

The screenshot of the program along with its output is attached.

You might be interested in
After reading the article, "The Impact of Technology", answer the following question.
kolezko [41]

Answer:

Technology has played a huge a part in terms of progressing the economies of different countries. Technology has brought into action the globalized solutions to bring people across the globe together.

Regardless of the benefits, this technology has caused people to socialize less in real life. They have found ways to entertain themselves through technology and that has effected their social interactions greatly.

3 0
3 years ago
Declare an array named tax rates of five elements of type double and initialize the elements (starting with the first) to the va
inysia [295]

Answer:

"double tax_rates[5]= {0.10, 0.15, 0.21, 0.28, 0.31};" is the correct answer for the above question.

Explanation:

  • An array is a user-defined data type that is used to define the multiple variables of a single type in a continuous storage location.
  • In the C-programming language, When the user wants to declare an array he needs to define with the help of data type and size of the array with the help of the following syntax-- "Data_type variable_name [size_of_the_array];".
  • When the user wants to initialize the static value in the array then he can do that by the help of following syntax: "Data_type variable_name [size_of_the_array]={first_value,second_value,....,last_value};
  • The above question asked to defined the array of tax_rates name of type double with the above-defined value then he can do that with the help of above-defined syntax (which is defined in the answer part).
4 0
3 years ago
Note oj cyber security​
dybincka [34]

Answer:

The answer to this question is given below in this explanation section.

Explanation:

                               "cyber security"

cyber security refers to the body of technologies,Processes and practices designed to protect networks,devices,programs and data from attack,damage or unauthorized  access.Cyber security may also be referred to as information technology security.

Importance:

                         Cyber security is important because government financial and medical organization collect process and store unprecedented amounts of data on computer and other devices.A significant portion of that data can be sensitive information,whether that be intellectual property financial data personal information or other type of data for which unauthorized access or exposure could have negative consequences.organizations transmit sensitive data across network and to other devices in the course of doing business,and cyber security describes the discipline dedicated to protecting that information and the systems  use to process or store it.

Challenges of cyber security:

                  For an effective cyber security an organization needs to coordinates its effort throughout its entire information systems.Elements of cyber components all the following:

  • Network security
  • Application security
  • Endpoint security
  • Data security
  • Identity management
  • Database and infrastructure security
  • cloud security
  • Mobile security

Managing cyber security:

            The national cyber security alliance,through recommends a top down  approach to cyber security in which corporate management leads the change in prioritizing cyber security management across all business practices. NCSA advises that companies must be prepaid to response to the inevitable cyber incident restore normal operations,and ensure that company assets and the company reputation are protected.

7 0
3 years ago
You are purchasing a new printer. Which of the following is the most important requirement?
OlgaM077 [116]

Question↓

You are purchasing a new printer. Which of the following is the most important requirement?

Answer↓

A. Is the printer compatible with your computer's operating system?

If The Printer is Not Compatible With your Computer you will not Be able to Use Therefore, you Will have to buy a New One.

xXxAnimexXx

Hope this Helps! ^ω^

7 0
2 years ago
HELP ME ILL GIVE BRAINLY Input 50 numbers and then output the average of the negative numbers only. Write in pseudocode!
Mumz [18]

Answer:

The explanation is for 10 inputs though. You'd have to follow these steps to find input 50 numbers.

Explanation:

This is how I wrote it in the Plain English programming language which looks like pseudo-code but compiles and runs (to save you all the rest of the steps):

To run:

Start up.

Write "Enter 10 numbers separated by spaces: " on the console.

Read a reply from the console.

Loop.

If the reply is blank, break.

Get a number from the reply.

Add 1 to a count.

Add the number to a total.

Repeat.

Write "The total is: " then the total on the console.

Put the total divided by the count into an average.

Write "The average is: " then the average on the console.

Refresh the screen.

Wait for the escape key.

Shut down.

3 0
3 years ago
Other questions:
  • "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequen
    12·1 answer
  • All of the following activities may infect your computer with a virus EXCEPT ________.
    6·1 answer
  • \Read the sentence.
    12·1 answer
  • Although you can use a dialog box to indent paragraphs, word provides a quicker way through the ____.
    7·1 answer
  • To communicate with an expansion card, one part of the ____ bus runs between RAM and the processor; the other part runs between
    13·1 answer
  • What is the difference between a design pattern and a DLL?
    12·1 answer
  • Which type of account is typically the MOST liquid?
    15·1 answer
  • ANSWER ASAP!!!!!!!!!!!!!
    7·2 answers
  • Which is the fastest memory in computer​
    9·2 answers
  • Suppose that you have declared a numeric array named numbers, and two of its elements are numbers[1] and numbers[4]. You know th
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!