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
. Why use a sensitivity analysis?
Natali [406]

Answer:

 Sensitivity analysis is the method in which it basically predict the final outcome of the decision. It analysis each variable individually and identify the dependency of the output value on the particular value of the input.  

The advantage of the sensitivity analysis is that it reduce the overall risk of the particular strategy and also impact of the system.

It basically work on the basic principle that firstly changed the structure and model and then observe the particular behavior of the model.

7 0
3 years ago
How is technology used in the voting process?
Semmy [17]
Each person has a electronic chip-enabled ID card, which lets them vote on the internet. The ID card is put into the card reader that is connected the computer. :)
7 0
3 years ago
How many bits are necessary for a binary representation (unsigned) of
Musya8 [376]
A. 5
b. as an unsigned int: 9. Normally a year is 365.25 days which would require 32-bits for an IEEE float.
c. 25
3 0
3 years ago
you have an ipv4 network that has two IPv6-only hosts that need to be able to communicate with each other. You want to implement
Soloha48 [4]

Answer:

Teredo tunnelling

Explanation:

The tunnelling method that will fit best in the situation is teredo tunnelling. The reason are embedded in its characteristics, they include;

Teredo tunneling has the following characteristics: Its tunnel endpoints are configured on hosts. The hosts are dual stack hosts and perform tunneling of ipv6 to send on the ipv4 network works through NAT the only solution that allows ipv4-only hosts to communicate with ipv6-only hosts is NAT-PT.

7 0
3 years ago
Which statement is NOT true regarding regular expression quantifiers? Group of answer choices They act on the preceding pattern
anzhelika [568]

Answer:

"The question mark quantifier "?" will match the preceding element exactly one time" is the correct answer to the given question .

Explanation:

The Quantifiers are defined as it determine how the several occurrences of a set of symbols, categories, or the characters should be found throughout the input to searching the matches.

  • The * quantifier in the regular expression corresponds the zero or more then zero to the previous item. it is represented by  {0,} quantifier
  • The + quantifier in the regular expression appears to fit in one or more times with the previous item. it equates with {1} quantifier.
  • The? Quantifier in regular expression compares zero or once of a previous item. It equates with {0,1}.
  • All the option are true regarding regular expression quantifiers so these option are incorrect according to the question
3 0
3 years ago
Other questions:
  • The strFirstName and strLastName variables contain the strings "Jane" and "Jones," respectively. Which of the following statemen
    14·1 answer
  • A matrix representation stores matrices such that the offset address of the element in row i and column j can be calculated by c
    12·1 answer
  • Why is the radial gradient type a good choice for the grapes?
    13·2 answers
  • A vehicle fails an HC emission test at idle and 2,500 rpm, and the engine has an acceleration stumble. The heated oxygen sensor
    15·1 answer
  • Consider the following skeletal C program: void fun1(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /*
    11·1 answer
  • Your employer is opening a new location, and the IT director has assigned you the task of calculating the subnet numbers for the
    14·1 answer
  • Which one of the following pieces of information would be allowed as part of a limited data set?
    15·1 answer
  • When installing the latest version of Internet Explorer, a dialogue box pops up with a box checked telling you that Bing will be
    15·1 answer
  • Joe a frequent visitor to a branch office attempts to connect his tablet to the office wireless network but is unable to connect
    14·1 answer
  • Can you answer this question?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!