Skip to content

C, Java Language

dyhe83 edited this page Jun 5, 2019 · 3 revisions

C, Java

if C, Java function doesn't contain while loop and for loop match the following pattern.

Define

number = [0-9]+
variable = [_a-zA-Z]+
op = [+ | - | * | / | << | >>]
cp = [= | > | >= | < | <=]

For

// O(Loop Iteration * LoopBody)
for(LoopCounter = a1; LoopCounter < an; LoopCounter = LoopCounter op d) {
    Statement;
}

where a1, an, d can be:

a1 -> Int
an -> Int
d -> Int

Int -> (Int) | number | variable | Expr
Expr -> Int op Int

If

// O(Condition + Max(True Statement, False Statement))
if (Condition) {
    Statement;
} else {
    Statement;
}

where Condition can be:

Condition -> (Comparator) | Comparator | FunctionCall
Comparator -> Int cp Int 
Clone this wiki locally