mid 2222222

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

EAST WEST UNIVERSITY

Department of Computer Science and Engineering


B.Sc. in Computer Science and Engineering Program
Mid Term II Examination, Summer 2023 Semester
Course: CSE 207- Data Structures, Section-1
Instructor: Dr. Maheen Islam, Associate Professor CSE Department
Full Marks: 40 (20 will be counted for final grading)
Time: 1 Hour and 20 Minutes

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]

Child of 50: 20 and 70 50


Child of 20: 10 and 45 /\
Child of 10: NULL 20 70
Child of 45: NULL /\
Child of 70: NULL 10 45

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

You might also like