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
Elena-2011 [213]
2 years ago
11

Evaluating sorts given the following array: 41, 32, 5, 8, 7, 50, 11 show what the array looks like after the first swap of a bub

ble sort in a scending order.
Computers and Technology
1 answer:
irga5000 [103]2 years ago
8 0

The way that  the array will looks like after the first swap of a bubble sort in ascending order is   {5,32,41, 8,7,50,11}.

<h3>Who do you Write sort code in JAVA?</h3>

It will be:

class SSort

{

  void sort(int array[])

  {

      int n = array.length;

      for (int i = 0; i < 2; i++)

      {

          int minimum_index = i;

          for (int j = i+1; j < n; j++)

              if (array[j] < array[minimum_index])

                  minimum_index = j;

           int temp = array[minimum_index];

          array[minimum_index] = array[i];

          array[i] = temp;

      }

  }

   void printArray(int array[])

  {

      int n = array.length;

      for (int i=0; i<n; ++i)

          System.out.print(array[i]+" ");

      System.out.println();

  }

  public static void main(String args[])

  {

      SSort s = new SSort();

      int array[] = {41, 32, 5, 8, 7, 50, 11};

      s.sort(array);

      System.out.println("After first two iteration of Selection sort:");

      s.printArray(array);

  }

}

Therefore, The way that  the array will looks like after the first swap of a bubble sort in ascending order is   {5,32,41, 8,7,50,11}.

Learn more about array  from

brainly.com/question/26104158

#SPJ1

You might be interested in
How do films use camera shots?
lorasvet [3.4K]
These advanced camera shots, or angles, are used in film to convey an effect or emotion rather than exemplify a sense of space. Before filming, cinematographers will write out their shot list in order to plan how each scene of their film should be shot
7 0
2 years ago
Read 2 more answers
You are a network technician for a small network. Your ITAdmin workstation just stopped communicating with all other computers i
Lelu [443]

Answer:

Ping the other workstations from the IT Admin workstation to confirm that connection has been lost, check the status of the network interface card in the workstation with command ifconfig in the terminal, then reset the connection using ifdown and ifup commands. If the problem is not resolved, check the cable connection.

Explanation:

Ping is an ICMP echo message sent by a network host to another to check for connectivity. If they are connected, the other workstation responds with an ICMP response message.

The ifconfig in Linux systems displays the network adapters and their individual IP configurations. If there is no connection even after the network is reset, then the cable connectors could be the problem.

8 0
3 years ago
Write a program that calculates payments for loan system. Implement for both client and Server. - The client sends loan informat
egoroff_w [7]

Answer:

Check the explanation

Explanation:

//Define the class.

public class Loan implements java.io.Serializable {

 

//Define the variables.

private static final long serialVersionUID = 1L;

private double annualInterestRate;

private int numberOfYears;

private double loanAmount;

private java.util.Date loanDate;

//Define the default constructor.

public Loan() {

this(2.5, 1, 1000);

}

//Define the multi argument constructor.

protected Loan(double annualInterestRate, int numberOfYears,

double loanAmount) {

this.annualInterestRate = annualInterestRate;

this.numberOfYears = numberOfYears;

this.loanAmount = loanAmount;

loanDate = new java.util.Date();

}

//Define the getter and setter method.

public double getAnnualInterestRate() {

return annualInterestRate;

}

public void setAnnualInterestRate(double annualInterestRate) {

this.annualInterestRate = annualInterestRate;

}

public int getNumberOfYears() {

return numberOfYears;

}

public void setNumberOfYears(int numberOfYears) {

this.numberOfYears = numberOfYears;

}

public double getLoanAmount() {

return loanAmount;

}

public void setLoanAmount(double loanAmount) {

this.loanAmount = loanAmount;

}

//Define the method to compute the monthly payment.

public double getMonthlyPayment() {

double monthlyInterestRate = annualInterestRate / 1200;

double monthlyPayment = loanAmount * monthlyInterestRate / (1 -

(Math.pow(1 / (1 + monthlyInterestRate), numberOfYears * 12)));

return monthlyPayment;  

}

//Define the method to get the total payment.

public double getTotalPayment() {

double totalPayment = getMonthlyPayment() * numberOfYears * 12;

return totalPayment;  

}

public java.util.Date getLoanDate() {

return loanDate;

}

}

//Define the client class.

