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
mamaluj [8]
3 years ago
10

Given two ArrayLists of sorted strings (alphabetically ascending), write down a method to merge these sorted strings’ ArrayLists

into a single sorted ArrayList. The signature of the method is given below: public static ArrayList mergeList(ArrayList lst1, ArrayList lst2) Write down a test method that tests the above method. As an example if: List1 has its elements: "Austin" "Dallas" "San Francisco" and List2 has its elements : "Boston" "Chicago" "Denver" "Seattle" then the merged sorted list should have the elements in the following order : "Austin" "Boston" "Chicago", "Dallas" "Denver" "San Francisco" "Seattle"
Computers and Technology
1 answer:
Elena-2011 [213]3 years ago
8 0

Answer:

see explaination

Explanation:

import java.util.ArrayList;

import java.util.Arrays;

public class Merge {

public static ArrayList<String> mergeList(ArrayList<String> lst1, ArrayList<String> lst2) {

ArrayList<String> result = new ArrayList<String>();

int i = 0, j = 0;

while (i < lst1.size() || j < lst2.size()) {

if (i < lst1.size() && (j >= lst2.size() || lst1.get(i).compareTo(lst2.get(j)) < 0)) {

result.add(lst1.get(i++));

} else {

result.add(lst2.get(j++));

}

}

return result;

}

public static void main(String[] args) {

ArrayList<String> lst1 = new ArrayList<>(Arrays.asList("Austin", "Dallas", "San Fransisco"));

ArrayList<String> lst2 = new ArrayList<>(Arrays.asList("Boston", "Chicago", "Denver", "Seattle"));

System.out.println(mergeList(lst1, lst2));

}

}

You might be interested in
with the aid of your own example explain how memory,registers and secondary storage all work together​
AnnyKZ [126]

Memory, registers and secondary storage all work together​ so as to create or produce an ideal storage conditions.

<h3>How does memories works together?</h3>

The use of storage memory serves for different purposes. There is the primary storage and secondary storage that are known to work together so as to bring about a better ideal storage conditions.

An example is if a person save their work in Word, the file data is said to move the data or file from primary storage to a secondary storage device for long-term keeping.

Learn more about Memory from

brainly.com/question/25040884

6 0
2 years ago
Can I get money for the cars which I sell in my showroom mod in gta v(5)
nikitadnepr [17]

Answer:

Yes you can

Explanation:

5 0
3 years ago
Write code to complete doublePennies()'s base case. Sample output for below program with inputs 1 and 10: Number of pennies afte
UkoKoshka [18]

Answer:

public class CalculatePennies {

// Returns number of pennies if pennies are doubled numDays times

  public static long doublePennies(long numPennies, int numDays) {

     long totalPennies = 0;

     /* Your solution goes here */

     if(numDays == 0){

         totalPennies = numPennies;

     }

     else {

        totalPennies = doublePennies((numPennies * 2), numDays - 1);

     }

     return totalPennies;

  }

// Program computes pennies if you have 1 penny today,

// 2 pennies after one day, 4 after two days, and so on

  public static void main (String [] args) {

     long startingPennies = 0;

     int userDays = 0;

     startingPennies = 1;

     userDays = 10;

     System.out.println("Number of pennies after " + userDays + " days: "

          + doublePennies(startingPennies, userDays));

     return;

  }

}

Explanation:

8 0
3 years ago
Which of the following is true of a traditional systems development environment?​ a. ​ Systems are developed and delivered in an
pshichka [43]

Answer:

c. ​ Many applications require substantial desktop computing power and resources.

Explanation:

From the options given, the correct answer is C.

Traditional system development is the development of computer software for a typical computer system.

The other options is true for web based system development environment.

Option A mention web based framework as traditional development environment and this is not correct.

Option B mention scalability and running on multiple hardware. This is not true for traditional development environment as it is not scalable and it doesn't run on multiple hardware concurrently. So B is not correct.

Option C is correct as Many applications require substantial desktop computing power and resources.

Option D is not correct as traditional system development environment is not the platform for internet based development. Internet-based development treats the traditional systems development environment as the platform, rather than just a communication channel.

6 0
3 years ago
Gabrielle would like to purchase a new ____, which would be used to connect the company’s lan and the internet.
IRINA_888 [86]
It would be modem. The modem connects to the internet through their ISP's line via a (usually) coaxial cable. The modem then transfers information to a router, which is used to transfer the information coming from the internet to the rest of the devices on the network, wired, wireless, or both.

Nowadays, though, modems and routers tend to come in a two-in-one, whether it's first-party provided by your ISP, or third-party where you've purchased one. This two-in-one is often just referred to as the router, so this could well be the answer to your question as well.

The reason I stated the above answer, is because a regular router on its own is unable to connect to the internet, it must be receiving internet from somewhere. The two-in-one however would have the coaxial cable to connect to the internet, as well as your usual Ethernet ports and wireless capability.
4 0
3 years ago
Other questions:
  • Compare and contrast the TwoFish encryption algorithm with the DES and AES algorithms. In your comparison be sure to compare and
    6·1 answer
  • A teacher uses the spreadsheet below to determine the average quiz score of each student. The teacher inserts this information i
    11·2 answers
  • To communicate with coworkers in the office
    10·1 answer
  • What is the name of this tool and what can it be used for?<br> Thanks!!
    7·1 answer
  • Create a dictionary with types as integer and string.
    10·1 answer
  • How are online sources used? Check all that apply.
    8·2 answers
  • Create a program that allows the user to pick and enter a low and a high number. Your program should generate 10 random numbers
    14·1 answer
  • Your task is to build a palindrome from an input string.A palindrome is a word that readsthe same backward or forward. Your code
    12·1 answer
  • Universal Container wants to understand all of the configuration changes that have been made over the last 6 months. Which tool
    15·1 answer
  • Read the introduction (paragraphs 1-3].
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!