On 10/15/07, Dr.Ruud <[EMAIL PROTECTED]> wrote:
snip
> > or the old chestnut:
> >
> > $array[0] ^= $array[1]
> > $array[1] ^= $array[0]
> > $array[0] ^= $array[1]
> >
> > Which even works on strings (but not references) in Perl.
>
> With strings not without length-issues:
snip
Thats what I get for
"Chas. Owens" schreef:
> Dr.Ruud:
>> Jeff Pang:
>>> my $tmp = $array[$_];
>>> $array[$_] = $array[$_+1];
>>> $array[$_+1] = $tmp;
>>
>> Alternative without a $tmp:
>>
>> @array[$_, $_+1] = @array[$_+1, $_];
>>
>> (but actually it has 2 $tmp's)
>
> or the old c
On 10/13/07, Dr.Ruud <[EMAIL PROTECTED]> wrote:
> "Jeff Pang" schreef:
>
> > my $tmp = $array[$_];
> > $array[$_] = $array[$_+1];
> > $array[$_+1] = $tmp;
>
> Alternative without a $tmp:
>
> @array[$_, $_+1] = @array[$_+1, $_];
>
> (but actually it has 2 $tmp's)
sn
"Jeff Pang" schreef:
> my $tmp = $array[$_];
> $array[$_] = $array[$_+1];
> $array[$_+1] = $tmp;
Alternative without a $tmp:
@array[$_, $_+1] = @array[$_+1, $_];
(but actually it has 2 $tmp's)
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-m
On Oct 10, 1:51 pm, [EMAIL PROTECTED] (Tom Phoenix) wrote:
> On 10/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > I'm having problems trying to figure out 'bubble sort'. I'm working on
> > assignment for a class
>
> Well, that *is* th
2007/10/12, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Here is what I had so far. I'm not sure exactly what I'm doing wrong.
>
> !/usr/bin/perl
>
> @array = (5,3,2,1,4);
> @tmp_array;
>
> $i = 0;
> while($i <= 5){
>if ($array[$i] > $array[$i+1]);
> }
>while ($i > 2) {
>print "$tmp_arra
On Oct 10, 1:57 pm, [EMAIL PROTECTED] (Rob Dixon) wrote:
> [EMAIL PROTECTED] wrote:
>
> > I'm having problems trying to figure out 'bubble sort'. I'm working on
> > assignment for a class and I have to do the following:
>
> > Use the foll
On Oct 9, 6:06 pm, [EMAIL PROTECTED] ([EMAIL PROTECTED]) wrote:
> I'm having problems trying to figure out 'bubble sort'.
http://en.wikipedia.org/wiki/Bubble_sort
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
--
To u
;m having problems trying to figure out 'bubble sort'. I'm working on
> assignment for a class and I have to do the following:
>
> Use the following code as a starting point for the next lab.
>
> #!/usr/bin/perl
>
> @array = (5,3,2,1,4);
>
> ## include yo
[EMAIL PROTECTED] wrote:
I'm having problems trying to figure out 'bubble sort'. I'm working on
assignment for a class and I have to do the following:
Use the following code as a starting point for the next lab.
#!/usr/bin/perl
@array = (5,3,2,1,4);
## include your c
On 10/9/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I'm having problems trying to figure out 'bubble sort'. I'm working on
> assignment for a class
Well, that *is* the only valid reason to code bubble sort in Perl, I
must admit. I hope you're in a cl
I'm having problems trying to figure out 'bubble sort'. I'm working on
assignment for a class and I have to do the following:
Use the following code as a starting point for the next lab.
#!/usr/bin/perl
@array = (5,3,2,1,4);
## include your code here ##
foreach $elem (@ar
On Thu, Nov 15, 2001 at 05:22:26PM -0800, Curtis Poe wrote:
> --- Sidharth Malhotra <[EMAIL PROTECTED]> wrote:
> > While were on this, I'm taking an intro to Data Structures class and
> > were learning all about the different sorting methods ... Insertsort,
> > mergesort etc. What kind of sorting
On Nov 16, Pete Emerson said:
>Multidimensional syntax $table[substr $_, $i, 1] not supported at ./sort3.pl line 31.
That's bizarre.
$table[substr($_, $i, 1)]
might fix that.
>and when I turn on strict:
Gah. I've got working code on PerlMonks.org, with the name "IP Address
Sorting".
--
Okay, so I'm trying to implement your radix sort, and something's going wrong.
When I turn on warnings (I'm using Perl v5.6.0) I get:
Multidimensional syntax $table[substr $_, $i, 1] not supported at ./sort3.pl line 31.
and when I turn on strict:
Can't use an undefined value as an ARRAY reference
Pete Emerson wrote:
>
> Dave Storrs wrote:
>
> > Hmmm...this is interesting. A friend of mine who is in the
> > process of getting her graduate degree in CS/information theory stuff
> > recently told me that it has been mathematically proven that no sort can
> > run faster than O(n log
Dave Storrs wrote:
> Hmmm...this is interesting. A friend of mine who is in the
> process of getting her graduate degree in CS/information theory stuff
> recently told me that it has been mathematically proven that no sort can
> run faster than O(n log n) unless you know something about
On Fri, 16 Nov 2001, Pete Emerson wrote:
> I got this from http://www.wikipedia.com/wiki/Radix_sort:
>
> QUOTE
> Radix sort is a sort algorithm that operates in O(n) time. This algorithm was
> orignally
> used to sort punched cards in several passes. It has resurfaced as an
> alternative to
> o
Jeff 'japhy' Pinyan wrote:
> Ooh, radix sort. This is a cool technique, but it has a drawback: it
> always runs in the same time. Sorting sorted data takes as long as
> sorting UNsorted data. (Or sordid data!)
I love the implementation, gotta examine it closely and your example by hand
with
Jeff 'Japhy' Pinyan wrote:
>
> Bubble sort is a naive sorting algorithm. It's called "bubble" sort
> because the larger elements "rise" to the "top" of the list, like a bubble
dang, that's the best explanation i've seen.
On Nov 16, Pete Emerson said:
>Since we're on the topic of sorts, what are the arguments for
>the implemented quicksort vs. a radix sort?
(Perl now uses some mergesort hybrid.)
Ooh, radix sort. This is a cool technique, but it has a drawback: it
always runs in the same time. Sorting sorted d
Since we're on the topic of sorts, what are the arguments for
the implemented quicksort vs. a radix sort?
Pete
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Andrea Holstein wrote:
>
> "John W. Krahn" wrote:
>
> > That looks like a direct translation of algorithm 5.2.2B from TAoCP Vol.
> > 3 however the usual implementation is more like Sedgewick's example:
> >
> > sub bubble {
> > my $a = shift;
> >
> > for ( my $i = @$a; $i >= 1; $i-- ) {
>
"John W. Krahn" wrote:
> That looks like a direct translation of algorithm 5.2.2B from TAoCP Vol.
> 3 however the usual implementation is more like Sedgewick's example:
>
> sub bubble {
> my $a = shift;
>
> for ( my $i = @$a; $i >= 1; $i-- ) {
> for ( my $j = 2; $j <= $i; $j++ )
Jeff 'Japhy' Pinyan wrote:
>
> (Cross-posted to the Perl Beginners List)
>
> On Nov 15, Tommy Butler said:
>
> >What's a "bubble sort" ? I believe I heard the term used on this list a
> >while back. I have some kind of idea of what it is,
--- Sidharth Malhotra <[EMAIL PROTECTED]> wrote:
> While were on this, I'm taking an intro to Data Structures class and
> were learning all about the different sorting methods ... Insertsort,
> mergesort etc. What kind of sorting method perl's sort() use?
>
> Sid.
Sid,
Perl's sort function is
IL PROTECTED]]
Sent: Thursday, November 15, 2001 7:39 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: What is "bubble sort"?
(Cross-posted to the Perl Beginners List)
On Nov 15, Tommy Butler said:
>What's a "bubble sort" ? I believe I heard the term used on thi
(Cross-posted to the Perl Beginners List)
On Nov 15, Tommy Butler said:
>What's a "bubble sort" ? I believe I heard the term used on this list a
>while back. I have some kind of idea of what it is, and how it would be
>implemented, but I'd like to find out for
28 matches
Mail list logo