Difference between revisions of "Optimization Topics/Exercise 04"

From Wiki**3

< Optimization Topics
(Created page with "Considere a seguinte função em C: <c> int find(int tab[], int max, int val) { int i; for (i = 0; i < max; i++) if (tab[i] == val) break; return i; } </c...")
 
 
Line 1: Line 1:
 
Considere a seguinte função em C:  
 
Considere a seguinte função em C:  
<c>
+
<source lang="c">
 
int find(int tab[], int max, int val) {  
 
int find(int tab[], int max, int val) {  
 
   int i;  
 
   int i;  
Line 8: Line 8:
 
   return i;  
 
   return i;  
 
}  
 
}  
</c>
+
</source>
  
 
# Identifique as optimizações independentes da máquina que são possíveis.  
 
# Identifique as optimizações independentes da máquina que são possíveis.  
 
# Traduza para código Postfix optimizado a função acima.  
 
# Traduza para código Postfix optimizado a função acima.  
 
# Identifique os blocos básicos.
 
# Identifique os blocos básicos.

Latest revision as of 13:56, 12 February 2019

Considere a seguinte função em C:

int find(int tab[], int max, int val) { 
  int i; 
  for (i = 0; i < max; i++) 
    if (tab[i] == val) 
      break; 
  return i; 
}
  1. Identifique as optimizações independentes da máquina que são possíveis.
  2. Traduza para código Postfix optimizado a função acima.
  3. Identifique os blocos básicos.