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
#1
Implement quicksort algorithm and sort 1000 random numbers.

Interesting to see if it's easier the usual way understanding the algorithm and writing the code or getting AI to do it for you?
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply
#2
This is a very interesting task.  Rolleyes
Plus I'll be able to compete against my Copilot.

Hello everyone, friends.  Shy
Reply
#3
QZVX574.000

Why doesn't this program work? It' just using LDArray.sort!

JR
Reply
#4
(10-28-2024, 12:39 PM)jrmrhrb00 Wrote: QZVX574.000

Why doesn't this program work? It' just using LDArray.sort!

JR

Hello.
I think the program doesn't work because the LDArray.Sort() method is designed to work with arrays created by the LDArray.Create() method.
In my opinion, this method does not work with SB array.
Because these arrays are different from each other, the LDArray array works much faster than the SB array.
Reply
#5
AB,

I agree with you in that it has to be a ldArray.

So, here's the updated program. Still doesn't work.

JXNC572.000

JR
Reply
#6
(10-28-2024, 04:22 PM)jrmrhrb00 Wrote: AB,

I agree with you in that it has to be a ldArray.

So, here's the updated program. Still doesn't work.

JXNC572.000

JR

One of the errors: status[i]=Math.GetRandomNumber(10)

There should be: LDArray.SetValue(status, i, Math.GetRandomNumber(10))
Reply
#7
I guess this is error Smile
Code : 
PHP Code:
'small basic array
For i = 1 To 10
name[i]=math.GetRandomNumber(10)
EndFor

'
creates ldArray from indices
status
=LDArray.CreateFromIndices(name)
TextWindow.WriteLine(status)

'loads ldarray with random numbers
For i = 1 To 10
status[i]=Math.GetRandomNumber(10)
EndFor

'
why does the below fail
result
=LDArray.Sort(status)
TextWindow.WriteLine(result)

'would give a listing of sorted numbers, but just shows them in their random order
For i = 1 To 10
TextWindow.WriteLine(status[i])
endfor 
I just don't run the code got it from mobile.
What results this show:
PHP Code:
result=LDArray.Sort(status)
TextWindow.WriteLine(result
And litdev extension api show for method:The input array is replaced by the sorted array
So after AB fix you have to make the last loop like this:
PHP Code:
For 1 To 10
TextWindow
.WriteLine(LDArray.GetValue(status,i))
endfor 
ZS
Reply
#8
AB,Z-S,

None of the suggested fixes worked. I guess I'll wait on LitDev. He is always good at figuring these things out.

JR
Reply
#9
(10-28-2024, 05:33 PM)jrmrhrb00 Wrote: AB,Z-S,

None of the suggested fixes worked. I guess I'll wait on LitDev. He is always good at figuring these things out.

JR

This is because we haven't fixed all the bugs yet.
Can you paste the latest version of your code into your new message?
Reply
#10
AB, L-S,

I went back to basically the same code.

JR

JXNC572.000
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)