Exp 2
Exp 2
AIM:
To write a program to implement of Iteration function for tree traversal.
ALGORITHM:
int main()
{
Node* root = new Node(1);
root->left = new Node(2);
root->right = new Node(3);
root->left->left = new Node(4);
root->right->left = new Node(5);
root->right->right = new Node(6);
root->right->left->left = new Node(7);
root->right->left->right = new Node(8);
preorderIterative(root);
return 0;
}
OUTPUT:
12435786
2B: Fibonacci with Iteration
AIM:
To write a program to implement of Iteration function for Fibonacci.
ALGORITHM:
1: Start
5: End Fibonacci(n)
7: return 0
9: return 1
OUTPUT :
Enter the number of elements: 9
0 1 1 2 3 5 8 13 21
RESULT:
Thus the C++ program to implement iteration function for tree traversal and
Fibonacci was written, executed and verified successfully .