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

  • Home
  • SEARCH
  • 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 6361337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:45:53+00:00 2026-05-24T23:45:53+00:00

In an online event, I have to complete a partially finished code. They use

  • 0

In an online event, I have to complete a partially finished code.
They use linklist data structure to store each element.The time complexity is O(n*n)
And in the outer (for) loop, the iteration is completed when node->next!= NULL (i.e. only n-1 checks).
Inner (for) loop, there are n checks until (ptr becomes NULL)

say, there are 5 elements.
And,
Elements in given order
5 ->3 ->1 ->2 ->4 ->NULL

Sort Cycles:

1 ->3 ->5 ->2 ->4 ->NULL

1 ->2 ->5 ->3 ->4 ->NULL

1 ->2 ->3 ->5 ->4 ->NULL

1 ->2 ->3 ->4 ->5 ->NULL

Elements in sorted order

1 ->2 ->3 ->4 ->5 ->NULL

Which sorting algorithm is used here?

  • 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-05-24T23:45:54+00:00Added an answer on May 24, 2026 at 11:45 pm

    This is an instance of selection sort. Notice that after iteration i, the first i elements of the list are now in sorted order, and that the element that was moved into the ith position is swapped with the element that used to be there. For example, here’s the change from the first iteration to the second:

    5 ->3 ->1 ->2 ->4 ->NULL
    1 ->3 ->5 ->2 ->4 ->NULL
    

    Notice that 1 (the smallest element) has been swapped to the front, but the rest of the elements are in the same order. Similarly, between the second and third iterations, you see this:

    1 ->3 ->5 ->2 ->4 ->NULL
    1 ->2 ->5 ->3 ->4 ->NULL
    

    Here, 2, the second-smallest element, is swapped to the second position, but the rest of the elements are in the same order.

    I’m not sure why they opted to use selection sort here. There are much better ways to sort a linked list.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a online Slide Show I'm working on using jQuery. I have use
Im about to create a very simple online event reservation application and currently have
I have the following code @EventHandler public void onPlayerQuit(PlayerQuitEvent event){ Player player = event.getPlayer();
Various online services have different values for maximum year of expiry, when it comes
Searching online, I have found the following routine for calculating the sign of a
I have a lightweight online shopping site based on JSP and XML, and I'm
I have built an online game system that depends on a timer that records
I'm making an online calendar. One will be able to create en event and
Background I am writing a simple online judge (a code grading system) using PHP
I have an application which makes calls to an online database. If I lose

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.