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
Answer im timed i'll mark brainliest
NNADVOKAT [17]

Answer:

The answer is shapes.

Explanation:

5 0
3 years ago
To construct a battery with a current of 6 A, you would connect six 1 A cells
m_a_m_a [10]
A. in parallel.,<span>D. in series.</span>
6 0
3 years ago
Read 2 more answers
How does a computer find a home group and join it
dezoksy [38]

Answer:

pen the Start menu, do a search for HomeGroup and press Enter.

Click the Join now button. ...

Click Next.

Select the content you want to share on the network by using the drop down menu for each folder and click Next.

Enter your HomeGroup password and click Next.

Explanation:

hope this helps if not ask me :);):):):)

6 0
3 years ago
Discuss the major procedures that investigators must use in order to collect network trace evidence of computer-related crimes.
frez [133]

Answer:

The answer is below

Explanation:

The major procedures that investigators must use to collect network trace evidence of computer-related crimes include the following:

1. Establish appropriate guidelines to follow: before starting the actual investigation, all the legal procedures and instructions to follow must be clearly stated and shown to everybody involved in the investigation process.

2. Assess the Evidence: the investigators must assess all the available evidence by checking the computer through a specific means. The assessment includes checking of hard drives, email accounts, social networking sites, or similar digital prints that can be used as proof of the criminal activities

3. Acquire the Evidence: here the investigators must find an appropriate means of gathering the evidence formally and legally. This may involve the removal of any form of hardware such as hard drives, and software-related items that can be extracted.

4. Examine the Evidence: this involved examination of the acquired evidence, to determine if it can be used as proof or not. This involved analyzing the evidence to check if they correlate with the criminal activities under investigation. Some of the things to check include, date of formation of the evidence, the names attached to it, the routes those data were sent or received from, etc.

5. Prepare a report and document them appropriately: this involved the proper detailing and recording of the information derived from the evidence. It includes the time of evidence examination and methods used in examining them. Also, the means at which they acquired the evidence among others.

8 0
3 years ago
Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will rea
irinina [24]

Answer:

Check the explanation

Explanation:

Executable Code:

def all_permutations(permList, nameList):

   # Define the function to create a list

   # of all the permutations.

   def createPermutationsList(nameList):

       # Compute and store the length of the list.

       n = len(nameList)

       # Return an empty list if the size is 0.

       if n == 0:

           return []

       # Return the element if the size is 1.

       if n == 1:

           return [nameList]

       # Create an empty list to store the permutations.

       permList = []

       # Start the loop to traverse the list.

       for i in range(n):

           # Store the first element of the current list.

           first = nameList[i]

           # Compute the store the remaining list.

           remaining = nameList[:i] + nameList[i+1:]

           # Start the loop and call the function recursively

           # with the remaining list.

           for perm in createPermutationsList(remaining):

               # Append the element in the permutation list.

               permList.append([first] + perm)

       # Return the permutation list.

       return permList

   # Call the function to compute the permutation list

   # and store the result.

   permList = createPermutationsList(nameList)

   # Start the loop to display the values.

   for perm in permList:

       for val in perm:

           print(val, end = " ")

       print()

# Call the main() function.

if __name__ == "__main__":

   # Prompt the user to enter the input.

   nameList = input().split(' ')

   permList = []

   # Call the function to create and output

   # the permutations of the list.

   all_permutations(permList, nameList)

#endcode

3 0
3 years ago
Other questions:
  • Pleas help with this question: Which statement about word processing software is true?
    15·1 answer
  • Your computer running Windows 7 is doing some very strange things with the operating system. You are fairly certain it is not a
    10·1 answer
  • In the relocatable dynamic partitions scheme, the Memory Manager relocates programs to gather together all of the empty blocks a
    9·1 answer
  • A web application starts when a client sends _______ to a server?
    13·1 answer
  • Graphic Designer A says that a halftone is an image created from a photograph and is comprised of a
    8·2 answers
  • ____ allows you to add formatting such as shapes and colors to text
    8·1 answer
  • In 5-10 sentences, describe the procedure for responding to an e-mail message.
    5·1 answer
  • Match each operating system drawback to its respective operating system.
    15·2 answers
  • What is humanity’s greatest invention?
    13·1 answer
  • True or False: Once you rename a field, the new field name must be used in the rest of the search string.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!