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 8724207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:46:46+00:00 2026-06-13T07:46:46+00:00

I am using C#, and I wanted to sort a linked list without using

  • 0

I am using C#, and I wanted to sort a linked list without using extra memory.

Input: listptr→ 11 → 8 → 2→ 4 → 5
Output: listptr→ 2 → 4 → 5 → 8 → 11

This is my class:

public class SNode
{
    public int data;
    public SNode next;
}

Should I create a new temp variable to store the temp list?

Like SNode temp = new SNode(2,NULL);?

This is a homework assignment.

  • 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-13T07:46:47+00:00Added an answer on June 13, 2026 at 7:46 am

    I should think the point of the exercise is to sort the list in place without creating a copy of the whole thing (so you can presumably use a small amount of memory in the form of variables to help with the sort).

    The easiest way to code it is probably to use a bubble sort (although this is horribly inefficient for large lists). The trick is to use a variable to keep track of the node before the current pair, since you will have to adjust its next if you need to swap the order of the nodes in the pair.

    As others have pointed out, in a real project you would use the .NET framework to do the heavy lifting for you, but I guess this is a theoretical exercise in pointer manipulation so you’re supposed to code it all for yourself.

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

Sidebar

Related Questions

I wanted to generate a list view using below code. But after running this
Just for fun, I implemented my own stack, but, without using a linked list,
without using a database i wanted a file to point to the newest revision
I am trying to sort a vector below using boost::phoenix library. The class Foo
I'm trying to create a sort of factory class in a template. I wanted
I'm currently using PlayerCommandPreprocessEvent . I use syntax like this: @EventHandler(priority = EventPriority.HIGHEST) public
I am using this command: cut -d: -f2 To sort and reedit text, Is
In the example below, if client code using GetPeople wanted to print the name
I have just started using flexigrid and wanted to use the resource string to
I wanted to implement python com server using win32com extensions. Then consume the server

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.