0% found this document useful (0 votes)
12 views7 pages

20CS332 - C++ AND DATA STRUCTURES-v1

Uploaded by

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

20CS332 - C++ AND DATA STRUCTURES-v1

Uploaded by

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

QP ID :

K.S.R. COLLEGE OF ENGINEERING, TIRUCHENGODE – 637 215


(AUTONOMOUS)
B. E. / B.Tech. DEGREE END SEMESTER EXAMINATION, Nov / Dec 2024

THIRD Semester

B.E. – Electronics and Communication Engineering

20CS332 – C++ AND DATA STRUCTURES

(Regulations 2020)

Time: Three hours Maximum Marks: 100


Answer All Questions
PART A –– (10 x 2 = 20 Marks)
Q.No. Questions CO BTLs
1. List the limitations of procedure-oriented language. CO1 R
2. Which of the following is not a type of constructor? CO1 A
Justify.
a. Copy constructor
b. Friend constructor
c. Default constructor
d. Parameterized constructor
3. What is a virtual function? CO2 U
4. How many types of polymorphisms are supported CO2 U
by C++? List them.
5. When array based implementation of list ADT is CO3 U
preferred over linked list representation?

1
6. What does the following function do for a given CO3 A
Linked List with first node as head? Justify your
answer.
void fun1(struct node* head)
{
If (head == NULL) return;
fun1(head->next);
cout<<head->data;
}
7. What is the maximum height of any binary search CO4 A
tree with 7 nodes? Assume that the height of a
tree with a single node is 0.
8. Derive the adjacency matrix of the given graph. CO4 A

9. Given input {4371,1323,4199, 9679,1989} and a CO5 A


hash function h(X)=X(mod 10) show the resulting
open addressing hash table with table size 10.
10. Arrange the following list of elements in ascending CO5 A
using Selection sort. 6, 4, 12, 3, 1.

PART B –– (5 x 16 = 80 Marks)

Q.No. Questions CO BTLs


11.(a) i. Explain in detail about the various (8) CO1 U
constructor in C++. Write the C++ code
to demonstrate them.
ii. Create two classes DM and DB that (8) CO1 A
stores the value of a distance in metres/
centimetres and feet/inches respectively.
2
Write the C++ code that will get the
distance and do the conversion.
(OR)
(b) i. What are the significances of Static (8) CO1 U
member functions and Static data
members in C++. Explain with a sample
code.
ii. Create a class to represent a vector with (8) CO1 A
its size, and write the member function to
do the following in C++: Print the elements
of the vector and modify the given
element by the new value.

12.(a) i. Explain in detail about Operator (6) CO2 U


Overloading in C++. Write appropriate
code.
ii. Perform the following using C++. (10) CO2 Ap
Create a class Account with customerId,
accNumber and balance as data
members. It has methods withdraw and
deposit which doesn’t have sufficient
parameters for implementation. Inherit two
classes namely SavingsAccount and
currentAccount from Account class.
SavingsAccoount class allows only 5
withdrawl and balance must be < 2000.
CurrentAccount does not have any
restriction for balance and number of
transactions. Add necessary data and
method members, constructors and write
code to test your application with another
main class.
(OR)
3
(b) i. Write short notes on inheritance in C++. (6) CO2 U
Give an example.
ii. Perform the following using C++. (10) CO2 Ap
Create a class Item representing item in a
grocery shop. The items have name,
itemid, purchase price and date of
purchase. It has an abstract class
CalucateSellingPrice(). Create a class
Vegetable, which also has an expiry date
apart from other details. The selling price
is calculated as
a. 8% profit on purchase price if there
are 3 days to expire,
b. 6% profit on purchase price if there
are 2 days to expire and
c. 4% profit on purchase price if there is
a day to expire,
d. Expired items are not sold.

13.(a) i. Imagine you have two empty stacks (10) CO3 Ap


named S1 and S2. Draw a picture of
each stack after the following operations.
PUSH(S1,2)
PUSH(S1,4)
PUSH(S1,6)
PUSH(S1,8)
PUSH(S1,10)
While (!Empty(S1))
{
POP(S1,X)
PUSH(S2,X)
}

4
Note:
 Assume that PUSH() takes stack
name and element to inserted as
input.
 POP() takes stack name from which
element to be popped and second
argument is the popped element.
Write the code in C++ with class
definition to perform PUSH and POP
operation in array based Stack.
ii. Write a routine to traverse the list and (6) CO3 Ap
make the List empty while traversing in
linked list implementation of list with a
pictorial representation.
(OR)
(b) i. Design a Circular Queue using array (10) CO3 Ap
implementation to maintain library book
information like bookId, availability and
price.
Write methods to implement the following
operations using C++:
a. Enqueue
b. Dequeue
c. isFull
d. isEmpty

ii. Write a routine to perform a delete (6) CO3 Ap


operation in linked list implementation of
list ADT.

14.(a) Construct an AVL tree for the data given (16) CO4 An
below. Specify the type of rotations for
5
each of the elements while inserting into
an initially empty AVL tree. 2, 4, 1, 42,
10, 12, 9, 22, 15. Write functions for
single and double rotations in AVL tree.
(OR)
(b) Using Dijkstra’s Algorithm, find the (16) CO4 An
shortest distance from source vertex ‘S’
to remaining vertices in the following
graph. Write the algorithm for the same.

15.(a) i. Write the Binary search algorithm and (6) CO5 U


demonstrate with an example.
ii. Write the Quick sort algorithm and apply (10) CO5 A
the same to arrange the given list of N
elements in ascending order.
90, 56, 34, 82, 18, 10, 52, 44, 67, 15, 76,
12.
(OR)
(b) i. Write the function for the insert and (6) CO5 U
search operations in in the hash table
with open hashing.
ii. How merge sort algorithm sorts the given (10) CO5 A
list of elements using divide and conquer
technique? Apply merge sort to sort the
list H, J, M, B, C, U, G, D, K, S, W, A, L,
E. Design a recursive algorithm for
6
merge sort.

**********

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy