資料結構›Ch1 演算法基礎第 23 題/共 57 題
23. Recurrence Relation、Substitution Method、Time Complexity
#DS-01-023易Recurrence RelationSubstitution MethodTime Complexity
- (10%) Consider the following function implemented in C. Please analysis the time complexity of
bar(N, 'A', 'B', 'C')in Big O notation using substitution method for solving recurrence relation. Please clearly show the steps of your analysis.
void bar(int N, char X, char Y, char Z)
{
if (N<=1)
printf("%c %c\n", X, Y);
else {
foo(N-1, X, Z, Y);
printf("%c %c\n", X, Y);
foo(N-1, Z, Y, X);
}
}
📄 交大114
▤完整推導請見《WH 資工筆記 · 資料結構》Ch1 演算法基礎