# C Programming Examples without using Recursion

## 1. C Examples on Traversal of a Tree without using Recursion

To traverse means to visit the vertices in some systematic order. preorder: visit each node before its children. postorder: visit each node after its children. inorder (for binary trees only): visit left subtree, node, right subtree. Depth first search is a way of traversing graphs, which is closely related to preorder traversal of a tree.The following programs demonstrate the DFS traversal of a tree, common tree traversals without using recursion.

C Program to Search an Element in a Tree Non-Recursively C Program to Traverse the Tree Non-Recursively C Program for Depth First Binary Tree Search without using Recursion |

## 2. C Examples on Solving Magic Square Puzzle and finding the HCF of a given Number without using Recursion

The H.C.F. of two or more than two numbers is the greatest number that divides each of them exactly. A magic square is a grid of numbers where the values in each of the rows, columns and diagonals adds up to the same sum, known as the â€śmagic number. The following programs find the HCF of a given number without using recursion and also demonstrates the Magic Square Puzzle without recursion.

C Program to find HCF of a given Number without using Recursion C Program to Solve the Magic Squares Puzzle without using Recursion |

## 3. C Examples on Number Conversion without using Recursion

In Gray code, while traversing from one step to another step only one bit in the code group changes. The following programs convert binary code of a number into its equivalent gray code using recursion and without using recursion. The other program in the section finds the product of 2 numbers without using recursion.

## 4. C Examples on Linked List Implementation without using Recursion

A Linked List is a dynamic data structure which contains memory blocks occupying random memory locations. The elements in the linked list are called nodes. The programs performs count of the number of occurrences of an element in the linked list using recursion, determines the length of the linked list using recursion and displays the nodes in a linked list using recursion and without using recursion. The programs also print the alternate nodes in a linked list without recursion.

## 5. C Examples on Stack Reversal without using Recursion

The following section demonstrates the reverse operation where it reverses the stack without using recursion. The other program in the section identifies the first capital letter in a string without using recursion.

C Program to Reverse a Stack without using Recursion C Program to find the First Capital Letter in a String without using Recursion |