Professional Documents
Culture Documents
mid 2222222
mid 2222222
mid 2222222
Note: There are SIX questions, answer ALL of them. Course Outcome (CO), Cognitive Level and Mark of
each question are mentioned at the right margin.
1. a. Consider a tree in which each node contains maximum of 2 children (binary [CO2,C1,
tree). Identify the range (minimum and maximum) of height of a binary tree of 42 Mark: 4]
nodes. [CO2,C1,
b. Find minimum and maximum numbers of nodes of a binary tree of height 6. Mark: 4]
2. Ackerman’s number, used in mathematical logic, can be calculated using the formula [CO1,C2,
shown as following. Mark: 8]
n + 1 if m = 0
Ackerman (m, n ) = {Ackerman (m − 1, 1) if n = 0 and m > 0
Ackerman(m − 1, Ackerman(m, n − 1) otherwise
Write a recursive algorithm that calculates Ackerman’s number. Verify your algorithm by
using it to manually calculate the following test case: Ackerman (2, 3).
3. Write a program to convert an array into a Binary Search Tree by inserting the [CO3,C3,
elements as nodes in BST, processing elements in the given order in the array. Mark: 8]
Also find the height of the created Binary Search Tree.
Example:
Input : Input array size: 7
Input array elements: 4 6 2 7 9 8 3
Output : Height of BST = 4
4. Write a program that will display child of each node of a BST (Write only the [CO3,C3,
Function). For example for the following BST, output will be: Mark: 8]
5. Given a queue of integers, write a program that will determine which value in the [CO3,C3,
queue is the largest and move that value to the front of the queue while otherwise Mark: 8]
leaving the remainder of the queue in its original order.
Example: Input:
Page 1 of 2
6 3 2 10 -4 5
Output:
10 6 3 2 -4 5
Page 2 of 2