473,657 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pls guide me to write a program in c sort a linked list using selection sort

5 New Member
pls help me to write a program in c that reads n elements of type float, stores them in a linked list ,sort it in the descending order using selection sort methods, and finally output the sorted linear linked list
Sep 5 '06 #1
4 5863
Banfa
9,065 Recognized Expert Moderator Expert
You write it and we'll help you debug it.
Sep 5 '06 #2
pukur123
61 New Member
Just write the code using following steps:

1. Start two loops.
2. In the outer loop access all the nodes except the last node.
3. in the inner loop access all nodes the nodes from the node following the node pointed by the variable in the outer loop
4. then check the values and accordingly swap the nodes.
5. go to the next node in the inner loop
6. go to the next node in the outer loop
Sep 6 '06 #3
Rakesh Mutharaju
14 New Member
Just write the code using following steps:

1. Start two loops.
2. In the outer loop access all the nodes except the last node.
3. in the inner loop access all nodes the nodes from the node following the node pointed by the variable in the outer loop
4. then check the values and accordingly swap the nodes.
5. go to the next node in the inner loop
6. go to the next node in the outer loop

To add to this one more hint.,

PREVIOUS_NODE;
TEMP_NODE; //
TEMP_NODE->PTR = NEXT_NODE->PTR;
if(CURRENT_NODE->VALUE < NEXT_NODE->VALUE)
{
NEXT_NODE->PTR = PREVIOUS_NODE->PTR;
PREVIOUS_NODE->PTR = CURRENT_NODE->PTR;
CURRENT_NODE->PTR = TEMP_NODE->PTR ;
}




ALL the 4 TEMP_NODE,PREVI OUS_NODE,CURREN T_NODE,NEXT_NOD E belong to the same linked list and the rest is just traversal and looping.
Sep 7 '06 #4
duaa
1 New Member
i need shell,selection ,inseration,bub ble sorting in linked list please
Nov 27 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
15120
by: Kent | last post by:
Hi! I want to store data (of enemys in a game) as a linked list, each node will look something like the following: struct node { double x,y; // x and y position coordinates struct enemy *enemydata; // Holds information about an enemy (in a game) // Its a double linked list node
1
12834
by: Booser | last post by:
// Merge sort using circular linked list // By Jason Hall <booser108@yahoo.com> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <math.h> //#define debug
3
2705
by: chellappa | last post by:
hi this simple sorting , but it not running...please correect error for sorting using pointer or linked list sorting , i did value sorting in linkedlist please correct error #include<stdio.h> #include<stdlib.h> int main(void) {
6
16127
by: Julia | last post by:
I am trying to sort a linked list using insertion sort. I have seen a lot of ways to get around this problem but no time-efficient and space-efficient solution. This is what I have so far: struct node { int x; struct node *next; };
0
1419
by: Svenn Bjerkem | last post by:
Hi, Armed with Programming Python 3rd Edition and Learning Python 2nd edition I try to write an application which I at first thought was simple, at least until I was finished with the GUI and then wanted to start putting some data into it. As you will see, the program is not yet finished but I post what I have so far.
2
3500
by: pchahar | last post by:
Write a program to process a text file. The program will determine how many unique words there are in the text file that begin with each letter of the alphabet. The text file name will be given as a command line argument to the program. You will use an array of pointers to implement this program. There will be one pointer for each letter of the alphabet. The array will be indexed by each letter. To do so, subtract the ASCII value for ‘a’...
6
6953
by: Nick Valeontis | last post by:
I know how to use Icomparable. However, I can't figure out how to sort a generic linked list? (without writing the algorithm) Lets say I have something like this: class DisJunctiveConstraintList : LinkedList<DisjunctiveConstraint>
1
3366
by: Homeworkboy | last post by:
Can anyone help me with this program? Look at the bottom of this program for help methods: /*1. Make a program that uses numbers from 1 to 100 including each ends which puts the even integers in the front of a double linked queue and the odd numbers in the back. Then prints out the deque. 2. Make a new deque list 2 that contain integers from 51 to 100. Print that list out as mine looks. Sort that list in decending order then print...
4
5319
by: slapsh0t11 | last post by:
Hello! I need help with a program that I believe I am nearly done with. However, there seems to be a few details that preclude me from success. Here is my assignment: Here is my class file (Sorts.java): import java.util.*; /**
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.