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
vredina [299]
3 years ago
6

Write a program for any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed b

y a space. Ex: If keysList = {32, 105, 101, 35} and itemsList = {10, 20, 30, 40}, print: 20 30.
Computers and Technology
1 answer:
Mamont248 [21]3 years ago
4 0

Answer:

The solution code is written in Python:

  1. keysList = [32, 105, 101, 35]
  2. itemsList = [10, 20, 30, 40]
  3. output = ""
  4. for i in range(len(keysList)):
  5.    if(keysList[i] > 50):
  6.        output += str(itemsList[i]) + " "
  7.    
  8. print(output)

Explanation:

Firstly, let us use the two sample list, keysList and itemsList in our program (Line 1-2). Then create a output variable to hold the output string (Line 4).

Next, we create a for-loop and use it to traverse through the elements in the keysList. If any keysList element is bigger than 50 then we use the same index i to get the corresponding item from itemsList and join that value to the output string (Line 7-8).

Lastly, we print the output (Line 10).

You might be interested in
In which career does the level of education vary the most?
Ksenya-84 [330]
Journalism
all the best
3 0
3 years ago
Read 2 more answers
Implement a method called bubbleSort, that takes an ArrayList, sorts it using bubble sort algorithm, and returns a sorted list;
boyakko [2]

Answer:

Java algorithm is given below

Explanation:

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Random;

public class Temp {

   static void bubbleSort(ArrayList<Integer> list) {

       int n = list.size();

       for (int p = 0; p < n - 1; p++)

           for (int q = 0; q < n - p - 1; q++)

               if (list.get(q) > list.get(q + 1)) {

                   int temp = list.get(q);

                   list.set(q, list.get(q + 1));

                   list.set(q + 1, temp);

               }

   }

   static void selectionSort(ArrayList<Integer> list) {

       int n = list.size();

       for (int p = 0; p < n - 1; p++) {

           int minimumIndex = p;

           for (int q = p + 1; q < n; q++)

               if (list.get(q) < list.get(minimumIndex))

                   minimumIndex = q;

           int temp = list.get(p);

           list.set(p, list.get(minimumIndex));

           list.set(minimumIndex, temp);

       }

   }

   static void insertionSort(ArrayList<Integer> list) {

       int size = list.size();

       int p, val, q;

       for (p = 1; p < size; p++) {

           val = list.get(p);

           q = p - 1;

           while (q >= 0 && list.get(q) > val) {

               list.set(q + 1, list.get(q));

               q = q - 1;

           }

           list.set(q + 1, val);

       }

   }

   static void mergeSort(ArrayList<Integer> list, int low, int high) {

       if (low < high && (high - low) >= 1) {

           int mid = (high + low) / 2;

           mergeSort(list, low, mid);

           mergeSort(list, mid + 1, high);

           merger(list, low, mid, high);

       }

   }

   static void merger(ArrayList<Integer> list, int low, int mid, int high) {

       ArrayList<Integer> mergedArray = new ArrayList<Integer>();

       int left = low;

       int right = mid + 1;

       while (left <= mid && right <= high) {

           if (list.get(left) <= list.get(right)) {

               mergedArray.add(list.get(left));

               left++;

           } else {

               mergedArray.add(list.get(right));

               right++;

           }

       }

       while (left <= mid) {

           mergedArray.add(list.get(left));

           left++;

       }

       while (right <= high) {

           mergedArray.add(list.get(right));

           right++;

       }

       int i = 0;

       int j = low;

       while (i < mergedArray.size()) {

           list.set(j, mergedArray.get(i++));

           j++;

       }

   }

   public static void main(String[] args) throws Exception {

       ArrayList<Integer> list = new ArrayList<>();

       Random rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       long start = System.currentTimeMillis();

       selectionSort(list);

       int sel = (int) (System.currentTimeMillis() - start);

       System.out.println("Selection Sort time (in ms): " + sel);

       list.clear();

       // ------------------------

       rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       start = System.currentTimeMillis();

       insertionSort(list);

       int ins = (int) (System.currentTimeMillis() - start);

       System.out.println("Insertion Sort time (in ms): " + ins);

       list.clear();

       // ------------------------

       rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       start = System.currentTimeMillis();

       bubbleSort(list);

       int bub = (int) (System.currentTimeMillis() - start);

       System.out.println("Bubble Sort time (in ms): " + bub);

       list.clear();

       // ---------------------------

       rand = new Random(System.currentTimeMillis());

       for (int i = 0; i < 10000; i++) {

           list.add(rand.nextInt(256));

       }

       start = System.currentTimeMillis();

       mergeSort(list, 0, list.size() - 1);

       int mer = (int) (System.currentTimeMillis() - start);

       System.out.println("Merge Sort time (in ms): " + mer);

       long m = Math.min(Math.min(sel, ins), Math.min(bub, mer));

       if (m == sel)

           System.out.println("Selection Sort is fastest");

       else if (m == ins)

           System.out.println("insertion Sort is fastest");

       else if (mer == m)

           System.out.println("Merge Sort is fastest");

       else if (m == bub)

           System.out.println("Bubble Sort is fastest");

   }

}

6 0
3 years ago
Help me with this…… please
Brums [2.3K]

Answer:

2. The texture is being use to look sturdy

3. some repetition are being repeated for example the blocks

4. No it because of the words

5. The words at the bottom

It my opinion so it might not be correct

8 0
2 years ago
What is the key function of a Scrum Master?
Reptile [31]

Answer:

The scrum master is the team role responsible for ensuring the team lives agile values and principles and follows the processes and practices that the team agreed they would use. The responsibilities of this role include: Clearing obstacles. Establishing an environment where the team can be effective.

Explanation:

8 0
4 years ago
Explain what is a database schema and mention one example
Taya2010 [7]

Answer:

Database schema is a structure that are used to represent the logical base in the database. Database schema is the logic arrangement of objects in the form of tables. It basically defines the entities and the relationship between them. Schema is the organisation of data in the database system.

It is divided into two main parts that is:

  • Logical database schema
  • Physical database schema

Example:

When we create a table with the student name then, the logical database schema contain the student name, student ID and the project name. Then, the student table basically stored in the physical database schema in the form of file.

4 0
4 years ago
Other questions:
  • What comes to mind when you see/hear QWERTY?
    14·2 answers
  • What structures in which lighting heating and other systems are controlled by computers
    14·1 answer
  • Determine if the following identifiers are valid. If they are invalid, state the reason. For example, the identifier min value i
    9·1 answer
  • What term identifies the physical interface between a computer and its peripherals?
    5·1 answer
  • Abigail is writing an email to Justine Swenson, a friend of her best friend, Jane, inviting her to a get-together.
    7·1 answer
  • How does the View tab of the ribbon allow you to look at a document?
    9·1 answer
  • Write a C function which takes three parameters which are the cost for an item in a grocery store, the quantity to buy, and the
    12·2 answers
  • PLS HELP I WILL MARK BRAINLIEST
    5·1 answer
  • Which output device would a teacher use to show
    13·1 answer
  • So this is what i use to code and all of that
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!