dsa 2-14
dsa 2-14
dsa 2-14
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)
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)
*********************