#LyX 2.3 created this file. For more info see http://www.lyx.org/
\lyxformat 544
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass book
\use_default_options true
\maintain_unincluded_children false
\language spanish
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\use_microtype false
\use_dash_ligatures true
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 1
\use_minted 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\is_math_indent 0
\math_numbering_side default
\quotes_style swiss
\dynamic_quotes 0
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Standard
Están formadas por un número fijo de elementos de un determinado tipo.
 Definición:
\end_layout
\begin_layout Standard
\align center
\begin_inset Tabular
| \begin_inset Text
\begin_layout Plain Layout
Lenguaje algorítmico
\end_layout
\end_inset | \begin_inset Text
\begin_layout Plain Layout
Pascal
\end_layout
\end_inset | 
| \begin_inset Text
\begin_layout Plain Layout
\emph on
nombre_tipo
\emph default
 = TIPO Tabla [
\begin_inset Formula $s_{1}$
\end_inset
, 
\begin_inset Formula $e_{1}$
\end_inset
; 
\begin_inset Formula $\dots$
\end_inset
; 
\begin_inset Formula $s_{n}$
\end_inset
, 
\begin_inset Formula $e_{n}$
\end_inset
] de 
\emph on
tipo
\emph default
;
\end_layout
\end_inset | \begin_inset Text
\begin_layout Plain Layout
\family typewriter
\emph on
nombre_tipo
\emph default
 = array [
\begin_inset Formula $s_{1}$
\end_inset
..
\begin_inset Formula $e_{1}$
\end_inset
, 
\begin_inset Formula $\dots$
\end_inset
, 
\begin_inset Formula $s_{n}$
\end_inset
..
\begin_inset Formula $e_{n}$
\end_inset
] of 
\emph on
tipo
\emph default
;
\end_layout
\end_inset | 
\end_inset
\end_layout
\begin_layout Standard
Si 
\begin_inset Formula $T$
\end_inset
 es una variable de un tipo tabla, podemos acceder a sus elementos con la
 notación 
\begin_inset Formula $T_{a_{1},\dots,a_{n}}$
\end_inset
, donde 
\begin_inset Formula $s_{i}\leq a_{i}\leq e_{i}$
\end_inset
, siendo 
\begin_inset Formula $s_{i}$
\end_inset
 y 
\begin_inset Formula $e_{i}$
\end_inset
 constantes de tipo entero, caracter o enumerado.
 En Pascal, 
\family typewriter
\emph on
T
\emph default
[
\begin_inset Formula $a_{1}$
\end_inset
,
\begin_inset Formula $\dots$
\end_inset
,
\begin_inset Formula $a_{n}$
\end_inset
]
\family default
.
\end_layout
\begin_layout Section
Composición 
\begin_inset Formula $k$
\end_inset
-RECORRIENDO
\end_layout
\begin_layout Standard
\align center
\begin_inset Tabular
| \begin_inset Text
\begin_layout Plain Layout
Lenguaje algorítmico
\end_layout
\end_inset | \begin_inset Text
\begin_layout Plain Layout
Pascal
\end_layout
\end_inset | 
| \begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i$
\end_inset
 
\series bold
RECORRIENDO
\series default
 [
\begin_inset Formula $a$
\end_inset
, 
\begin_inset Formula $b$
\end_inset
] 
\series bold
HACER
\end_layout
\begin_layout Plain Layout
\family typewriter
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $s$
\end_inset
\end_layout
\begin_layout Plain Layout
\series bold
FIN_RECORRIENDO
\end_layout
\end_inset | \begin_inset Text
\begin_layout Plain Layout
\family typewriter
for 
\begin_inset Formula $i$
\end_inset
 := 
\begin_inset Formula $a$
\end_inset
 to 
\begin_inset Formula $b$
\end_inset
 do
\end_layout
\begin_layout Plain Layout
\family typewriter
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $s$
\end_inset
\end_layout
\end_inset | 
| \begin_inset Text
\begin_layout Plain Layout
\begin_inset Formula $i$
\end_inset
 
\series bold
RECORRIENDO
\series default
 [
\begin_inset Formula $a$
\end_inset
, 
\begin_inset Formula $b$
\end_inset
] 
\series bold
EN_SENTIDO_INVERSO HACER
\end_layout
\begin_layout Plain Layout
\family typewriter
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $s$
\end_inset
\end_layout
\begin_layout Plain Layout
\series bold
FIN_RECORRIENDO
\end_layout
\end_inset | \begin_inset Text
\begin_layout Plain Layout
\family typewriter
for 
\begin_inset Formula $i$
\end_inset
 := 
\begin_inset Formula $b$
\end_inset
 downto 
\begin_inset Formula $a$
\end_inset
 do
\end_layout
\begin_layout Plain Layout
\family typewriter
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $s$
\end_inset
\end_layout
\end_inset | 
\end_inset
\end_layout
\begin_layout Standard
Ejecuta 
\begin_inset Formula $s$
\end_inset
 una vez por cada elemento entre 
\begin_inset Formula $a$
\end_inset
 y 
