EasyManuals Logo

Sinclair QL User Manual

Sinclair QL
422 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #113 background imageLoading...
Page #113 background image
•
Some
Techniques
Suppose we have reached the point where four items are sorted and we now focus
on green, the leftmost item
in
the unsorted part.
2 3 4
I
,,:"
6
7 8
black
blue
magenta
red
cyan
yellow
white
sorted part
t
unsorted part
1.
We
place green
In
the variable, comp$, and set a vanable,
p,
to
5.
2.
The variable, p, will eventually Indicate where we think green should go. When
we know that green should move
left,
then we decrease the value of
p.
3.
We
compare green with red.
If
green
IS
greater than (nearer
to
Z)
or equal
to
red
we exit and green stays where
It
is.
Otherwise we copy red
,n
to
POSition
5 thus and decrease the value of p thus:
•
black
2 3
blue magenta
4
red
I
I
5
red
6
cyan
7
yellow
8
white
4.
We
now repeat the process but
thiS
time we are comparing green with magenta
and we get:
Finally we move
left again comparing green with blue. This time there
is
no need
to move or change anything.
We
eXit
from the loop and place green
in
position
3.
We
are then ready
to
focus on the sixth Item, cyan.
•
5
black
black
2
blue
2
blue
3 4
magenta magenta
I
3 4
green magenta
5
red
5
red
I
I
6
cyan
6
cyan
I
7
yellow
7
yellow
8
white
8
white
1.
We
will first store the co/our$
In
an array colour$(B) and use: PROBLEM ANALYSIS
comp$
the current colour being compared
p to point at the position where we think the colour
in
comp$
might go.
2.
A
FOR
loop will focus attention on positions 2 to 8
In
turn
(a
single item
is
already
sorted).
3.
4.
12/84
A REPeal loop
will
allow comparisons until we find where the comp$ value actually
goes.
REPeal compare
IF
comp$ need
go
no further left EXIT
copy
a colour
Into
the position on
its
right
and decrease
p
END REPeal compare
After EXIT from the REPeal loop the colour
in
comp$ is placed
In
position p and
the
FOR loop continues.
97

Other manuals for Sinclair QL

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair QL and is the answer not in the manual?

Sinclair QL Specifications

General IconGeneral
ProcessorMotorola 68008
Clock Speed7.5 MHz
RAM128 KB (expandable to 640 KB)
ROM48 KB
Operating SystemSinclair QDOS
Release Year1984
StorageMicrodrive tape loop
Graphics256x256 pixels, 8 colors
PortsRS-232, ROM cartridge
SoundBeeper (internal speaker)

Related product manuals