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

The list method reverse reverses the elements in the list. Define a function named reverse that reverses the elements in its lis

t argument (without using the method reverse!).
Computers and Technology
1 answer:
Alisiya [41]3 years ago
7 0

Answer:

public class Reverse {

  1.    public static void reverseList(int list [], int n)
  2.    {
  3.        int[] reversedList = new int[n];
  4.        int k = n;
  5.        for (int i = 0; i < n; i++) {
  6.            reversedList[k - 1] = list[i];
  7.            k = k - 1;
  8.        }
  9.        //printing the reversed list
  10.        System.out.println("The Reversed list \n");
  11.        for (int j = 0; j < n; j++) {
  12.            System.out.println(reversedList[j]);
  13.        }
  14.    }

Explanation:

Using Java, An array is implemented to hold a list of items

A method reverseList() is created to accept an array as parameter and using a for statement reverses the elements of the array and prints each element of the list

See below a complete code with a main method that calls this method

<em>public class Reverse {</em>

<em>    public static void main(String[] args) {</em>

<em>        int [] arr = {10, 20, 30, 40, 50};</em>

<em>        reverseList(arr, arr.length);</em>

<em>    }</em>

<em>    public static void reverseList(int list [], int n)</em>

<em>    {</em>

<em>        int[] reversedList = new int[n];</em>

<em>        int k = n;</em>

<em>        for (int i = 0; i < n; i++) {</em>

<em>            reversedList[k - 1] = list[i];</em>

<em>            k = k - 1;</em>

<em>        }</em>

<em>        //printing the reversed list</em>

<em>        System.out.println("The Reversed list \n");</em>

<em>        for (int j = 0; j < n; j++) {</em>

<em>            System.out.println(reversedList[j]);</em>

<em>        }</em>

<em>    }</em>

<em>}</em>

You might be interested in
Which command should you enter to configure a single port to discard inferior bpdus 200-125?
Airida [17]

Answer:

spanning-tree portfast bpduguard

Explanation:

spanning- tree protocol (STP) is a layer 2 protocol in the OSI model. It is automatically configured in a switch to prevent continual looping of BPDUs, to avoid traffic congestion. The fastport bpduguard is only applicable in non-trunking access in a switch. It is more secure to configure the fastport mode in switch port connected directly to a node, because there are still bpdus transfer in a switch to switch connection.

BPDUs Guard ensures that inferior bpdus are blocked, allowing STP to shut an access port in this regard.

8 0
3 years ago
What date does GTA 6 come out<br> A. 2020<br> B. 2019<br> C. 2021<br> D. 2022
timofeeve [1]

it is a okkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk

7 0
2 years ago
Read 2 more answers
The function below takes two numeric parameters. The first parameter specifies the number of hours a person worked and the secon
Triss [41]

Answer:

def calculate_pay(total_worked_hours, rate_per_hour):

   if total_worked_hours > 40:

       return (40 * rate_per_hour) + ((total_worked_hours - 40) * 2 * rate_per_hour)

   else:

       return total_worked_hours * rate_per_hour

Explanation:

  • Create the calculate_pay function that takes 2 parameters.
  • Inside the function check whether the total_worked_hours is greater than 40 and then return the pay by calculating with the help of formula for work over 40 hours.
  • Otherwise return the pay by multiplying the total_worked_hours with rate_per_hour.
6 0
3 years ago
Write a public static method called getPIDs that has a parameter of type Map called nameToPID (keys are student names and values
Rasek [7]

Answer:

Java program is explained below

Explanation:

import java.util.HashSet;

import java.util.Map;

import java.util.TreeMap;

public class TruckRace1 {

   public static HashSet<String> getPIDs (Map<String,String>nameToPID ){

       HashSet<String> pidSet = new HashSet<>();

       for(String ids: nameToPID.values()){

           pidSet.add(ids);

       }

       return pidSet;

   }

   public static void main(String[] args) {

       Map<String,String> pids = new TreeMap<>();

       pids.put("John","123");

       pids.put("Jason","124");

       pids.put("Peter","125");

       pids.put("Alice","126");

       pids.put("Peny","129");

       HashSet<String> ids = getPIDs(pids);

       for(String id:ids){

           System.out.println(id);

       }

   }

}

4 0
3 years ago
What is a butt cap? (0.5 points)
777dan777 [17]

Answer:

Butt cap chops off the stroke at the end.

Explanation:

Stroke end are called caps, other parts of a stroke are joins and dashes. There are three types of caps used in Computer graphics design, they are;

Butt cap, round cap and projecting cap.

5 0
2 years ago
Other questions:
  • Write a program that calls fork(). Before calling fork(), have the main process access a variable (e.g., x) and set its value to
    5·1 answer
  • The instruction set for a microprocessor is unique and is typically understood only by the microprocessors of the same brand.
    7·1 answer
  • 1.
    5·2 answers
  • Name the component used in first generation of computer​
    10·1 answer
  • A system that monitors network use for potential hacking attempts and takes preventative action to block, isolate, or identify a
    11·1 answer
  • What are the pros and cons of editorial anonymity in Wikipedia
    10·2 answers
  • True or false that computers that are joined together are able to share hardware and software, but not data
    11·1 answer
  • Heres the last questions
    5·1 answer
  • What is the function of a breadcrumb trail in a website?
    13·1 answer
  • Five plus six is equal to?​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!