how a single linked list can be sorted by swapping the pointers??
Gunjan Rathi 0
Newbie Poster
Recommended Answers
Jump to PostHave you looked at std::sort? It accepts a custom comparator.
Jump to PostThe link in my post is a reference article.
Jump to Postc is not cplusplus, so std::sort might not be suitable. /* to swap data d of two nodes in principle: */ if(p->d > q->d){ t=p->d; p->d=q->d; q->d=t; }
All 10 Replies
Gunjan Rathi 0
Newbie Poster
tinstaafl 1,176
Posting Maven
rubberman
commented:
I'd agree if this were a C++ question, but it isn't. See my reply below. +12
Gunjan Rathi 0
Newbie Poster
tinstaafl 1,176
Posting Maven
1stDAN
Gunjan_1 0
Newbie Poster
deceptikon 1,790
Code Sniper Team Colleague Featured Poster
Gunjan_1 0
Newbie Poster
rubberman 1,355
Nearly a Posting Virtuoso Featured Poster
deceptikon 1,790
Code Sniper Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.