You are on page 1of 7

DEPARTMENT OF INFORMATION TECHNOLOGY

20CS301 – DATA STRUCTURES USING C++


QUESTION BANK

PART A - MODULE I

1. Differentiate : Procedural language and Object oriented programming language

2. State the difference between C and C++.

3. What is an identifier?

4. What is a keyword?

5. Define constant and variable in C++.

6. List the types of operators in C++.

7. List the OOPS concepts.

8. Define encapsulation.
9. Define abstraction.
10. List out the benefits & applications of OOPS.
11. Define data hiding.
12. What is the use of scope resolution operator?

13. When you will make a function inline?

14. Difference between Overloading and Overriding.

15. What are objects? How they are created?

16. Can we define a method with same name of class? Define and produce its syntax.

17. What do you mean by friend function? State the need for friend function.

18. State the difference between a constructor and destructor. List some of the properties of constructor
and destructor.
19. What is the need of new operator?

20. Distinguish between break and continue statement.

21. Distinguish between while and do-while loop.

22. Differentiate static and dynamic binding.

23. What are templates? Give the general format for template.
24. What is exception handling? Mention the key words used in exception handling.

25. Define polymorphism. List the types of polymorphism.

26. What are the C++ operators that cannot be overloaded?

27. Give the syntax of exception handling mechanism.

28. Calculate the electricity bill of a residence for the following constraints. Calculate the consumed
unit from electric meter and do the following:
a) If the consumed unit is between 0 and 100, Rs.1.50 per unit
b) If the consumed unit is between 100 and 200, Rs.1.50 per unit
c) If the consumed unit is between 200 and 300, Rs.2.00 per unit
d) If the consumed unit is above 300, Rs.3.00 per unit
29. Find the output for the following when x=10 and y=0;
int main()
{
if (!(x>y))
cout << " x is equal to y ";
else
cout << " x is not equal to y ";
}
30. Define recursion.Write a C++ program to find the factorial of a number using recursion.
31. Write a C++ program to convert binary to decimal and vice-versa.
32. Write a C++ program to make a simple calculator to add, sub, multiply or divide using
switch..case.
33. C++ Programs from Arrays, control structures, functions and OOPS concepts
PART A - MODULE II

34. Define ADT. List the benefits of ADT.

35. Differentiate Linear and non-linear data structures with an example.

36. Compare: Singly , Doubly and Circular linked list.

37. Difference between Arrays and linked list.


38. List the applications of List ADT.

39. Write a program in C++ to create a Doubly linked list of n nodes and display it in reverse order.

40. Write a program in C++ to delete node from the beginning of a circular linked list.

41.
Write an algorithm to reverse a doubly linked list.

42. Define Stack. List the applications of stack.


43.
Convert the given infix expression (A+B*C-D)/(E*F) into its equivalent prefix and postfix form
using stack.
44.
How the recursive function is implemented using stack?
45. Determine the elements in the stack, if the following sequence of operations is executed?
Push (10,S); Push(22,S); Pop(S); Push(30,S); where S is the stack.
46. When multiple applications running on a PC, operating system assigns each of the running
application with a time slice to execute them in a cyclic order. Which data structure can be
recommended to the given scenario? Justify.
47.
Suppose a Circular queue of capacity (n - 1) elements is implemented with an array of ‘n’ elements.
Assume that the insertion and deletion operation are carried out
using REAR and FRONT respectively. Initially, REAR = FRONT = 0. State the conditions to detect,
queue is full and queue is empty.

48. Consider the following pseudocode. Assume that IntQueue is an integer queue. What does the
function fun do?
void fun(int n)
{
IntQueue q = new IntQueue();
q.enqueue(0);
q.enqueue(1);
for (int i = 0; i < n; i++)
{
int a = q.dequeue();
int b = q.dequeue();
q.enqueue(b);
q.enqueue(a + b);
print(a);
}
}
49.
Discuss how to implement queue using stack.
50. State the conditions that followed in the array and linked list implementation of queue.
51. List the types of Queue.
52. Define deque. What are the types of deque?

53. Why do we need for priority queue?

PART A - MODULE III

54. Define tree ADT.

55. Define Height and depth of a tree.

56. Differentiate binary tree from general tree.

57. Define expression tree. How will you construct an expression tree?
58. Perform tree traversal:

59. Define terminal and non-terminal node.

60. Compare: Full and complete binary tree.

61. What is the maximum height of any AVL-tree with 7 nodes? Assume that the height of a tree
with a single node is 0.
62. List the applications of tree.
63. Define Graph. Give the types of representation of graphs.

64. Define a Weighted Graph.

65. Define Connected graph.

66. Define Path & Cycle.

67. Differentiate
W : Directed and undirected graph.
h
68. What
W
a is a minimum spanning tree?
h
t is a single source shortest path problem?
69. What
a
70. ta is a tree edge and back edge?
What
r
71. Define
ae articulation point.
r
72. When
et a graph is said to be biconnected ?Give an example for a biconnected graph.

