By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

Insertion to a sorted list

P: n/a
I am trying out a program to insert an element to a sorted list(singly
linked list)without using the temporary variable.Is there a solution
for this problem?

Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"chai" <ch*********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am trying out a program to insert an element to a sorted list(singly
linked list)without using the temporary variable.Is there a solution
for this problem?


This group deals with standard C, not algorithms. If you have an algorithm
but have problems expressing it's in terms of C (your code isn't compiling
or working as per the algorithm), come here for the help. But if you need
the algorithm, this isn't the right group to ask for it.

Alex
Nov 15 '05 #2

P: n/a
"chai" <ch*********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am trying out a program to insert an element to a sorted list(singly
linked list)without using the temporary variable.Is there a solution
for this problem?


Not a problem. No temporary variable is required. What did your teacher
say to make you think there was one? Maybe you could stay after class
and ask, or make a friend who can help.

--
Mabden
Nov 15 '05 #3

P: n/a
"chai" <ch*********@yahoo.com> wrote in news:1128681085.215861.272570
@z14g2000cwz.googlegroups.com:

I am trying out a program to insert an element to a sorted list(singly
linked list)without using the temporary variable.Is there a solution
for this problem?


I presume you mean you don't want to walk a pointer down the list looking
for the correct spot to insert.

One way would be to write a recursive insert function. Call it with a
pointer to the list, and have it call itself with the pointer to the next
node in the list until it finds the insertion point. (Not gonna write the
code for you, junior. But it ain't that hard.)

That would be a fucking stupid way to do it, though. A temporary pointer
requires a lot less memory and fewer CPU cycles.
Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.