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

Write a C++ program that usesInsertion Sort to sort an unsorted list of numbers.

Computers and Technology
1 answer:
andrew11 [14]3 years ago
5 0

<u>C++ program - Insertion sort</u>

<u></u>

#include <bits/stdc++.h>  

using namespace std;  

/* Defining function for sorting numbers*/

void insertionSort(int array[], int n)  

{  

   int i, k, a;  

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

           {

              k=array[i];

               a=i-1;

            while(a>=0 && array[a] > k) // moving elements of array[0 to i-1] are greater than k, to one position //

                      {

                       array[a+1] = array[a];

                        a =a-1;

                      }

              array[a+1] =k;

             }  

}              

/* Driver function */

int main()  

{  

   int array[] = { 12,56,76,43,21};   //input integers

   int n = sizeof(array) / sizeof(array[0]);   //finding size of array

 

   insertionSort(array, n);   //Calling function

    for (int i = 0; i < n; i++)   //printing sorted array

        cout << array[i] << " ";  

    cout << endl;  

    return 0;  

}  

You might be interested in
Which of the following are examples of the concept of layered access in physical security? Select one: a. Firewall, IDS, CCTV b.
Tpy6a [65]

Answer:

b. Fences, gates, monitored doors

Explanation:

The best defense is a good defense. A good security system is reliable and will provide you with a criminal-deterrent protection, detect intrusions, and trigger appropriate incident responses. It involves the use of multiple layers  of interdependent systems like protective guards, locks, protective barriers, fences, and many other techniques.

4 0
3 years ago
Read 2 more answers
What is 14.10 to the tenth power​
nataly862011 [7]

what i remeber is that when your trying to figure out to the tenth power u have to multiply it like for example:3^{2}power would be 9 because u had to multiply 3, 2 times so i think the answer is 310,592,615,939.35/310,592,615,939.4

3 0
3 years ago
I’ll mark brainliest if correct
aliya0001 [1]

Answer:

I believe the answer is B

Explanation:

5 0
3 years ago
The beginning statement of a loop is called a declaration.<br> True<br> False
Ilya [14]
It is true the reason why it is true is
4 0
3 years ago
Read 2 more answers
5 of 10
DaniilM [7]

Answer:

what

Explanation:

3 0
3 years ago
Other questions:
  • Which type of system must you connect to and use to make changes to Active Directory?
    15·1 answer
  • In one to two sentences, explain why citizens pay taxes
    8·1 answer
  • ____________ is a script or a tool that obtains privileges of a root
    8·1 answer
  • Suppose the fixed width of an aside element in a fixed layout is 300 pixels, and the fixed width of its parent element (body) is
    15·1 answer
  • Which of the following languages does not provide built-in-pattern matching operations (the language, although, has pattern matc
    14·1 answer
  • PLEASE HELP!
    14·2 answers
  • What will the following code display? int numbers[4] = { 99, 87 }; cout &lt;&lt; numbers[3] &lt;&lt; endl; a. 87 b.0 d. 34. What
    12·1 answer
  • Which tab should a user click to access the Page Borders feature of Word?
    13·2 answers
  • The optical phenomenon that allows us to view rapidly changing still images as moving images is called _______.
    15·2 answers
  • Please help me please please
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!