73. With
h a neat sketch, Explain Euler circuits.
te
74. List
h the applications of Graph. Explain any two.
et
w
to
w PART B – MODULE I
75. Explain
o the concepts of OOPS. State the merits and demerits of object oriented methodology.
t
76. y are the various categories of operators supported by C++? Explain with example.
What
tp
y
e
77. Illustrate with a program class declaration, definition and accessing class members.
p
s
e
78. What is an inline function? Write its syntax and explain with an example.
so
79. Explain
f copy constructor with suitable C++ coding.
o
80. Explain
fc the various forms of inheritance in C++ with necessary coding.
o
81. Describe
cn the types of polymorphism with suitab.le C++ coding
o
n
82. What
n do you mean by friend function? Explain with an example.
e
n
c
et
83. Discuss the need for exception with try, catch and throw keywords. Explain try..catch statement
with help of suitable C++ coding.
84. Explain about the three types of Parameter passing with suitable examples.
85. What is Function overloading? Explain it with a suitable program.
86. What is operator overloading? Explain it with a suitable program.
87. Design a C code that allows a user to do the following:
1) Create a bank account by supplying a user id and password.
2) Login using their id and password.
3) Quit the program.
Now if login was successful, the user will be able to do the following:
1) Withdraw money.
2) Deposit money.
3) Request balance.
4) Quit the program.
If login was not successful (for example the id or password did not match) then the user will be
taken back to the introduction menu.
88. How are dangling pointers different from memory leaks? Illustrate with an example.
89. Write a C++ Program to perform matrix multiplication.
90. Write a C++ Program to transpose a given matrix.
91. Define a class named ‘Bank Account’ to represent following members:

Data members : Account Number - Name of Depositor - Account Type - Balance Amount
Member functions: - Initialize members - Deposit Amount - Withdraw Amount - Display Balance

Write a C++ program to initialize members through constructor and display all the details of Bank
Account class for 3 customers. Use destructor to destroy the object.
92. Write a C++ program to implement single inheritance for the given scenario. Create a class EMP
which holds eno, ename, designation as its instance variable, a constructor is called to hold the
default values. Later, a method “get()” is used to input values for the variables. Create a class
SALARY inherit from emp where this class holds necessary to find the gross salary of an employee
in “calc()”function and display all the details of an employee in “display( )” function.
93. Declare a one dimensional integer array of size 5. Initialize array and search the element x in an
array and display the same. Use new and delete operator to allocate and deallocate memory for an
array.
94. Explain ‘this’ pointer with a neat example.
95. C++ Programs from Arrays, control structures, functions and OOPS concepts
PART B - MODULE II

96. With suitable example, Explain the operations of insertion and deletion of linked list .

97. Write an algorithm for inserting and deleting an element from Doubly linked list?

98.
Develop a C++ code for performing insertion & deletion operation in Singly linked list.
99. Evaluate the given expression A+B^C+(D*E/F)*G using stack. Here A=3, B=5, C=2, D=7, E=4, F=1,
G=8. Also, develop a C++ code for evaluating a postfix expression.
100.
Write a C++ code to implement stack of size N using an array. The elements in the stack are to be
integers. The operations to be supported are PUSH, POP and DISPLAY. Take into account the
exceptions of stack overflow and stack underflow.
101. Write the algorithm for converting infix expression to postfix expression / Design a C++ Code for
converting infix to postfix expression.
102. Explain linear linked implementation of Stack and Queue.
103. Develop a C++ code for evaluating balanced parenthesis in an expression.
104. How to efficiently implement Queues in a single array? Illustrate with an example.
105. Elaborate the different types of Queue and its applications.
PART B – MODULE III
106. What is a Binary tree? Write a C++ program for performing the traversal.
107. Given an unsorted integer array that represents binary search tree keys = [15, 10, 20, 8, 12, 16, 25]:
(a) Construct a height-balanced binary search tree after inserting the above keys. Delete key 20
from the tree and reconstruct the BST.
(b) Perform traversal from the reconstructed tree (a).
108. Design a C++ code / algorithm for Insertion and deletion operation of a Binary search tree.
109. State the height balancing property. Explain the rotation methods of AVL tree with an example.
110. Given the following AVL Tree:

(a) Draw the Binary Search Tree after 5 is removed, but before any rebalancing takes place.
Label each node in the resulting tree with its balance factor. Replace a node with both
children using an appropriate value from the node's left child.
(b) Rebalance the tree that results from (a). Draw a new tree for each rotation that occurs when
rebalancing the AVL Tree.
111. Differentiate: Depth First Search and Breadth First Search. For the given graph, perform traversal
using DFS and BFS.

112. With a suitable example, Explain Prim’s and Kruskal’s algorithm to construct a minimum spanning
tree.
113. With a suitable example, Explain Dijktra’s algorithm to solve Single shortest path problem.
114. Construct a Minimum spanning tree (MST) for the following undirected graph:

115. State the Single source shortest path problem. Find the shortest path from source vertex ‘1’ to all
other vertices for a given undirected graph using Dijktra’s algorithm.

116. Find the shortest path from source vertex ‘s’ to all other vertices for a given undirected graph using
Dijktra’s algorithm.

You might also like