dsa 2-14

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

Roll No.

B.E / B.Tech (Full Time) DEGREE ARREAR END SEMESTER EXAMINATIONS,


APR /MAY 2014
INFORMATION TECHNOLOGY
III Semester

IT8303 Programming & Data Structures II


(Regulation 2012)

Time : 3 Hours Answer ALL Questions Max. Marks 100


PART- A (10 x 2 = 20 Marks)

1. How new operator differs from malloc?


2. What is the significance of Scope resolution operator?
3. List out the operators that could not be overloaded as a friend.
4. What is the output of this program?
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str ("I like to code in C");
unsigned sz = str.size();
str.resize (sz + 2,'+');
str.resize (14);
c o u t « str«'\n';
return 0;
}
5. What is terminate() function in exceptions? Why do we need it?
6. How can we extend a namespace which is already defined?
7. What is a Disjoint Set?
8. Construct a Binomial Heap for the following numbers:
.. -10 50-23 14 57 26 34-2842 17
9. Write a recursive procedure for Depth First Search.
10. How do you represent a graph using Adjacency list?

Part - B (5x16=80 marks)

11. i) Write a C++ program to represent a Vector using classes. Include member
functions to perform the following tasks:
a. To create a Vector b. To multiply it by a Scalar c. Display of Vector.
(8)
ii) Create a Class named 'MATRIX' of size m*n. Define a friend function to find the
transpose of MATRIX. (8)

12. a) i) What is RTTI? Where do we require? Explain the significance of it with few
cases. (6)
ii) Write a C++ program to develop a polynomial class consisting of a coefficient
and an exponent part. Overload an assignment operator to assign one polynomial
to another using friend function. (10)
(OR) *-
b) i) Create a class named employee with data members first name, last name and
member functions: earnings (Pure Virtual function) and Print(Virtual function).
Derive a class called boss from employee and its data member is weekly salary
and member function: set_weekly_salary. Calculate and print the earnings
appropriately. (10)
ii) How is protected access specifier different from other access specifiers while
inheriting a class? Explain with an example. (6)

13. a) i) Write a C++ program that uses a Stack object to determine whether a String is
palindrome or not using Class Templates. (8)
ii) Write a C++ program to read a text file and count & display the total number of
alphabets and numbers present in it. (8)
(OR)
b) i) Create a Listl consisting of even numbers and a List2 with odd numbers. Sort
both of the lists appropriately and Merge two sequences of numbers to
produce List3 and display the values of List3. (Make use of the LIST header
file from STL). (8)
ii) Write a C++ program to calculate the current age of a person by accepting his
date of birth. Raise an exception if the age is negative. (8)

14. a) i) Show the result of inserting the following keys into an initially empty Red-Black
Tree: 85, 15, 70, 60, 30, 50, 110, 40. Further delete the keys 60, 30, 15 from
the above. (6+4)

ii) Explain the various types of Amortized analysis in detail. (6)


(OR)
b) i) Simulate the result of inserting the following keys into an initially empty B-Tree:
I.J.K.C.V.G.M.R.NAB.X.Y.P.D.Z.L.H.Q.S.F.E with minimum order 5. Further
delete the keys F, M, G, R from it. (8)
ii) Write a suitable routine to insert nodes into an AVL tree with appropriate
rotations. (8)

15. a) i) Compute All-Pair shortest path for the following graph using Floyd-Warshall
algorithm (10)
3

ii) How do you construct a minimum spanning tree using Kruskal's algorithm.
Explain with an example. (6)
(OR)
b) i) Write Bellman Ford algorithm and compute shortest path for the following^raph
using it. (Assume Vertex 1 as the source node) (10)

/
8

ii) Write a suitable algorithm to sort the edges of a graph using Topological Sort.
Also show the simulation of the above algorithm with an example. (6)

*********************

You might also like