public class ClientLoan extends Application {

 

//Create the server object.

ServerLoan serverLoan;

 

//Declare the variables.

int y;

double r, a, mp=0, tp=0;

String result,d1;

 

//Create the button.

Button b = new Button("Submit");

 

//Define the method stage.

public void start(Stage primaryStage) throws Exception {

 

TimeZone.setDefault(TimeZone.getTimeZone("EST"));

TimeZone.getDefault();

d1 = "Server Started at " +new Date();

 

//Create the GUI.

Label l1=new Label("Annual Interest Rate");

Label l2 = new Label("Number Of Years:");

Label l3 = new Label("Loan Amount");

TextField t1=new TextField();

TextField t2=new TextField();

TextField t3=new TextField();

TextArea ta = new TextArea();

 

//Add the components in the gridpane.

GridPane root = new GridPane();

root.addRow(0, l1, t1);

root.addRow(1, l2, t2, b);

root.addRow(5,l3, t3);

root.addRow(6, ta);

 

//Add gridpane and text area to vbox.

VBox vb = new VBox(root, ta);

 

//Add vbox to the scene.

Scene scene=new Scene(vb,400,250);

 

//Add button click event.

b.setOnAction(value -> {

 

//Get the user input from the text field.

r = Double.parseDouble(t1.getText());

y = Integer.parseInt(t2.getText());

a = Double.parseDouble(t3.getText());

 

//Create the loan class object.

Loan obj = new Loan(r, y, a);

 

//Call the method to compute the results.

mp = obj.getMonthlyPayment();

tp = obj.getTotalPayment();

 

//Format the results.

result = "Annual Interest Rate: "+ r+"\n"+

"Number of Years: "+y+"\n"+

"Loan Amount: "+a+"\n"+

"monthlyPayment: "+mp+"\n"+

"totalPayment: "+tp;

 

//Add the result to the textarea.

ta.setText(result);

 

//Create an object of the server class.

serverLoan = new ServerLoan(this);

});

 

//Set the scene to the stage.

//Set the stage title.

//Make the scene visible.

primaryStage.setScene(scene);

primaryStage.setTitle("ClientLoan");

primaryStage.show();

}

 

//Define the main method lauch the application.

public static void main(String args[])

{  

launch(args);

}

 

//Define the server class.

class ServerLoan extends Stage {

 

//Create the client loan object.

ClientLoan parent;

 

//Create the stage object.

Stage subStage;

 

//Create the text area.

TextArea ta = new TextArea();

 

//Define the constructor.

private ServerLoan(ClientLoan aThis) {

 

//Get the time in desired timezone.

TimeZone.setDefault(TimeZone.getTimeZone("EST"));

TimeZone.getDefault();

 

//Format the date with message.

String d2 = "Connected to client at " +new Date();

 

//Initialize the object.

parent = aThis;

 

//Add the date and the result to

//the text area.

ta.setText(d1);

ta.appendText("\n"+ d2);

ta.appendText("\n"+result);

 

//Create the grouppane.

GridPane root = new GridPane();

 

//Add text area to the group pane.

root.addRow(0, ta);

 

//Initialise the stage object.

subStage = new Stage();

 

//Add gridpane to the scene.

Scene scene = new Scene(root, 400, 200);

 

//Set the scene to the stage.

//Set the stage title.

//Make the scene visible.

subStage.setScene(scene);

subStage.setTitle("ServerLoan");

subStage.show();

}

}

}

Kindly check the Output in the attached image below.

4 0
3 years ago
Read 2 more answers
Write a loop that inputs words until the user enters STOP. After each input, the program should number each entry and print in t
scoray [572]

Answer:

oh wowwwwwwwww

Explanation:

7 0
2 years ago
Read 2 more answers
Select the correct answer.
Naya [18.7K]

Answer:

The correct answer is: Option OD: function

Explanation:

Many programming languages use functions to make the coding simple and easy to understand. A function is like a small unit that takes input in the form of arguments or parameters, does the processing on the input and returns the output.

Hence,

The correct answer is: Option OD: function

6 0
2 years ago
Other questions:
  • Assign to avg_owls the average owls per zoo. Print avg_owls as an integer. Sample output for inputs: 1 2 4 3
    7·1 answer
  • What does the Autosum feature on excel do?
    15·1 answer
  • Which payment type is best if you are trying to sick to a budget?
    15·1 answer
  • 2. What are the pros and cons of Toyota structure?
    13·1 answer
  • Can anyone help me with getting bash ubuntu on windows setup?
    15·1 answer
  • When a business is using methods that help it use its time and resources the best they can, what are they exercising?
    11·2 answers
  • Bert started off his working life as a typesetter for a print house. With the advent of new technologies, Bert's job became redu
    6·1 answer
  • Which feature allows users to see all suggestions for edits to a document at once?
    7·2 answers
  • So wait how do i comment on someone's answer because that would be useful ,,.
    9·2 answers
  • Which sequence represents the hierarchy of terms, from smallest to greatest?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!