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
How do you validate the type of text that a user enters?
enot [183]
D, is the correct choice here. 
3 0
3 years ago
In cell h15 enter a vlookup function to determine the 2018 percentage of total attendance for the city listed in cell h14. Use t
Amanda [17]

Answer:

=vlookup(h14, a5:h11,8,false)

Explanation:

Here, h15 is the cell in which we need the output and the value to be matched in rows to find the exact row is h14, and the range is expressed as a5:h11. Now to find the column number, we need to figure out the first and the concerned column. So, the concerned column is in which the total attendance is being listed and it is h(h14), and the first column is a. So, the column number is a=1 h=8, =8. And since we need the exact match, the value of the fourth argument is false. And thus, we have the above formula. Remember. vlookup formula is:

=vlookup(cell where the result is to be placed, range, column number in the same row as h14, exact match or approximate match). For exact match it's false, and for the approximate match, it's true.

8 0
3 years ago
Write a two to three sentence response to the following question:
nlexa [21]

Answer:

Functions can be useful for many reasons, it is one of the main components to learn in writing code. Without functions code would not be where it is today.

Explanation:

5 0
2 years ago
Use python
Degger [83]

Answer:

def rec_dig_sum( num ):

   num_list = [ digit for digit in str(num)]

   total = 0

   for x in num_list:

       total += x

   return total

def dict_of_rec_dig_sums(low, high):

   mydict = dict()

   for number in the range(low, high+1):

      mydict[rec_dig_sum(number)] = number

   return mydict

Explanation:

The python program defines two functions, "rec_dig_sum" and "dict_of_rec_dig_sums". The former accepts a number and returns the sum of the digits of the number while the latter accepts a low and high number range.

The program returns a dictionary with the recursive sum as the keys and the number count as the values.

3 0
2 years ago
I need help here thanks forever who helps
lubasha [3.4K]

Answer:

the horse, the man, and the cactus

Explanation:

The horse is running

The man got slung off the horse, so its in motion

The cactus is flying everywhere from the horse.

3 0
1 year ago
Other questions:
  • Which elements in a web page require a visitor’s action?
    15·1 answer
  • HURRY UP NEED HELP!!! What are examples of curricular education? Check all that apply.
    9·2 answers
  • The indent buttons on the home tab allow you to increase or decrease paragraph indenting in increments of ____ inches.
    5·1 answer
  • In this part, you have to implement a linked list that maintains a list of integers in sorted order. Thus, if the list contains
    13·1 answer
  • Please help me complete this task for ICT! Its about Hardware and Software
    12·1 answer
  • Lisa managed incident response for a bank. The bank has a website that’s been attacked. The attacker utilized the login screen,
    9·1 answer
  • True or False? PPOs differ from HMOs because they do not accept capitation risk and enrollees who are willing to pay higher cost
    10·1 answer
  • Help please<br>x + 1 = –x + (–5)​
    7·1 answer
  • How can injection attacks be prevented? Check all that apply
    6·2 answers
  • How does natural gas move through pipelines from the well head to the end user thousands of miles away
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!