Você está na página 1de 2

/*

* multiplicacaoRecursiva.c
*
* Created on: 19/05/2011
* Author: FERNANDO CESAR
*/
#include <stdio.h>
#include <stdlib.h>
int multRecursiva (int a, int b, int acumulador);
int multRecursiva (int a, int b, int acumulador)
{
int tempAcumulador = acumulador;
tempAcumulador += a ;
if ( a == 1 )
return b;
if ( b == 1 )
return tempAcumulador;
else
return multRecursiva( a , ( b - 1 ), tempAcumulador );
}
int main()
{
int x = 5;
int y = 7;
printf ("Produto de %d * %d = %d ", x, y, multRecursiva(x, y, 0));
return 0;
}
###
a) Inserção Direta
[3, 5, 10, 11, 13, 1, 20, 4]
[3, 5, 10, 11, 1, 13, 4, 20]
[3, 5, 10, 1, 11, 4, 13, 20]
[3, 5, 1, 10, 4, 11, 13, 20]
[3, 1, 5, 4, 10, 11, 13, 20]
[1, 3, 4, 5, 10, 11, 13, 20]
[1, 3, 4, 5, 10, 11, 13, 20]
b) Inserção Binária
[3, 5, 10, 11, 13, 1, 20, 4]
[3, 5, 1, 11, 13, 10, 20, 4]
[1, 3, 5, 11, 13, 10, 20, 4]
[1, 3, 5, 4, 13, 10, 20, 11]
[1, 3, 4, 5, 13, 10, 20, 11]
[1, 3, 4, 5, 11, 10, 20, 13]
[1, 3, 4, 5, 10, 11, 20, 13]
[1, 3, 4, 5, 10, 11, 13, 20]
c) Bubble Sort
[3, 5, 10, 11, 13, 1, 20, 4]
[3, 5, 10, 11, 1, 13, 4, 20]
[3, 5, 10, 11, 1, 13, 4, 20]
[3, 5, 10, 1, 11, 4, 13, 20]
[3, 5, 1, 10, 4, 11, 13, 20]
[3, 1, 5, 4, 10, 11, 13, 20]
[1, 3, 4, 5, 10, 11, 13, 20]
d) Merge Sort
[3, 5, 10, 11, 13, 1, 20, 4]
[3, 5, 10, 11] [13, 1, 20, 4]
[3, 5] [10, 11] [13, 1] [20, 4]
[3, 5] [10, 11] [1, 13] [4, 20]
[3, 5] [10, 11] [1, 4] [13, 20]
[3, 5, 10, 11] [1, 4, 13, 20]
[1, 3, 4, 5, 10, 11, 13, 20]

Você também pode gostar