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
kolbaska11 [484]
3 years ago
15

Write a function in Java that takes in the int[] array, sorts it using bubble sort, then returns back the sorted array. Examples

:
Computers and Technology
1 answer:
Vlad1618 [11]3 years ago
6 0

Answer:

static int [] bubbleSort(int[] arr) {  

       int n = arr.length;  

       int temp = 0;  

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

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

                         if(arr[j-1] > arr[j]){      

                                temp = arr[j-1];  

                                arr[j-1] = arr[j];  

                                arr[j] = temp;  

                       }      

                }  

        }

        return arr;  

   }  

Explanation:

Above function is written in java language in which it takes integer array then sorts it using bubble sort and return back the array. The function has return type int[] which is necessary for returning array of type integer. The variable n contains the size of array which is calculated through  array's length method which is built in. Above function sorts array in descending order if you want to sort it in ascending order just change the condition of in if branch from <em>"</em><em>if(</em><em>arr[j-1] > arr[j]</em><em>)</em><em>"</em> to <em>"</em><em>if(</em><em>arr[j-1] < arr[j]</em><em>)</em><em>"</em> means replace > sign with < sign .

You might be interested in
What is the role of a design tWhat is the role of a design tool in a Robotic Process Automation (RPA) solution?
marin [14]

Answer and Explanation:

Robotic Process Automation(RPA) are software tools that apply artificial intelligence(AI) technology to automate digital routine tasks for business executives. It mimics everyday tasks and automatically executes them for the user.

Design tools in RPA play the role of infusing the best design into RPA software, it works with the popular phrase "design thinking". Robotic process automation software are now in tune with the popular buzz of a user centered approach to design of RPA tools. This ideology focuses on deploying RPA software that appeals to users and are therefore market friendly.

4 0
3 years ago
A batholith is an example of a(n) _____ igneous rock (one of the two main igneous rock groups).
Naily [24]
A batholith is an intrusive igneous rock.
3 0
4 years ago
Read 2 more answers
What is the benifet of the manager feature
Masja [62]

Answer: Benefits managers administer an organization's employee benefits program, which may include retirement plans, leave policies, wellness programs, and insurance policies such as health, life, and disability.

Explanation:

8 0
3 years ago
Seth is considering advertising his business using paid search results.What do you think makes paid search advertising so effect
pychu [463]

You haven't given any statements to choose from, but I can explain why paid search results are effective.

Paid seach results market to consumers that are interested in the product or similar products. These consumers are more likely to buy the product, since they are searching for a similar term. Paid search results can reach many people in very little time, and their resulting marketing benefits are almost instantaneous.

5 0
3 years ago
Read 2 more answers
Today you turned on your computer after being on vacation for a week. You see spinning white dots on a black screen. You decide
inn [45]

Since after update of operating system patches the end user see dots in black screen, either end user has to restore operating system old back up if he or she has or boot the operating system in safe mode.

<u>Explanation:</u>

On safe mode end user can repair the operating system; in repair mode still operating system cannot repair the operating system on same safe mode uninstall patches or recent updates of operating system during vacation.

Still it is workstation or laptop or desktop is not restoring it normally better to format and reinstall the operating system.

6 0
4 years ago
Other questions:
  • Employers will check you out on social media sites like Facebook, MySpace, and Twitter.
    6·2 answers
  • You also learn in class that one kilobyte of computer memory will hold about 2/3 of a page of typical text (without formatting).
    6·1 answer
  • In fixed-width files, each record is on a separate line and the fields are separated by a special character.
    7·1 answer
  • We have a combinatorial logic function that can be decomposed into three steps each with the indicated delay with a resulting cl
    15·1 answer
  • You have a friend that says she is interested in going into web development. She is very knowledgeable in terms of technology an
    13·1 answer
  • Preserving confidentiality, integrity, and availability is a restatement of the concern over interruption, interception, modific
    11·1 answer
  • How much do high-end earners make as power plant operators? Type answer as numerical number.
    14·1 answer
  • Explain why interrupt times and dispatch delays must be limited to a hard real-time system?
    8·1 answer
  • Some operating systems add the command interpreter to the kernel .what will be the justification for this design principle?
    11·1 answer
  • Which addresses represent valid local loopback addresses? check all that apply.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!