LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-26-2005, 03:39 AM   #1
vijeesh_ep
Member
 
Registered: Jul 2004
Location: India
Distribution: Redhat-8
Posts: 35

Rep: Reputation: 15
Unhappy link list reversl program


hai
I am trying to develop a sigle link list reversl program in c .I want to do it like this

1)the function takes the address of the head node as the argument
2)it can use only one temp variable.
3)it must not use recursion
4)it must return the new address of the head node;

is there any chance of doing this?.plz guide me

Last edited by vijeesh_ep; 02-26-2005 at 05:35 AM.
 
Old 02-26-2005, 06:13 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
and the chance of this even slightly not being homework from school / college is....?

please do not ask for solutions for work set as part of an educational program. if you have been paying attention and read the sources you should have been, you should have no problem in completing work set for you.
 
Old 02-26-2005, 08:06 PM   #3
skoona
Member
 
Registered: Mar 2004
Location: Indiana, USA
Distribution: Fedora, CentOS, Ubuntu, OS/X, Raspbian
Posts: 90

Rep: Reputation: 18
Re: link list reversl program

Quote:
Originally posted by vijeesh_ep
hai
I am trying to develop a sigle link list reversl program in c .I want to do it like this

1)the function takes the address of the head node as the argument
2)it can use only one temp variable.
3)it must not use recursion
4)it must return the new address of the head node;

is there any chance of doing this?.plz guide me
GLIB already does this. If you already have 'devhelp' on your system look at the glib reference manual for glib data types. "$yum install devhelp" will install this documentation tool for you. Or you can follow this link to learn more about glib's linked list support.

http://developer.gimp.org/api/2.0/gl...ata-types.html

They really have already figured it out.
 
Old 02-27-2005, 12:17 AM   #4
95se
Member
 
Registered: Apr 2002
Location: Windsor, ON, CA
Distribution: Ubuntu
Posts: 740

Rep: Reputation: 32
Think about it, a list like this:
a -> b -> c -> d
reversed is just
d -> c -> b -> a
i.e. every element just points to the element that was previously before it. This problem becomes very trivial if as you go through your list you just remember the previous element.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
concepts a linked list program in c ssg14j Programming 4 08-19-2005 10:10 AM
How to rm a list of files returned from another program? neo_in_matrix Linux - Newbie 2 04-12-2005 11:24 PM
What is Cursor implementation of Link List ? indian Programming 0 11-26-2004 10:54 AM
Help!How can I get the file name list in C program? wuzhong Programming 6 09-22-2004 11:56 AM
Simple link list problem karlan Programming 4 01-22-2004 01:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration