0% found this document useful (0 votes)
382 views2 pages

Data Structures and Algorithms Mid-Semester Test: BITS Pilani-K K Birla Goa Campus

This document provides instructions for a mid-semester test in the course CS F211 Data Structures and Algorithms. The test contains 5 questions worth a total of 60 marks to be completed within 90 minutes. Question 1 involves proving time complexities of functions and solving a recurrence relation. Question 2 involves rearranging an array and pseudocode for linked list operations. Question 3 covers queue implementations and using queues to implement a stack. Question 4 addresses properties of binary search trees and AVL trees. Question 5 demonstrates heap sort and discusses efficient insertion in a binary tree implemented as a heap.

Uploaded by

Annwesha Panda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
382 views2 pages

Data Structures and Algorithms Mid-Semester Test: BITS Pilani-K K Birla Goa Campus

This document provides instructions for a mid-semester test in the course CS F211 Data Structures and Algorithms. The test contains 5 questions worth a total of 60 marks to be completed within 90 minutes. Question 1 involves proving time complexities of functions and solving a recurrence relation. Question 2 involves rearranging an array and pseudocode for linked list operations. Question 3 covers queue implementations and using queues to implement a stack. Question 4 addresses properties of binary search trees and AVL trees. Question 5 demonstrates heap sort and discusses efficient insertion in a binary tree implemented as a heap.

Uploaded by

Annwesha Panda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structures and Algorithms

Mid-Semester Test
BITS Pilani- K K Birla Goa Campus
Total: 60 Marks Time : 90 Minutes
Weightage: 30% March 06, 2018
Course No: CS F211

Note:
1. All parts of a question should be answered consecutively. Each answer should start from a fresh page.
2. Assumptions made if any, should be stated clearly at the beginning of your answer.

1. (a) Find C and n0 to prove that log2 n ∈ O(n1/3 ). (3 Marks)


(b) Show that (n + 1)4 ∈ O(n5 + 10n). (3 Marks)
(c) Prove that if f (n) ∈ O( g(n)) and g(n) ∈ O(h(n)) then f (n) ∈ O(h(n). (4 Marks)
(d) Find the closed form solution for the following recurrence relation

b if n < 2
T (n) =
2T (n/2) + bnlogn Otherwise
(4 Marks)

2. (a) Write a pseudocode to rearrange elements of a given array such that all those
originally stored at odd indices should be placed before those at even in-
dices. For example, if the input array is 1,2,3,4,5,6,7,8 then the output array is
1,3,5,7,2,4,6,8. (5 Marks)
In a doubly linked list each node has two pointers (except head and tail), one
to its successor and one to its predecessor.
(b) Write a pseudocode for inserting a key k after a node u on a doubly linked
list. (2 Marks)
(c) Write a pseudocode for deleting a node u on a doubly linked list. (2 Marks)

3. (a) Write a pseudocode for all queue operations (enqueue, dequeue, size, isEmpty,
front) when queues are implemented using circular arrays. (5 Marks)
(b) Write a pseudocode for pop if stack is implemented using two queues. What
is the time complexity? (4 Marks)

4. (a) A certain Professor Amongus claims that if a binary tree which stores ele-
ments in its internal nodes has the following property, then it is a binary
search tree. For every node v, the element stored at the left child of v is less
than or equal to the element stored at v and the element stored in the right
child of v is greater than or equal to the element stored at v. Is the Professor
making a correct claim? (3 Marks)
(b) Provide an example of a proper binary tree with n nodes and size of its array
based representation is Ω(n). (3 Marks)
(c) Construct an AVL tree T by inserting the keys (in the given order) into an
empty tree: (15,16,22,45,2,10,28,30,50,12,1). (4 Marks)
(d) For the above AVL tree, illustrate the delete operation by deleting the root
node. (3 Marks)
(e) Prove that height of the AVL tree is O(log n). (4 Marks)

5. (a) Illustrate heap sort for the input (5, 16, 22, 45, 2, 10, 18). (4 Marks)
(b) Suppose the binary tree T used to implement a heap can be accessed using
only the methods of the binary tree ADT. That is, we cannot assume T is im-
plemented using an array. Given a reference to the current last node, v, de-
scribe an efficient algorithm for finding the insertion point (that is, the new
last node) using just the methods of the binary tree interface. Be sure and
handle all possible cases. What is the running time of this method? (7 Marks)

Page 2

You might also like