0% found this document useful (0 votes)
19 views

05 CSC335 Chapter10c (Recursion Part 2)

This document discusses recursion in parsing and algorithm efficiency. It provides an example of how a parser uses recursion to generate a parse tree according to rules that define expressions, terms, and factors. It also notes that algorithm efficiency depends on factors like input size, machine speed, source code quality, and compiler quality. Efficiency is measured by counting the number of times instructions are executed, with computing time defined as the number of instruction executions for a given input size.

Uploaded by

frankjamison
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

05 CSC335 Chapter10c (Recursion Part 2)

This document discusses recursion in parsing and algorithm efficiency. It provides an example of how a parser uses recursion to generate a parse tree according to rules that define expressions, terms, and factors. It also notes that algorithm efficiency depends on factors like input size, machine speed, source code quality, and compiler quality. Efficiency is measured by counting the number of times instructions are executed, with computing time defined as the number of instruction executions for a given input size.

Uploaded by

frankjamison
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 5

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

You might also like