Go Back   Velocity Reviews > Newsgroups > Java
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply

Java - insertion sort java code

 
Thread Tools Search this Thread
Old 04-12-2005, 03:24 AM   #1
Tim923
 
Posts: n/a
Default insertion sort java code

Would someone post the code for the insertion sort on an array of some
type?
  Reply With Quote
Old 04-12-2005, 04:21 AM   #2
Betty
 
Posts: n/a
Default Re: insertion sort java code

you lazy

"Tim923" <> wrote in message
news:...
> Would someone post the code for the insertion sort on an array of some
> type?



  Reply With Quote
Old 04-12-2005, 02:55 PM   #3
Tim923
 
Posts: n/a
Default Re: insertion sort java code

>you lazy

I already earned my BA degree. This is just for personal interest.
  Reply With Quote
Old 04-12-2005, 03:30 PM   #4
Eric Sosman
 
Posts: n/a
Default Re: insertion sort java code



Tim923 wrote:
>>you lazy

>
>
> I already earned my BA degree. This is just for personal interest.


Something rings false about the second sentence. If
you have a personal interest in insertion sorts, why ask
someone else to provide the code? If insertion sorts are
so interesting to you, why ask someone else to have all
the fun?

Tell you what, though: I'll offer some code for an
Even Better sorting method, one that will outperform an
insertion sort on virtually every measure in almost every
circumstance. Here ya go:

java.util.Arrays.sort(array_of_Comparable);

Hope this helps.

--


  Reply With Quote
Old 04-12-2005, 03:47 PM   #5
Caine
 
Posts: n/a
Default Re: insertion sort java code

In <> Tim923 wrote:
>>you lazy

>
> I already earned my BA degree. This is just for personal interest.
>


Looks like it's time to enroll again and get that Master's degree, your
Bachelor's has obviously not taught you to think for yourself...
  Reply With Quote
Old 04-12-2005, 05:13 PM   #6
Virgil Green
 
Posts: n/a
Default Re: insertion sort java code

Caine wrote:
> In <> Tim923 wrote:
>>> you lazy

>>
>> I already earned my BA degree. This is just for personal interest.
>>

>
> Looks like it's time to enroll again and get that Master's degree,
> your Bachelor's has obviously not taught you to think for yourself...


Which, frankly concerns me... that without knowing how to think for one's
self, one could be accepted into and presumably complete the Master's
program.

--
Virgil


  Reply With Quote
Old 04-12-2005, 05:36 PM   #7
Tim923
 
Posts: n/a
Default Re: insertion sort java code

> Something rings false about the second sentence. If
>you have a personal interest in insertion sorts, why ask
>someone else to provide the code?


Busting my butt for years to get my 4 year math degree at Binghamton
University entitles me to ask such questions about courses that don't
count for degrees. It's a well known policy.

http://www.jptc.org/cont_2.html
  Reply With Quote
Old 04-12-2005, 06:48 PM   #8
Eric Sosman
 
Posts: n/a
Default Re: insertion sort java code



Tim923 wrote:
>> Something rings false about the second sentence. If
>>you have a personal interest in insertion sorts, why ask
>>someone else to provide the code?

>
>
> Busting my butt for years to get my 4 year math degree at Binghamton
> University entitles me to ask such questions about courses that don't
> count for degrees. It's a well known policy.


It's possible that you're being atrociously misjudged,
but you must admit that the request looks peculiar in the
extreme. A few of the red flags:

- You specify an insertion sort, and are presumably
unwilling to use an implementation of any other
sorting algorithm. Thus your goal is not to sort
something (I offered code for that), but to do an
insertion sort. I can think of only one context
that calls for one not-very-good sorting algorithm,
and that's homework.

- Well, no: Other contexts exist. Insertion sort has
poor asymptotic behavior but small constant factors,
so it can outperform "superior" algorithms on very
short files. Practical sorting implementations often
switch to insertion sort (or something like it) once
they've "almost sorted" the large file. You may be
implementing such a thing -- but if you were capable
of doing so, you would also be capable of writing the
six or eight lines of an insertion sort without needing
to ask for help.

- You say you want an insertion sort "just for personal
interest" -- and that still rings false to me. People
who are interested in a topic generally want to do
their own investigation/participation/discovery, not
ask other people to have the fun as proxies. Nothing
you've written thus far explains (or even attempts to
explain) this attitudinal oddity.

Perhaps if you would explain how you intend to use the
code (and why you're not up to the simple task of writing
it yourself), nasty suspicious people like me might become
more sympathetic.

--




  Reply With Quote
Old 04-12-2005, 06:56 PM   #9
Betty
 
Posts: n/a
Default Re: insertion sort java code


"Virgil Green" <> wrote in message
news:LkT6e.746$. ..
> Caine wrote:
> > In <> Tim923 wrote:
> >>> you lazy
> >>
> >> I already earned my BA degree. This is just for personal interest.
> >>

> >
> > Looks like it's time to enroll again and get that Master's degree,
> > your Bachelor's has obviously not taught you to think for yourself...

>
> Which, frankly concerns me... that without knowing how to think for one's
> self, one could be accepted into and presumably complete the Master's
> program.
>
> --
> Virgil
>

I still say lazy. Why? Because google produces a zillion examples
with java code.


  Reply With Quote
Old 04-12-2005, 09:53 PM   #10
googmeister@gmail.com
 
Posts: n/a
Default Re: insertion sort java code

> Tell you what, though: I'll offer some code for an
> Even Better sorting method, one that will outperform an
> insertion sort on virtually every measure in almost every
> circumstance. Here ya go:
>
> java.util.Arrays.sort(array_of _Comparable);


OK, I'm up for the challenge. Let's measure performance in terms of
memory.
Insertion definitely beats the system sort (mergesort) here. Insertion
sort
is a great algorithm if the files are small, and this explains why the
system
sort cuts off to insertion sort on small files. Also insertion sort
runs in linear
time if the input is sorted or nearly sorted, and these inputs tend to
arise
in practice.

  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java code to send MS Outlook Tasks mansi Software 0 03-03-2009 08:20 AM
Java with Asp.net mdinant Software 0 04-04-2008 11:21 AM
Java Error: java.lang.ClassFormatError: oracle/jdbc/ttc7/TTC7Protocol Shalz Software 0 03-08-2008 05:05 PM
Java Beginners Still Bill Software 3 02-19-2008 09:13 AM
How To Access HTML elements in code behind??? nedums_b Software 1 02-07-2008 06:15 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47