You are on page 1of 2

Bapatla Engineering College (Autonomous)

Department of Information Technology


I Assignment Test
Subject: CS/IT 216 Data Structures
CLASS: II Year I Sem. A Sec.
Max.Time: 50 mts.
Date:
Marks: 10
I.

Max.

For each of the following six program fragments: find worst case time
complexity. Give reasons for your answer. ( 1 + 1 + 1 + 1 + 3 + 3 )
(a) sum = 0;
for( i=0; i<n; i++ )
sum++;

(b) sum = 0;
for( i=0; i<n; i++ )
for( j=0; j<n; j++ )
sum++;

(d) sum = 0;
for( i=0; i<n; i++ )
for( j=0; j<i; j++ )
sum++;

(e) sum = 0;
for( i=0; i<n; i++ )
for( j=0; j<i*i; j++ )
for( k=0; k<j; k++)
sum++;

(c) sum = 0;
for( i=0; i<n; i+
+)
for( j=0; j<n*n;
j++ )
sum++;
(f) sum = 0;
for( i=1; i<n; i+
+)
for( j=1; j<i*i;
j++ )
if( j%1 == 0 )
for( k=0; k<j;
k++ )
sum++;

II.

Implement the following list operations using Linked List ADT.


(2+
3+2+1+1+1)
a) Make empty list
b) To find pointers to predecessor and successor nodes of a given node
in the list.
c) To find pointers to first and last nodes of a given list.
d) To find weather a list is empty or not.
e) To compare elements at two positions in a list.
f) To swap elements at two positions in a list.

III.

Implement the following list operations using Linked List ADT.


3+3)
a) Insert an element after a given position in a list.
b) Delete an element after a given position in a list.
c) Find a pointer to the previous node of a node at position K.

IV.

You are given a linked list, L, and another linked list, P, containing
integers, sorted in ascending order. The operation print_lots(L,P) will
print the elements in L that are in positions specified by P. For instance,
if P = 1, 3, 4, 6, the first, third, fourth, and sixth elements in L are
printed. Write the routine print_lots(L,P). You should use only the basic
list operations. What is the running time of your routine?

V.

Given two lists, L1 and L2, write a procedure to merge two lists using
only the basic list operations.

VI.

(4+

Given a list L1 write a procedure to sort the list using only the basic list
operations.

Bapatla Engineering College (Autonomous)


Department of Information Technology
II Assignment Test
Subject: CS/IT 216 Data Structures
CLASS: II Year I Sem. A Sec.
Max.Time: 50 mts.
Date:
07/12/2013
Max. Marks: 10
I.

Explain the following terms in the context of Data Structures.


1+1+1+1+5)
(a) Tree

(b) Depth of a
Tree

(c) Height of node in a Tree.

(d) Binary Search


Tree

(e) AVL Tree

(f)Binary Tree Traversal


Techniques

(1+

II.

Implement the following Binary Search Tree operations.


(2+3+5)
a) Make empty BSTree
b) To find minimum element in the BSTree.
c) To delete an element from BSTree.

III.

Implement the following AVL Tree operations.


5)
a) Single rotation with left.
b) Double rotation with right.

IV.

Implement the following operations on Hash Table ADT that uses


Separate Chaining.
a) Initialize Hash Table.
(3+3+4
)
b) Find an element in the Hash Table.
c) Insert an element into Hash Table.

V.

Implement the following operations on Hash Table ADT that uses


Quadratic Probing.
a) Initialize Hash Table.
(3+3+4
)
b) Find an element in the Hash Table.
c) Insert an element into Hash Table.

VI.
a) Write a C program to insert an element into AVL Tree.
(5+5)
b) Derive expression for average internal path length of a Binary
Search Tree.

(5+

You might also like