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]
2 years ago
10

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

Computers and Technology
1 answer:
andrew11 [14]2 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
How do multi-cellular organisms develop?
FromTheMoon [43]
Letter B. is the answer
<span>B.  Cell differentiation - start from a single cell and as the cells divide they become specialized</span>

HOPE THIS HELPS















4 0
3 years ago
WHICH OF THE FOLLOWING RANGES OF CELLS IS CORRECTLY NAMED?
olganol [36]
The answer is (d.) A5:E5

In a worksheet, the cell is where you enter the information and the contents. It's an intersection of a row and a column in which column is identified by letters and numbers for row. Every cell has a name based on the column and row intersection. For example an intersection from column A and Row 5 is called A5. Cell range refer to a group of cells. They are named after the first and the last cell separated by a colon.
7 0
3 years ago
What is a secondary storage medium that uses magnetic techniques to store and retrieve data on disks or tapes coated with magnet
Elza [17]

Answer:

The correct answer to the following question will be "Magnetic medium".

Explanation:

Some storage device that portrays details or information using magnetic patterns is called a magnetic device.

  • Magnetic tape, and hard drives are the commonly used magnetic storage devices.
  • This will be the method by which magnetic methods are used to hold and retrieve information on tapes.

So, it's the right answer.

3 0
2 years ago
1.) A ____ is a piece of information.
alukav5142 [94]

Answer:

pasensya na Hindi ko alam Ang sasabihin

5 0
3 years ago
Why was the television the first audio visual device that changed the way people see entertainment?
Daniel [21]
It was  not.   Movies   then  talking movies  were   before television.

7 0
3 years ago
Other questions:
  • When you declare an array, _____________________ You always reserve memory for it in the same statement You might reserve memory
    9·1 answer
  • A hub transmits all incoming messages to all of its ports except the port where the messages came in. A switch usually sends mes
    14·2 answers
  • The benefit of host and guest operating system difference is:
    8·2 answers
  • 1. A database table can hold ??
    9·1 answer
  • Public class Main{ public static void main(String [] args){ String name=WelcomeJava; Runnable r1=() -&gt; System.out.println(nam
    12·1 answer
  • HELP ASAP !!! What should be a one-page document?
    7·1 answer
  • What is the key to satisfaction and success when choosing a career
    15·2 answers
  • The Python language uses a compiler which is a program that both translates and executes the instructions in a high-level langua
    15·1 answer
  • Question 12 (2 points)
    10·2 answers
  • A type of authentication that requires the user to provide something that they know, such
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!