## What is non recursion in Java?

A recursive method calls itself with an adjusted set of parameters – and as your method is main and does not call main it is not recursive.

## What is AVL tree write the procedure for insertion into an AVL tree?

Insertion Operation is performed to insert an element in the AVL Tree. Insert the element in the AVL tree in the same way the insertion is performed in BST. After insertion, check the balance factor of each node of the resulting tree.

**What is AVL tree construct AVL tree from following elements?**

AVL Tree: An AVL tree is a binary search tree in which the heights of the left and right subtrees of the root differ by at most 1 and in which the left and right subtrees are again AVL trees. An AVL Tree is a form of binary tree, however unlike a binary tree, the worst case scenario for a search is O(log n).

**What are non-recursive functions?**

A non-recursive formula is a formula for a sequence that does not itself depend on any other terms in the sequence. In other words, the only variable you will need to plug in is the index of the sequence. For instance, S_n = n² is one of the most basic non-recursive formulas.

### What is non-recursive method?

A non-recursive technique is anything that doesn’t use recursion. Insertion sort is a simple example of a non-recursive sorting algorithm.

### How do you implement a recursive non-recursive traversal of a tree?

1) Create an empty stack S. 2) Initialize current node as root 3) Push the current node to S and set current = current->left until current is NULL 4) If current is NULL and stack is not empty then a) Pop the top item from stack. b) Print the popped item, set current = popped_item->right c) Go to step 3.

**What is the difference between recursive and non-recursive function?**

Recursive function is a function which calls itself again and again. A recursive function in general has an extremely high time complexity while a non-recursive one does not.

**How do I perform a deletion in AVL tree?**

The algorithm steps of deletion operation in an AVL tree are:

- Locate the node to be deleted.
- If the node does not have any child, then remove the node.
- If the node has one child node, replace the content of the deletion node with the child node and remove the node.

#### How to create an AVL tree from an array of integers?

Sort the given array of integers. Create the AVL tree from the sorted array by following the approach described here. Now, find the level order traversal of the tree which is the required sequence.

#### Why is the above tree not AVL?

The above tree is not AVL because differences between heights of left and right subtrees for 8 and 12 is greater than 1. Why AVL Trees? Most of the BST operations (e.g., search, max, min, insert, delete.. etc) take O (h) time where h is the height of the BST.

**How to debug avltree insertion errors?**

Your AVLTree has a complex class invariant and expressing it is generally a good idea for an efficient debug. As soon as you have identified the insertion that fails, you just have to break on the return false; in the invariant method that is executed. At this point you should be able to understand the origin of the bug.

**What is the difference between AVL tree and red black tree?**

So if your application involves many frequent insertions and deletions, then Red Black trees should be preferred. And if the insertions and deletions are less frequent and search is the more frequent operation, then AVL tree should be preferred over Red Black Tree.