Rastreamento da função fatorial recursiva function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end Supondo-se o seguinte.

Slides:



Advertisements
Similar presentations
EXEMPLO DE REMOÇÃO ARVORE if (T = nil) then begin writeln ('ELEMENTO NAO ENCONTRADO NA ARVORE'); end else begin if (X.ch < T^.elem.ch) then.
Advertisements

F F F F FF LEI DE COULOMB ++ d q1q1 q2q2 -- d q1q1 q2q2 +- d q1q1 q2q
VERBS.
MO Prof. Paulo Cesar Centoducatte MC542 Organização de Computadores Teoria e Prática.
Robot Arm //Função callback de redesenho da janela de visualização void Display(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef(-1.0,
TÍTULO DO TRABALHO EM LETRAS MAIÚSCULAS NOME DO ALUNO 1 Orientador: Prof. Dr. Nome 2, Co-orientador: Prof. Dr. Nome³ 1 filiação (título de graduação, programa.
TÍTULO DO TRABALHO EM LETRAS MAIÚSCULAS Nome do Aluno¹ Prof.(a) Dr. Nome² - Orientador Prof.(a) Dr. Nome² - Co-orientador 1 filiação (título de graduação,
1. 2 Memória (R-bit register) Circuito Combinatório D1D1 DRDR TRTR T1T1 X1X1 XLXL Y1Y1 YNYN clockreset MEF.
Gotas de Crystal So this is Christmas Então já é Natal And what have you done E o que você tem feito Another year over Um outro ano se encerra And new.
Forma de Trabajo 3 – Plantear todas las estrategias posibles 4 – Seleccionar la más adecuada (Método de ordenamiento por Selección)
Introdução a Programação COM 100 Aula 08 Procedimentos.
Let´s take a walk together Vamos passear juntos Near the oacean share Perto da praia Hand in hand you and I De mãos dadas, eu e você Let´s cherish every.
Hay que… & Se prohíbe….
Capoeira Today 1970’s capoeira masters began travel around the world and spread the harmony of capoeira.
Transistors (MOSFETs)
I work – he works You watch – he watches They study – she studies
ІІ етап Всеукраїнської олімпіади з інформатики
Divisor máximo de dois inteiros. unsigned int gcd(unsigned int A, unsigned int B) { if (B > A) return gcd(B,A); else if (B==0) return A; else return gcd(B,A%B);}
Scientific Programming for(i=0; i b) { a = func1(c,d,i*10); } else if(a < b) { a = func2(e,f,i*10); } else { a = func3(g,h,i*10);
(x 2 + 3x).(x – 4) (x 7 + 3).(x 7 – 3) (1 – t 4 ).(1 + t 4 )
QUE A MISÉRIA CHEGUE LOGO AO FIM; QUE O EMPREGO SEJA NÃO SÓ PRA MIM. QUE OS SALÁRIOS SEJAM DE TANTA GENTE; QUE O ESTADO OLHE O MAIS CARENTE! QUE OS SALÁRIOS.
PIRÂMIDES Pirâmide Triangular Pirâmide Quadrangular Pirâmide Hexagonal
Análise Sintática – Parte 2 Árvores Sintáticas Abstratas (ASTs) Scanning.
Representação do código objeto public class Instruction { public byte op; // op-code (0..15) public byte r; // register field (0..15) public byte n; //
1/03/09 De 89 à 98. 1/03/09 De 89 à 98 1/03/09 De 89 à 98.
Optimização Numérica Modelação de problemas 1ª aula teórico-prática 11/Setembro/2006.
EJERCICIOS PARA PREVENIR Y RECUPERAR LA DISLEXIA Los ejercicios con alumnos disléxicos deben ser sencillos y graduados. Los ejercicios con alumnos disléxicos.
Algoritmos de Busca Heurísticos. Sumario Heurísticos –Best-first –Greedy best-first –A * –Algoritmos de Busca local –Hill-climbing Metaheuristicos –Simulated.
Semáforos Plataforma Java 1.5 Juliano Cardoso Vacaro.

Vocab 1A. To talk about what you do in class Aprender de memoria Contestar Dar un discurso Discutir Explicar Hacer una pregunta El informe El laboratorio.
Daksha Patel Measurement, mapping and the human body Fugitive materials Making connections Analogy Heuristics.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Práctica tRAZAS & Manejo de memoria. Pasaje de Parámetros Program parametros; var pa1, pa2: integer; procedure p(pf1: integer; var pf2: integer); var.
Images for reflection. Que
Eu vou louvar- we will never stop Text and music Joses de Arimathea English translation Ilse Roskam.
Pages 07/03/ FCPT. This is a fat cat!
“O Espiritismo é uma Lei da Natureza”. L.E.222 “O Espiritismo é uma Lei da Natureza”. L.E.222 “É a alavanca que Deus se utiliza“É a alavanca que Deus se.
EXCLUSÃO DE MATRICULA. PROCURE NO “CADASTRO - ALUNO” O CANDIDATO QUE FOI MATRICULADO INDEVIDAMENTE.
Curiosidades “esqueléticas” Parte integrante da revista Território Teen “PROFESTAS HOJE” Editora Cultura Cristã.
Essa paz que hoje eu sinto em minh’alma Não é porque tudo me vai bem. Essa paz que hoje eu sinto em minh’alma É porque eu amo ao meu SENHOR Não olho as.
LITERATURA BRASILEIRA
IMPÉRIO BIZANTINO OU IMPÉRIO ROMANO DO ORIENTE Professora Vanessa Martins.
Cada uma das seguintes figuras representa uma circunferência e um polígono O polígono está inscrito na circunferência O polígono não está inscrito na.
。 33 投资环境 3 开阔视野 提升竞争力 。 3 嘉峪关市概况 。 3 。 3 嘉峪关是一座新兴的工业旅游城市,因关得名,因企设市,是长城文化与丝路文化交 汇点,是全国唯一一座以长城关隘命名的城市。嘉峪关关城位于祁连山、黑山之间。 1965 年建市,下辖雄关区、镜铁区、长城区, 全市总面积 2935.
Line complète de production de Fromage.
A BIBLIOTECA CPI DE SAN SADURNIÑO.
PRESENTACIÓNS CON IMPRESS
Sistemas Operativos Multiprogramação; Multiplexação; Memória Física; Memória virtual; Trabalho/Job - Processo/Process/Task - Thread.
POTENCIAL DE AÇÃO CARDÍACO. PA – CÉLULA MUSCULAR CARDÍACA Principal diferença entre o PA no neurônio e na célula muscular é que na célula miocárdica.
Qual é a diferença entre fonética e fonologia?. Fonética Estuda a natureza física da produção e da percepção dos sons da fala humana. Preocupa-se com.
CPU | Features & Components
Eu vou louvar- we will never stop
¡¿What the Fahrenheit!? El 20 de abril.
Magnificat Pobres e Humildes dos 11/12/2018 9:23 PM
FELIZ NATAL John Lennon.
Direct Mapping.
¿QUÉ HAY DEBAJO DE LA SUPERFICIE?
Програмата е насочена към обновяване на многофамилни жилищни сгради, като с нея се цели чрез изпълнение на мерки за енергийна ефективност да се осигурят.
Sector 25 from the Root Directory (in 32 byte chunks)
Conjunciones de Propósito con Subjuntivo
I go out salgo. I go out salgo scissors las tijeras.
Asking/Responding Spelling Something
Calculate 81 ÷ 3 = 27 3 x 3 x 3 3 x 3 x 3 x 3 ÷ 3 = This could be written as
Сабақтың тақырыбы: Мәлімет типтері. Шамалардың сипатталуы
Chapter 6 File Systems 6.1 Files 6.2 Directories
PUC por um Semestre - PIUES Termoquímica Calor de reação.
 Escribir el nombre del archivo que queremos utilizar archivo que queremos utilizararchivo que queremos utilizar  Sombrearlo  Menú – insertar – hipervínculo.
SISTEMAS OPERATIVOS (ESTRUCTURA) Por: Matta Avalos Carlos.
CONTROL DE CALIDAD TOTAL. QUÉ ES CONTROL DE CALIDAD?
Presentation transcript:

Rastreamento da função fatorial recursiva function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end Supondo-se o seguinte trecho de programa... : A := 4; F := Fat(A);

function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; Alocação de memória N 4

function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; Alocação de memória N 4

function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; Alocação de memória N 4 4 * Fat(3) Nova ativação de Fat

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end;

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end;

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) Nova ativação de Fat

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end;

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end;

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) Nova ativação de Fat

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) N 1 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end;

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) N 1 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end;

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) N 1 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 1 * Fat(0) Nova ativação de Fat

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) N 1 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 1 * Fat(0) N 0 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end;

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) N 1 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 1 * Fat(0) N 0 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; Função encerra e retorna 1 Fat(0) = 1

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) N 1 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 1 * Fat(0)

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1) N 1 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 1 * 1 = 1 Função encerra e retorna 1 Fat(1) = 1

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * Fat(1)

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2) N 2 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 2 * 1 = 2 Função encerra e retorna 2 Fat(2) = 2

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * Fat(2)

Alocação de memória N 4 N 3 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3) function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 3 * 2 = 6 Função encerra e retorna 6 Fat(3) = 6

Alocação de memória N 4 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * Fat(3)

Alocação de memória N 4 function Fat (N: byte): Longint; begin if N = 0 then Fat := 1 else Fat := N * Fat (N-1) end; 4 * 6 = 24 Função encerra e retorna 24 Fat(4) = 24

: A := 4; F := Fat(A); : Alocação de memória A 4 F 24 Retorno ao módulo que fez a 1a. chamada...