Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7737007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:53:21+00:00 2026-06-01T07:53:21+00:00

I had a question on a test – I got it wrong, but I

  • 0

I had a question on a test – I got it wrong, but I don’t know why?

Question: An array of integers is to be sorted from biggest to smallest using an insertion sort. Assume the array originally contains the following elements:

5 9 17 12 2 14

What will it look like after the third pass through the for loop?

17 9 5 12 2 14

17 12 9 5 2 14 – Correct answer

17 12 9 5 14 2

17 14 12 9 5 2

9 5 17 12 2 14

In an insertion sort, I thought the source array is untouched; I felt, at the third pass, the destination array would be incomplete.

How did the test arrive at this answer?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:53:22+00:00Added an answer on June 1, 2026 at 7:53 am

    Basically, after n passes of insertion sort, the first n+1 elements are sorted in the correct order and the rest are untouched. As you can see in the alternatives, the correct answer is the only one that fulfills that. Every step is only inserting relative to the already sorted numbers, so each step one extra number is correctly sorted.

    Step 0 (Original, 5 assumed sorted)

    5 9 17 12 2 14
    

    Step 1, takes the 9 and puts it in the correct place before 5 (result, 9 5 sorted)

    9 5 17 12 2 14
    

    Step 2, takes the 17 and puts it in the correct place before 9 (result 17 9 5 sorted)

    17 9 5 12 2 14
    

    Step 3, takes the 12 and puts it in the correct place after 17 and before 9 (result 17 12 9 5sorted)

    17 12 9 5 2 14
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had a general question about extracting code from a visual studio web test.
I had the following question in a test today. But i had not see
I've had a test, and there was a question I lost some points on,
i had a question in my program. When I pass the 3D int array
EDIT: it turned out this question had been asked the wrong way — see
I've been using SO for a long time but finally had a question I
I had this question on an Algorithms test yesterday, and I can't figure out
I had no luck with this question so I've produced this simple-as-possible-test-case to demonstrate
Kind of a special question today :) I just had a test at my
I recently had this question in an interview to write test cases to test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.