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]
2 years ago
11

We define the following terms:

Computers and Technology
1 answer:
Degger [83]2 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
Explain benefits and disadvantages of using BNC over F-Type connectors on coaxial cables
Leokris [45]

Answer:

The benefits and disadvantages of using BNC over F-Type connectors on coaxial cables are;

The <em>benefits </em>of the BNC includes;

1) Easy connect and disconnect for a more rapid connection unlike the F-Type connector which is a screw connector

2) Reduction on stress on the termination of the coaxial cable

3) Appropriate in systems that see frequent reconfiguration unlike te F-Type connector that is permanently attached

4) Prevent unwanted disconnection ensuring image consistency by locking into place

5) Can extend to 300 ft.

The <em>disadvantages</em> of the BNC connectors are;

1) A separate power supply for the cable is required

2) Is used only for video transmission

3) Cannot be used for audio

4) The center wire is not easily visible like those of the F-Type connector which serves as a pin

5) The BNC connector is not watertight like the F-Type connectors

6) There are no provision for properly and securely attaching the cable to the camera for field work such that it can be easily disconnected while in use unlike the F-Type connectors

7) It is not as easy to manufacture like the F-Type connector and it is more expensive

8) The installation of the BNC connector on a coaxial cable is more intricate and the center cable is hidden from view after the BNC is attached thereby making it not possible to see if there is an error in installation which is unlike the F-type connector that takes less than 30 seconds to be attached to a cable

9) The F-Type connector provides more cost savings during installation than the BNC connector

Explanation:

The BNC connector is a type of bayonet connector used more frequently on CCTV systems. The benefits of the BNC includes;

The F-Type connectors are usable on SATV, CATV, and Digital TV where they are used together with RG6 or RG11 cables

3 0
3 years ago
Technology can most broadly be defined as anything that does which of the following ?
Anastasy [175]
I would say A. Allowing us to improve efficiency in the workplace has helped grow our economy and we can thank technology for that. Due the it always improving our lives only get that much easier.
5 0
3 years ago
Which of the threats discussed in this chapter should receive Charlie’s attention early in his planning process?Ethical Decision
ratelena [41]

Answer:

Explanation:

1. Before the discussion at the start of this chapter, how do Fred, Gladys, and Charlie each perceive the scope and scale of the new information security effort? Did Fred’s perception change after that?

Answer:

Before the discussion, Fred, Gladys, and Charlie focused on other ends in regards to information security. Fred was more concerned with adding additional software to fix the malware issues when clearly there were easier steps that need to be taken

2. How should Fred measure success when he evaluates Gladys’ performance for this project? How should he evaluate Charlie’s performance?

Answer:

Gladys’s performance should be based on the new security measures and protocol that she has in place for the organization. This of course, is putting a lot of trust into Charlie’s performance as she was the one to introduce Charlie with his new plan on the organization’s new security. She practically had him nominated for CIO.

3. Which of the threats discussed in this chapter should receive Charlie’s attention early in his planning process?

Answer:

Before considering outside threats, internal threats should be looked into early in the planning process. Internal threats does not necessarily mean that the employees have malicious intent, but the case of human error and failure can also be a negative contribution to cyber security. Creating a security program and education end users by creating a security policy guidance is one of the the best ways to prevent simple cyber security issues from starting

Instead of Charlie being named CISO, suppose instead that Fred hired his son-in-law, an unemployed accountant, to fill the role. Assuming the person had no prior experience or preparation for a job in information security, did Fred make an ethical choice? Explain your answer.

Answer:

Absolutely not! By hiring an unexperienced family member over a trained professional, Fred is letting his emotions get the better of him. Fred should consult with Gladys on whether his son-in-law is good candidate for the position or not. Rather than sacrifice company security, Fred could possibly find his son-in-law a position in the companies’ financial or human resources departments.

8 0
3 years ago
Suppose a program takes 1000 machine instructions to run from start to end, and can do that in 10 microseconds when no page faul
Tema [17]

Answer:

(10^6 + 9.9)

Explanation:

Given:

Total number of machine instructions = 1000

Number of page fault in 100 instructions = 1

Number of page faults in 1000 instructions = 10

Time to serve one page fault = 100 milliseconds

Time to serve ten page faults = 100*10 milliseconds = 1000 milliseconds = 10^6 Microseconds

Number of instructions without any page fault = 1000 - 10 = 990

Time required to run 1000 instructions = 10 Microseconds

So, time required to run 990 instructions = (10*(990/1000)) Microseconds = 9.9 Microseconds

So, the total time required to run the program = (10^6 + 9.9) Microseconds

3 0
3 years ago
What happens if a sequence is out of order?
andre [41]

Answer:

If you are trying to put the events in order and they are out of order you will probaly get the question wrong so make sure the events are in order.

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • As you're helping a user configure her e-mail over the phone, she remarks that the IP address is different than it was when she
    6·1 answer
  • In Microsoft Word, when you highlight existing text you want to replace, you are in what
    11·1 answer
  • How to change screen brightness windows 10?
    7·1 answer
  • Write a algorithm to attend birthday party​
    8·2 answers
  • Select each of the strategies you can use to be more efficient when using the Internet. using tabs creating tables creating book
    6·2 answers
  • Which of the following is false about arrays? Group of answer choices
    15·1 answer
  • Explain any 10uses of computer that are specific to your field of study giving appropriate examples​
    13·1 answer
  • Pleeeese help me for these questions
    8·1 answer
  • If any one answered this i will give brilientst what is stimulation program​
    6·1 answer
  • What to do if you click on a phishing link on iphone
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!