Parcial

static void Seleccion (int [] matrix

)
{
int i,k,p,buffer,limit=matrix.length -1;
for(k=0; k<limit; k++)
{
p=k;
for(i=k+1; i<=limit; i++)
if(matrix [i]<matrix[p])
p=i;
if(p!=k)
{
buffer=matrix[p];
matrix[p]=matrix[k];
matrix[k]=buffer;
}
}
}
Limite = 4
V -> 5 9 1 4 3
i
p
buffer
1
0
1
2
2
3
3
1
4
4
2
5
4
2
2
3
3
4
3
5
3
4
5
4
5
-------------------------------------------------------public static void m (int iT, int iN)
{
m(4,5)
if (iN>1)
m(iT,iN-1);
System.out.pritnln(iT*iN);
}
5
1
1
1

9
9
3
3

1
5
5
4

4
4
4
5

3
3
9
9

k
0
1
2
3
4

el algoritmo imprime el 4, 8 12 16 y 20
-------------------------------------------------------Arboles
8, 5, 7, 3, 1, 9, 6, 4, 2
preorden 8,5,3,1,2,4,7,6,9
inorden 1,2,3,4,5,6,7,8,9
posorden 2,1,4,3,6,7,5,9,8
-------------------------------------------------------numero de hojas que tiene un arbol
public static int hojas(nodoArbol R)
{
int numHojas=0;

Ld==null)) return (1). if(R.Li).Li==nnull)&& (R.Ld!=null) numHojas=numHojas+hojas(R.Ld) } return (numHojas) } .if((R. else { if(R.Li!=null) numHojas=numHojas+hojas(R.

Sign up to vote on this title
UsefulNot useful