![]() |
Challenge 9 - Quick sort - Printable Version +- Small Basic Forum (https://litdev.uk/mybb) +-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1) +--- Forum: Challenges (https://litdev.uk/mybb/forumdisplay.php?fid=5) +--- Thread: Challenge 9 - Quick sort (/showthread.php?tid=152) |
RE: Challenge 9 - Quick sort - AbsoluteBeginner - 10-28-2024 (10-28-2024, 09:22 PM)jrmrhrb00 Wrote: AB, JR, I don't know how much your code has changed compared to your code that I have. But, in the version of your code that I now see on my computer, line "status=LDArray.CreateFromIndices(name)" is located AFTER line "LDArray.SetValue(status, i, Math.GetRandomNumber(10))". That is, you FIRST try to use an array that has not yet been created, and only THEN write "CreateFromIndices". Give us the latest version of your code. ( Unfortunately, I have to go to bed. See you later. ![]() AB RE: Challenge 9 - Quick sort - Scout - 10-28-2024 I assume that the LDArrays cannot be output with Textwindow.WriteLine(). Only the internal name of the array appears. The sort function is OK. Code: name = LDArray.Create(10) That would be the simplest way of sorting. But I think that the numbered challenges should be solved without extensions. This is probably more about the Quicksort algorithm and a possible comparison with an AI solution. Have fun Scout RE: Challenge 9 - Quick sort - jrmrhrb00 - 10-28-2024 Scout, This failed too. Variable Name is used, but value is not assigned. First error. Name [ 1 ] :7 Name [ 2 ] :6 Name [ 3 ] :6 Name [ 4 ] :9 Name [ 5 ] :7 Name [ 6 ] :1 Name [ 7 ] :3 Name [ 8 ] :9 Name [ 9 ] :6 Name [ 10 ] :9 Result Sort: FAILED Name [ 1 ] :FAILED Name [ 2 ] :FAILED Name [ 3 ] :FAILED Name [ 4 ] :FAILED Name [ 5 ] :FAILED Name [ 6 ] :FAILED Name [ 7 ] :FAILED Name [ 8 ] :FAILED Name [ 9 ] :FAILED Name [ 10 ] :FAILED Press any key to continue... The rest of them. Notice that the sort did fail. RE: Challenge 9 - Quick sort - AbsoluteBeginner - 10-29-2024 (translated by Google translator) Hi all. ![]() Most likely, only LitDev will be able to fix this problem. However, we can continue to complete the task without using the extension. First of all, I try to develop my own quick sort method. ![]() I deliberately do not study methods that already exist. I'm interested in inventing things that I don't know yet. I wish everyone good luck. RE: Challenge 9 - Quick sort - z-s - 10-29-2024 Hii JR On desktop i fixed your code no error in extension. JXNC572.000-0 a more simpler version: MVHG984.000 ChatGPT's Solution Without third party library : LBBP129.000 RE: Challenge 9 - Quick sort - jrmrhrb00 - 10-29-2024 Z-S, Great job. I was sure I was doing something wrong but couldn't figure out what. Basically, I wasn't getting or setting the values for a LDArray. The amazing thing is there is no guidance any where on how to use those arrays. Used to be in the old small basic forum, but that is gone. Maybe, this is something that LitDev would write an article on. Thanks, JR RE: Challenge 9 - Quick sort - AbsoluteBeginner - 10-29-2024 (10-28-2024, 10:31 PM)jrmrhrb00 Wrote: Scout, Hi all. ![]() It's strange, but Scout's code works for me without errors. ![]() I don't understand anything... RE: Challenge 9 - Quick sort - litdev - 10-29-2024 Well done all, LBBP129.000 is bubblesort not quicksort (bubblesort very slow for large lists compared to quicksort), also only 5 not random elements LDArray is good for multi-dimensional arrays, where the max number of elements in each dimension is fixed initially LDList is good for 1D arrays, where the number of elements can grow dynamically RE: Challenge 9 - Quick sort - z-s - 10-29-2024 Got it https://en.m.wikipedia.org/wiki/Quicksort RE: Challenge 9 - Quick sort - Scout - 10-29-2024 Found this nice demo on sorting algorithms and extended it to 1024 random numbers for Challenge 9. It doesn't use extensions and is therefore a bit slow. But it could also be due to the shape moves. Program ID: JCXS148.000 Once we have created the algorithm for quicksort in Small Basic, we could extend this demo with quicksort. ![]() |