\begin_inset Formula $b$
\end_inset
, en sentido directo o inverso, y en este la variable 
\begin_inset Formula $i$
\end_inset
, de sólo lectura, toma el valor del elemento en cuestión.
\end_layout
\begin_layout Section
Tipo 
\family typewriter
string
\end_layout
\begin_layout Standard
Representa una cadena de caracteres, a los que se accede igual que en una
 tabla definida de 1 a 
\begin_inset Formula $n$
\end_inset
:
\end_layout
\begin_layout Standard
\begin_inset Box Boxed
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "100col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\family typewriter
var 
\emph on
str
\emph default
 : string [
\begin_inset Formula $n$
\end_inset
]
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
Se representan con comillas simples rodeando el contenido, se accede a los
 caracteres con 
\family typewriter
\emph on
str
\emph default
[
\emph on
i
\emph default
]
\family default
 y se definen las siguientes operaciones:
\end_layout
\begin_layout Itemize
\family typewriter
st1 + st2
\end_layout
\begin_layout Itemize
\family typewriter
concat(st1, ..., stn : string) : string
\end_layout
\begin_layout Itemize
\family typewriter
copy(st : string; start, index : integer) : string
\end_layout
\begin_layout Itemize
\family typewriter
delete(var st : string; start, index : integer)
\end_layout
\begin_layout Itemize
\family typewriter
insert(src : string; var dst : string; pos : integer)
\end_layout
\begin_layout Itemize
\family typewriter
length(s : string) : integer
\end_layout
\begin_layout Itemize
\family typewriter
pos(substr, str : string) : byte
\end_layout
\begin_layout Itemize
\family typewriter
str(in : 
\family default
(byte, integer...)
\family typewriter
; var out : string)
\end_layout
\begin_layout Itemize
\family typewriter
val(in : string; var out : 
\family default
(byte, integer...)
\family typewriter
; var invalidcharpos : integer)
\end_layout
\begin_layout Section
Algoritmos de ordenación
\end_layout
\begin_layout Standard
Suponemos que todos los algoritmos incluyen el siguiente léxico:
\end_layout
\begin_layout Standard
\begin_inset Box Boxed
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "100col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\series bold
LÉXICO
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $\text{TipoClave}=\text{ENTERO}$
\end_inset
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $\text{TipoDatos}=\text{\textbf{TIPO}}<\text{clave}:\text{TipoClave}\text{;}\dots>$
\end_inset
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $\text{TipoIndice}=\text{\textbf{TIPO}}\text{[1..\ensuremath{n}]}$
\end_inset
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $a:\text{\textbf{TABLA} [TipoIndice] \textbf{DE} TipoDatos}$
\end_inset
;
\end_layout
\end_inset
\end_layout
\begin_layout Subsection
Inserción directa
\end_layout
\begin_layout Standard
\begin_inset Box Boxed
position "t"
hor_pos "c"
has_inner_box 1
inner_pos "t"
use_parbox 0
use_makebox 0
width "100col%"
special "none"
height "1in"
height_special "totalheight"
thickness "0.4pt"
separation "3pt"
shadowsize "4pt"
framecolor "black"
backgroundcolor "none"
status open
\begin_layout Plain Layout
\series bold
LÉXICO
\end_layout
\begin_layout Plain Layout
\family typewriter
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $q,j:\text{TipoIndice}$
\end_inset
\family default
;
\end_layout
\begin_layout Plain Layout
\family typewriter
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $b:\text{TipoDatos}$
\end_inset
\end_layout
\begin_layout Plain Layout
\series bold
ALGORITMO
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\emph on
\begin_inset Formula $q$
\end_inset
\emph default
 
\series bold
RECORRIENDO
\series default
 [2, 
\begin_inset Formula $n$
\end_inset
] 
\series bold
HACER
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $b\leftarrow a_{q}$
\end_inset
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $j\leftarrow q-1$
\end_inset
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\series bold
MIENTRAS
\series default
 
\begin_inset Formula $b\text{.clave}a_{j}\text{.clave}$
\end_inset
 
\series bold
ENTONCES
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $pos\leftarrow j$
\end_inset
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $min\leftarrow a_{j}$
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\series bold
FIN_SI
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\series bold
FIN_RECORRIENDO
\series default
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $a_{pos}\leftarrow a_{q}$
\end_inset
;
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset space \hspace{}
\length 8ex
\end_inset
\begin_inset Formula $a_{q}\leftarrow min$
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset space \hspace{}
\length 8ex
\end_inset
\series bold
FIN_RECORRIENDO
\end_layout
\begin_layout Plain Layout
\series bold
FIN
\series default
.
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Otros algoritmos de ordenación, más avanzados, son el 
\series bold
algoritmo de Shell
\series default
, 
\begin_inset Formula $O(n^{1.25})$
\end_inset
, y 
\series bold
Quicksort
\series default
, 
\begin_inset Formula $O(n\log n)$
\end_inset
, que Charles Hoare demostró que no existe otro más rápido.
\end_layout
\end_body
\end_document