EC6301 Object Oriented Programming and Data Structure 123
EC6301 Object Oriented Programming and Data Structure 123
net
Since the partition step ambiguously describes what to do with elements equal to the pivot, this
becomes a design decision. Part of a good implementation is handling this case as efficiently as
possible. Intuitively, we would hope that about half the elements that are equal to the pivot go
into S1 and the other half into S2, much as we like binary search trees to be
balanced.Thefigureshows the action of quicksort on a set of numbers. The pivot is chosen (by
chance) to be 65. The remaining elements in the set are partitioned into two smaller sets.
Recursively sorting the set of smaller numbers yields 0, 13, 26, 31, 43, 57 (by rule 3of
recursion). The set of large numbers is similarly sorted. The sorted arrangement of theentire set
is then trivially obtained.It should be clear that this algorithm works, but it is not clear why it is
any fasterthan mergesort. Like mergesort, it recursively solves two subproblems and requires
linear additional work (step 3), but, unlike mergesort, the subproblems are not guaranteed to be
of equal size, which is potentially bad. The reason that quicksort is faster is that the partitioning
step can actually be performed in place and very efficiently. This efficiency more than makes up
for the lack of equal-sized recursive calls. The algorithm as described so far lacks quite a few
details, which we now fill in. There are many ways to implement steps 2 and 3; the method
presented here is the result
of extensive analysis and empirical study and represents a very efficient way to implement
quicksort. Even the slightest deviations from this method can cause surprisingly bad
results.
-----------------------------------)))000000000000((((((-----------------------------------------
QUESTION BANK
UNIT – I
DATA ABSTRACTION & OVERLOADING
PART A
1.What are the features of Object Oriented P rogramming?
2.List out some of the benefits of OOP.
3.What is the use of scope resolution operator?
4.List out the advantages of new operator over malloc ().
5.What are the control structures used in C++?
6.State the difference between structures and class.
7.Define a class.
8.List the access modes used within a class.
9.What are the characteristics of member functions?
10.What are the properties of a static data member?
11.What are the properties of a static member function?
12.How can objects be used as function arguments?
187
Visit : www.EasyEngineeering.net
Visit : www.EasyEngineeering.net
PART B
UNIT - II
INHERITANCE & POLYMORPHISM
PART A
1. What are the t ypes of inheritance?
2. Give the syntax for i nheritance.
3. De fine s ing le inher ita n ce.
4. Define mu lt i- le ve l inher itan ce.
5. De fine mu lt ip le inheritance.
6. De fine H ierarc h ic a l inheritance.
7. De fine H ybr id inheritance.
8. What is a virt ua l base class?
9. What is an abstract class?
10. What are the t ypes of poly mo rphis m?
11. De fine ‘this’ p o inter.
12. What is a v irt ua l function?
13. What is a pure virtual functio n?
188
Visit : www.EasyEngineeering.net
Visit : www.EasyEngineeering.net
PART B
1. Explain the various types of Inheritance with suitable example program
2. What are virtual functions? Explain their needs using a suitable example. What are the rules associated
with virtual functions?
3. Write a brief note on casting class pointers and member functions.
4. What are the different forms of inheritance supported in c++? Discuss on the visibility of base class
members in privately and publicly inherited classes.
5. What are abstract classes? Give an example (with the program) to illustrate the use of abstract class.
6. Explain about Code Reuse with program.
7. Write notes on Typing conversions and derived class with program.
8. Define a student class. Inherit that into MCAStudent class and NonMCAStudent. MC A Students
inherits into GLSS Tudents and NonGLSStudents. A function howP racticalHours can only be applied to
MCAStudents. We have a base class Student pointer to a GLSStudent object.Use dynamic_cast ti check
that NonMCAS tudents do not S howP racticalHours.
9. Narrate type conversion with example
10. Explain inheritance with example
11. Explain polymorphism with example
12. What is a virtual destructor? Explain the use of it.
UNIT III
LINEAR DATA STRUCTURES
PART A
1. Write down the definition of data structure.
2. Define ADT (Abstract Data Type)?
3. Define linear data structure?
4. What are different types o f Linked List?
5. What is the difference between array and linked list?
6. Define a stack?
7. Define push and pop operations.
8. Define a q ueue?
9. What is single linked list?
10. How to create a new node?
11. Define HEAD po inter and NULL po inter?
12. What is meant by dummy header?
13. Define Circular linked list?
189
Visit : www.EasyEngineeering.net
Visit : www.EasyEngineeering.net
PART B
1. Explain about Linked list, its Types, insertion and deletion routines with suitable example.
2. Explain the insertion and deletion operation in singly linked list.
3. Explain array based implementation of list with an example program.
4. Given singly linked list whose first node is pointed to by the pointer variable C formulate an algorithm
to delete the first occurrence of X from the list and Insert the element X after the position P in the list.
5. Explain the implementation stack using linked list.
6. Write the ADT operation for insertion and deletion routine in stack.
7. Explain the process of postfix, prefix, infix expression evaluation with an example.
8. Give a procedure to convert an infix expression a+b*c+(d*e+f)*g to postfix notation.
9. Write a routine to insert an element in a linked list
10. What is a queue? Write an algorithm to implement queue.
11. Explain the process of conversion from infix expression to postfix using stack.
12. Write the ADT operation for insertion and deletion routine in linked lists & Queue
UNIT - IV
NON-LINEAR DATA STRUCTURES
PART A
1. Define non-linear data structure?
2. What is a Binary tree?
3. What are the applications of binary tree?
4. What is meant by traversing?
5. What is binary tree traversal?
6. What are the different types of traversing?
7. What are the two methods of binary tree implementation?
8. Define Graph?
9. Define adjacent nodes?
10. Name the different ways of representing a graph?
11. What are the two traversal strategies used in traversing a graph?
12. What is an acyclic graph?
13. Define Degree of a tree.
14. Define Terminal node or leaf?
15. Define Non-terminal nod e?
190
Visit : www.EasyEngineeering.net
Visit : www.EasyEngineeering.net
PART B
1. Explain the operations of insertion of nodes into and deletion of nodes from, a binary search tree with
code.
2. Narrate insertion deletion with example.
3. Give the analysis of insertion and deletion operations of nodes in binary search tree.
4. Draw the binary search tree for the following input list 60, 25,75,15,50,66,33,44. Trace an algorithm to
delete the nodes 25, 75, 44 from the tree.
5. Explain the operations of insertion of nodes into and deletion of nodes from, a binary search tree with
code.
6. Explain the two applications of trees with a neat example.
7. How do you insert an element in a binary search tree?
8. What are the graph traversal methods? Explain it with example.
9. Give an algorithm to find minimum Spanning tree, explain it with suitable example.
10. Write an algorithm for finding minimum spanning tree and explain application, illustrate the
algorithm with typical data of yours own example.
11. Explain the algorithm for depth first search and breadth first search with the following graph
12. Explain connected component.
UNIT - V
SORTING and SEARCHING
PART A
1. What is meant by sorting?
2. What are the two main classifications of sorting based on the source of data?
3. What is meant by external and internal sorting?
4. What is the purpose of quick sort?
5. What is the advantage of quick sort?
6. What is the purpose of insertion sort?
7. Define merge sort.
8. What are the advantages of merge sort?
9. What is linear search?
10. What is binary search?
11. Differentiate linear search and binary search.
12. Differentiate quick sort and merge
13. Give the advantage of merge sort
14. Distinguish quick sort and insertion sort.
191
Visit : www.EasyEngineeering.net
Visit : www.EasyEngineeering.net
PART B
1. Sort the sequence 3, 1, 4,7,5,9,2,6,5 using Insertion sort.
2. Explain the operation and implementation of merge sort.
3. Explain the operation and implementation of external sorting.
4. Write quick sort algorithm and explain.
5. Trace the quick sort algorithm for the following list of numbers. 90,77,60,99,55,88,66
6. Write down the merge sort algorithm and give its worst case, best case and average case analysis.
7. Explain the Quick sort algorithm with example
8. Briefly explain about quick sort algorithm
9. Trace the quick sort algorithm for the following numbers 90,77,60,99,55,88,66
10. Explain linear search & binary search algorithm in detail.
11. Explain linear search algorithm with an example.
12. Briefly differentiate linear search algorithm with binary search algorithm.
192
Visit : www.EasyEngineeering.net