lets says i have 5 elements in the linked list
3->1->4->2->7;
i want after calling sort method
its will become something like
1-->2->3->4->7
without the inseration code ..
only to fix it.
the given link list
iam thinking about it more then few hours but keep failing .
even tho i succseed doing some good codes to some given link list.(like deleting duplicate nodes in given link list , reverse link list , only even link list and so on)
but in this 1 i keep failing for hours.
if someone can guid me or share algorithm how to do it right
appricate very much.
Without seeing your code I can only guess at what there is to work with.I am not very good at psudo code, but the concept should work.
Create a function for the sort.A name other than "sort" would be best.
include the header files "algorithm" and "vector"
std::vector<int> vInt;
do
transverse linked list
vInt.emplace_back(variable_name_in_linked_list)
while (nextNode != nullptr)
std::sort(vInt.begin(), vInt.end)
for (size_t lp = 0; lp < vInt.size(); lp++) or another to transverse the linked list
transverse linked list
set variable_name_in_linked_list = vInt[lp]
Not knowing what your code is this is the simplest way I could think of. Another way would be to reshuffle the linked list nodes. If you have more variables in a node just add additional vectors.
I do not happen to have any program that uses a linked list right now, so I do not have any way to test this for now.