Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Sorting an array

Name: Anonymous 2010-10-24 4:13

There's an array of values from 1 to n. It isn't sorted. We have to sort it, but there are only to ways to move: third element to beginning or last element to beginning. How to do that ?

Name: Anonymous 2010-11-02 7:03

>>39
5/10, a commendable effort.  I wondered what it was doing until I noticed the swap.

Anyway, you can do an insertion sort in Θ(n2).

Name: Anonymous 2010-11-03 8:41

Samefag from >>40 here
I'm just curious how to do that

Name: Anonymous 2010-11-03 11:01

>>42
samefag
back to /b/, please

Name: Anonymous 2010-11-03 11:22

>>43
implying your post is going to change anything

Name: >>39 2010-11-03 11:40

>>42
What? It works fine

Name: Anonymous 2010-11-03 13:23

Simplify the operations a bit; last → first is just rotation; use that to seek, and you have just one operation: move any element two positions forward.
For even sized arrays this lets you move any element anywhere, for odd-sized arrays you have to first rotate the element to the correct modulo-2 position, and you'll end up with a sorted or almost sorted array.

A more interesting question is how to prove the unsolvable cases can't be solved. I found an invariant using the Lehmer code — probably, but it's kind of a pain to make a formal proof.

Name: Anonymous 2010-11-04 11:01

>>46
What do you mean by 'correct modulo-2 position' ?

Name: Anonymous 2010-11-04 11:59

>>46

fuck you

Name: Anonymous 2010-11-06 16:59

>>46
The most essential question is to make this max in O(n^2).
I dunno what correct modulo position is

Name: Anonymous 2010-11-06 18:07

>>49
That's okay, we love you anyway.

Name: Anonymous 2010-11-07 14:09

I thing the best way to sort arrays is
arrGayConquests.sort();

Name: Anonymous 2010-11-07 16:52

http://sio.mimuw.edu.pl/user.php/prz.pdf?op=get&id=96921

What a faggot, you thought the /prog/ won't find out?

Name: Anonymous 2010-11-07 17:22

>>52
Hah, wow, they get a month for five tasks? Please tell me this was the easy one.

Name: Anonymous 2010-11-07 18:29

>>53
This is the fourth of five. The three before it are laughable and doable by either tree search or even simple Haskell list comprehension and mapping/Prolog hacks, if the provided memory is sufficient. The third one is a joke; I'm assuming I'm too tired and missing something.

http://sio.mimuw.edu.pl/user.php?op=zadania&c=10180

Name: Anonymous 2010-11-07 18:48

I'd also like to direct you to a helpful blög post that will be of great help while doing most, if not all, of these exercises.

http://cairnarvon.rotahall.org/2010/02/28/search-trees-are-easy/

Name: RANDALL 2010-11-07 22:28

>>55
*blag

Name: Anonymous 2010-11-07 22:41

>>55
Nice shameless self-promotion, ``faggot''.

Name: Anonymous 2010-11-08 0:53

>>55
When are you going to write something new?

Name: Anonymous 2010-11-08 2:39

>>5

I like this solution.

Name: Anonymous 2010-11-08 2:54

>>55,57
Remember folks, if you dislike his post or his blog, it's because you're "insecure" or "uneducated." Heaven forbid he could actually be a douche.

Name: 55 2010-11-08 3:15

>>60
I posted his blog in an honest attempt to help with these exercises, not because of your stupid Xarn wars or whatever. I demand an apology.

Name: Anonymous 2010-11-08 3:16

Fuck IHBT.

Name: Anonymous 2010-11-08 3:17

>>60
Fuck off of /prog/.

Name: Anonymous 2010-11-08 3:22

finally a czarn mention

BAMPV XARNÆ

Name: Anonymous 2010-11-08 3:42

>>61
Please forgive me, >>61, no offence indented.

FORCED INDENTION OF FORGIVENESS

Name: Anonymous 2010-11-08 3:47

>>60
I'll take a knowledgeable, interesting ``douche'' over someone whose only contribution to /prog/ consists of whining in every fucking thread because Xarn once called him a name.

>>64
And you can fuck right off too.

Name: Anonymous 2010-11-08 5:52

>>66
You're mad...

Name: Anonymous 2010-11-08 14:51

>>67
your gay

Name: Anonymous 2010-11-08 19:02

>>68
What about my gay?

Name: Anonymous 2010-11-09 15:03

>>54
Bear in mind that these are for kids from 16 to 19 years old, and this is only first of three rounds. Yeah, they are easy, but I would really like to see, how do you solve them using search trees in reasonable time complexity.

Name: Anonymous 2011-02-04 18:23

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List