Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NEED HELP WITH THIS CODE. PLEASE IF POSSIBLE ATTACH A PICTURE OF THE RUNNING CODE. Use C ++ to write a program. Where you can

NEED HELP WITH THIS CODE. PLEASE IF POSSIBLE ATTACH A PICTURE OF THE RUNNING CODE.

Use C ++ to write a program. Where you can use a statically-allocated one-dimensional array of doubles for this with length 100. You will never have more than 100 things to sort, but you may have fewer. Your program will have to keep track of how many elements you actually use.Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program.The way linear insertion works is this:

  1. If the list is empty, the number goes in the first array element.
  2. If the list is not empty, search to find the two elements where the top one is smaller than the one you have and the bottom one is larger (assuming an ascending-order sort.) This is your insertion point. Then move everything below and including the insertion point down in the array. Put the new element in.
  3. Increment the count of elements in the array

Once the list is sorted, print it.

Go back and ask for another file name.

For example, if the file contains 6, 3, 7, and 2 your array would look like this at each step:

Step 1: Array is empty, so insert the 6.

6

Step 2: Move the 6 down, insert the 3

3

6

Step 3: Put the 7 at the end; nothing moves

3

6

7

Step 4: Move the 3, 6, and 7 down, then insert the 2.

2

3

6

7

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. See your material from your readers point of view.

Answered: 1 week ago

Question

Acceptance of the key role of people in this process of adaptation.

Answered: 1 week ago

Question

preference for well defined job functions;

Answered: 1 week ago