Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sorting Algorithms
#1
I have been tinkering with AI (mainly Copilot) to reproduce those fascinating visual sorting programs. The AI is not 100% accurate when it comes to Naalaa, but in most cases, the syntax is somewhat easy enough for me to convert.... I have managed to replicate 6 popular sorting algorithms... Bubble, Insertion, Selection, Merge, Heap, Cocktail and the infamous Bogo sort.

One interesting thing I found was, inserting a 'wait' value of zero seconds has an effect on the speed of the sort. For example: Bubble sorting 200 samples with a 'wait 0' in the sort loop, takes about 41 seconds... remove the wait statement and the time is reduced to almost 8 seconds... apart from the Bogo sort, all other algorithms performed similarly.

Two points to remember... These visual sorting algorithms are a little mind-numbing and are purely here as "see if I can" experiment... the second: Bogo sort, in my opinion, is one of the most useless sort routines on the planet... try not to go beyond 5 elements to sort... All of the other algorithms use 200 elements... Moo Ha Ha Ha Ha.


.zip   sorting.zip (Size: 5.74 KB / Downloads: 10)

Remove the 'wait' statements and record the timings... Curious to know the results....

ps: Try to stay awake... lol
Logic is the beginning of wisdom.
Reply
#2
This was cool!

I remember when we learnt most of these algorithms at the university. Pascal was the language we used Smile  Never heard of coctail or bogo sort before though Big Grin

'wait 0' doesn't wait, but it gives the program a chance to process window messages, such as the close button being clicked.
Reply
#3
Yeah. Cocktail shaker sort is a bi-directional bubble sort. Bogo is a strange one... In a nutshell: Imagine you have 5 dice. Shake them up. "Are they in order?". If no, shake all 5 dice again. Repeat until "yes". Can you imagine how long that process would take if it used the same 200 elements as the other sorts? Shake 200 dice. "Are they in order?"... What are the odds of getting all 200 in order? Yikes! Probably one of the worst and most useless sorts... lol

Anyway, fun projects.... By the way, how is that neural interface coming along? Typing text etc. is SO tedious... lol
Logic is the beginning of wisdom.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)