EasyManuals Logo

HP HP-28S User Manual

HP HP-28S
341 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 #273 background imageLoading...
Page #273 background image
Example.
Sort
the
list { 8, 3, 1,
2,
5
}.
I USER I
OJ
8,3,1,2,5
SORT
LMED (Median
of
a List)
3:
2:
1: ( 1 2 3 5 8 )
mDlBIlI1IlmlIl!mma~
Given a
sorted
list, calculate
the
median.
If
the
list
contains
an
odd
number
of
elements,
the
median
is
the
value
of
the
center
element.
If
the
list contains
an
even
number
of elements,
the
median
is
the
aver-
age value
of
the
elements
just
above
and
below
the
center.
Arguments
Results
1 :
{
sorted
list
::-
1 :
median
of
sorted
list
Techniques:
• FLOOR
and
CEIL. For
an
integer, FLOOR
and
CEIL
both
return
that
integer; for a non-integer, FLOOR
and
CEIL
return
successive
integers
that
bracket
the
non-integer.
Program
DUP
SIZE
1 + 2
.....
DUP
p
FLOOF.:
GET
::;~·lAP
p CEIL
GET
Comments
Begin
the
program.
The
size of
the
list.
The
center
position
in
the
list
(fractional for even-sized lists).
Store
the
center
position
in local
variable
p.
Begin
the
defining
program.
Make
a
copy
of
the
list.
Get
the
number
at
or
below
the
center
position.
Move
the
list to level
1.
Get
the
number
at
or
above
the
center
position.
272
28:
Programming
Examples

Table of Contents

Other manuals for HP HP-28S

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the HP HP-28S and is the answer not in the manual?

HP HP-28S Specifications

General IconGeneral
BrandHP
ModelHP-28S
CategoryCalculator
LanguageEnglish

Related product manuals