You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
05-16-2017, 06:53 AM
Post: #11
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
I Found this and it looked Interesting...

Converted to (Uppercase!) Because My Eyes like it! Smile and one of the Reasons I hate the look of C / C++ Code although I suppose I could also Convert that to (Uppercase!) ?


COCKTAIL SORT...

THE BUBBLE SORT WORKS GREAT BUT I WAS LOOKING INTO THE COCKTAIL SORTING ALGORITHM 
WHICH IS BASICALLY THE BUBBLE SORT BUT IT ALSO BUBBLE SORTS THE OPPOSITE DIRECTION. 


DIM A(9)
A(0)=5
A(1)=4
A(2)=7
A(3)=2
A(4)=8
A(5)=1
A(6)=9
A(7)=10
A(8)=3

'ARRAY LENGTH SUBTRACT 1
ALENGTH=8-1


'BUBBLE DOWN THE ARRAY
FOR X=0 TO ALENGTH
FOR I=X TO (ALENGTH-X)
IF A(I) > A(I+1) THEN
TEMP=A(I)
A(I)=A(I+1)
A(I+1)=TEMP
END IF
NEXT I

'BUBBLE UP THE ARRAY
FOR T=(ALENGTH -X) TO (X+1) STEP -1
IF A(T) < A(T-1) THEN
TEMP=A(T-1)
A(T-1)=A(T)
A(T)=TEMP
END IF
NEXT T
NEXT X
Find all posts by this user
Like Post
05-16-2017, 07:07 AM
Post: #12
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
Yes, this one could be improved by swap too.

Quick sort would be faster than this too.

Where did you find this? an older BASIC?

B += _
Find all posts by this user
Like Post
05-16-2017, 07:28 AM (This post was last modified: 05-16-2017 07:30 AM by Anthony.R.Brown.)
Post: #13
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
I Could not find the Original link Sad 

Found it!...

http://justbasic.conforums.com/index.cgi...1120928790

But! when I tried to Run the first Version...there is a mistake ?


Anthony.
Find all posts by this user
Like Post
The following 1 user Likes Anthony.R.Brown's post:
bplus
05-16-2017, 08:58 AM
Post: #14
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
Yep! JB does not have swap. Nice to learn the alternate way too. Wink

B += _
Find all posts by this user
Like Post
05-16-2017, 01:46 PM (This post was last modified: 05-16-2017 01:47 PM by Anthony.R.Brown.)
Post: #15
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
This may help... (If Only I understood what they are talking about) Confused
Find all posts by this user
Like Post
The following 1 user Likes Anthony.R.Brown's post:
bplus
05-16-2017, 01:52 PM
Post: #16
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
I think all you need to understand is to see which is on top!

Should be easy... Smile

B += _
Find all posts by this user
Like Post
05-16-2017, 02:22 PM
Post: #17
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
Yes! some Guys like to be on top! Wink
Find all posts by this user
Like Post
The following 1 user Likes Anthony.R.Brown's post:
bplus
05-16-2017, 02:30 PM
Post: #18
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
Some Sorts too apparently Wink

B += _
Find all posts by this user
Like Post
09-05-2017, 04:26 PM
Post: #19
 (Print Post)
RE: What is the Shortest,Efficient,Fast, Code Possible QB64 Sort ?
I knew I discussed Quick Sort with someone!

B += _
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - ARB Checkers
QB64 Member Project - Domain
QB64 Member Project - Othello
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Spiro Roses
QB64 Member Project - Martin Fractals version four
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Line Thickness
QB64 Member Project - 9 Board
QB64 Member Project - Quarto
QB64 Member Project - Inside Moves
QB64 Member Project - Kings Court
QB64 Member Project - Foursight
QB64 Member Project - Connect Four
QB64 Member Project - Qubic
QB64 Member Project - Point Blank
QB64 Member Project - Score 4
QB64 Member Project - Blokus
QB64 Member Project - Overboard
QB64 Member Project - Martin Fractals version two
QB64 Member Project - Exit
QB64 Member Project - Bowditch curve
QB64 Member Project - Pivet version one
QB64 Member Project - Input
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Martin Fractals version three
QB64 Member Project - Dakapo
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Splatter
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Amazon
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Rotating Background
QB64 Member Project - Isolation
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - Rubix's Magic
QB64 Member Project - Swirl
QB64 Member Project - Color Rotating Text
QB64 Member Project - Color Triangles
QB64 Member Project - Touche
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Algeria Weather
QB64 Member Project - Sabotage
QB64 Member Project - Basic Dithering
QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Dreamy Clock
QB64 Member Project - Pivot version two