
saru
Novice
Oct 30, 2013, 1:38 AM
Post #3 of 5
(20537 views)
|
Re: [Chris Charley] bubble sort ??
[In reply to]
|
Can't Post
|
|
Dear Chris, Thanks for your reply. i am really happy and looking forwad to further help.But still i didn't get what my examiner wants, I am posting the my task where i have to complete it with perl command and explain it what i did on it...:(, he asked like this: complete the function myBubbleSort, which should implement the bubble sort algorithm. my- BubbleSort has the reference to the array, that should be sorted, as a parameter (consider the calls to myBubbleSort in the prepared perl script). The sorting algorithm should directly be applied to the array to be sorted (in-place = only constant amount of memory needed for sorting, no new array allocated). If you have finished, execute the prepared script, look whether your algorithm find the same sorting order as perlSort1 and try to find and explaination for the result of perlSort2. use strict; use warnings; sub myBubbleSort { my $refToSortList=$_[0]; ####Complete } my @testList = (254324, 213, 2345, 6524, 3475, 81451, 1141); my @perlSort = sort { $a <=> $b } @testList; myBubbleSort(\@testList); print "\n\n\n"; print "myBubbleSort: ", join(" ", @testList), "\n"; print "perlSort1: ", join(" ", @perlSort), "\n"; #####Explain the output: print "perlSort2: ", join(" ", sort(@testList)), "\n"; print "\n\n\n";
(This post was edited by aakashgh on Oct 30, 2013, 1:44 AM)
|