We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Challenge 9 - Quick sort
#41
(11-05-2024, 03:14 PM)litdev Wrote: Sorting is an extremely well researched topic and extremely unlikely any of us will discover anything new that works well.  But that isn't the point, the point is researching something, thinking about it and writing code, testing the code and comparing it with other methods objectively.  So by all means, share your variants or maybe try to write the quicksort as originally suggested.

(translated by Google translator)

In that case, I will continue preparing my code for publication. Because it is interesting.  Rolleyes
[-] The following 1 user Likes AbsoluteBeginner's post:
  • litdev
Reply
#42
(translated by Google translator)

Hi all.

My fear is growing that I won’t be able to sort an array of 1024 elements in 9...10 passes.  Blush
I haven't explored everything yet, but at this point, I need twice as much.

Eh, it's a pity that I have little free time.
But, on the other hand, I am very lucky that I have Small Basic.
Using any other programming language that is more complex than Small Basic, I would be too lazy to do these experiments.  Rolleyes
Reply
#43
(translated by Google translator)

Guys, I knew this existed !  Smile

I finally found a way to quickly sort any array using my "box sort" method !

I don't have the opportunity to describe this method now. But, on the other hand, I have the opportunity to share with you the pleasure that I have made my personal discovery.  Tongue

It's night here now. See you later.
Reply
#44
(translated by Google Translate)

Hello everyone.  Smile
Here is the solution that suddenly became obvious to me.

As you remember, my previous solution is that the value of an integer random number was used as an index of this number in the sorted array.
But, until yesterday, this method did not allow using arrays that contained fractional values or values that were larger than the size of the original array.

Last night, I saw in my mind's eye that if we use not the entire fractional random number as an index, but, for example, only the two left symbols of this number, then we get an INTEGER index of the auxiliary array of "boxes".
We place this entire number in the "box" with this index.
In this case, for all random numbers of the original array, the two left symbols must be used, which correspond to the same decimal places.

For example, if the array contains the numbers 123.4567 and 1.2345, then the two-digit index of the "box" for the first number will be 12, and for the second number = 00 (001.2345).

After all the random numbers of the original array are placed in the corresponding "boxes", we simply repeat this operation for each "box" that contains more than one number (we will create "boxes within boxes"). But this time, we use the next two symbols of the random numbers (for the number 123.4567 = 34 and for the number 001.2345 = 12).

This is the solution I have now.  Tongue

I don't have the code yet. But you can write your version of the code until I publish mine.
Reply
#45
Here is Quick Sort using Small Basic Stack Functions. Creates a thousand random variables and then sorts them.

PFNR733.000

JR
Reply
#46
Hello, JR.  Shy

I'm interested to know your sorting option.

Thank you.  Wink
Reply
#47
AB,

I don't know what you mean by sorting option. It is just quick sort. Sorting is basically done via the sub "partition" and the indexes are tracked via the small basic stack. If you want to figure out how it works analyze the partition function. This was originally generated by copilot using a stack. I changed it to using small basic stack functions.

JR
Reply
#48
(11-18-2024, 12:54 PM)jrmrhrb00 Wrote: AB,

I don't know what you mean by sorting option...

JR

(translated by Google translator)

JR,
Google translator made such a translation of my words, which meant “one of the possible ways of sorting” (sorting option).
It's really interesting to see how people use AI when creating code. A person is as strong as the amount of energy and matter of Nature he can use to achieve his goal.
I first brought this to my attention many years ago when I watched the movie "Rambo 2" ( Rambo in Vietnam ).  Blush
Now it's time to use AI.  Wink
[-] The following 1 user Likes AbsoluteBeginner's post:
  • jrmrhrb00
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)