CSC-335 ADTs & Data Structures
(Chapter 10 ADT Recursion Extra Notes
The content of this power point lecture has been originally created by Christos Kolonis and modified by Dr. Ahmad R Hadaegh
Recursion Example: Parsing
Parser is part of the compiler Input to a compiler is characters
Broken up into meaningful groups Identifiers, reserved words, constants, operators
These units are called tokens
Recognized by lexical analyzer Syntax rules applied
2
Recursion Example: Parsing
Parser generates a parse tree using the tokens according to rules below:
An expression: term + term | term term | term A term: factor * factor | factor / factor | factor A factor: ( expression ) | letter | digit
3
Note the indirect recursion
Algorithm Efficiency
How do we measure efficiency
Space utilization amount of memory required Time required to accomplish the task
Time efficiency depends on :
4
size of input speed of machine quality of source code quality of compiler
These vary from one platform to another
Algorithm Efficiency
We can count the number of times instructions are executed
This gives us a measure of efficiency of an algorithm
So we measure computing time as:
T(n) = computing time of an algorithm for input of size n = number of times the instructions are executed