Basic CS-Data Structures [3i Infotech Placement]: Sample Questions 35 - 36 of 52

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 35

Data Structures
Edit

Describe in Detail

Essay▾

What is recursion?

Explanation

Understanding of Recursion in C Programming
  • Recursion is the process of repeating items in a self-similar way.
  • It happens when a function calls itself- called a recursive call of the function.
  • Thus recursion is the process where one of the instructions is to “repeat the process” .
  • Similar to loop because it repeats the same code, and in some ways it is similar to looping.
  • Programmatically recursion expresses ideas where result of the recursive call is necessary to complete the task.

Advantages of Recursion

  • Function calling related information is maintained by recursion.
  • Stack evaluation will take place by using recursion.
  • Fix prefix, post-fix notation will be evaluated by recursion.

Disadvantages of Recursion

  • Slow process due to stack overlapping.
  • Recursive program can create stack overflow.
  • Functions can create.

Question 36

Data Structures

Describe in Detail

Essay▾

Traverse the given tree using Inorder, Preorder and postorder traversals.

Image Shows the Tree

Explanation

Inorder: D H B E A F C I G J

  • First, visit all nodes in the left subtree
  • Then the root node
  • Then the nodes in the right subtree

Preorder: A B D H E C F G I J

  • Visit root node
  • Then the nodes in the left subtree
  • After the node in the right subtree

Postorder: H D E B F I J G C A

  • Visit all the nodes in the left subtree
  • After the root node
  • Then the nodes in the right subtree

Developed by: