Beruflich Dokumente
Kultur Dokumente
1
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
known as dynamic binding because the selection of the appropriate function is done
dynamically at run time. This runtime polymorphism can be achieved by the use of
pointers to objects and virtual functions.
9. What is an expression?
An expression is a combination of operators, constants and variables arranged as per
rules of the language. It may include function calls which return values.
Class class_name
{
Private:
Variable declaration;
Function declaration;
Public:
Variable declarations;
Function declarations;};
3
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
4
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
6
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
7
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
Only one copy of that member is created and shared by all the objects of that class.
It is visible only within the class, but the life time is the entire program.
43. Give the operator in C++ which cannot be overloaded?
Sizeof ->size of operator
:: ->scope resolution opertor
?: -> conditional operator
. ->Membership operator
.* ->pointer to member operator
45. What are the steps that involves in the process of overloading?
Creates a class that defines the data type that is to be used in the overloading
operation.
Declare the operator function operator op() in the public part of a class.
Define the operator function to implement the required operation.
Constructor Destructor
1.A constructor is used to initialize the A destructor is used for releasing dynamically
object allocated memory
2.No symbol precedes the class name A tilde symbol precedes the class name
3.Constructors can be overloaded Destructors cannot be overloaded
8
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
16 MARKS:
1. a) Compare object oriented methodology with structure programming methodology with an
example.
b) What is meant by return by reference? Explain.
2 . Explain the following with example.
a. Parameterized constructor
b. Copy constructor
c. Default argument constructor
d. Dynamic constructor
3. Write an operator overloading program for manipulating matrices.
4. Explain friend class and friend function with example.
5. What are access specifiers? How are they used to protect data in c++?
6. What is function polymorphism (overloading)? Explain with suitable example.
7. Explain the method of invoking function dynamically.
UNIT II
4. Why can’t derived class access private things from base class?
To protect from future changes to the base class. Derived classes do not get access to
private members of a base class. This effectively "seals off" the derived class from any changes
made to the private members of the base class.
9
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
5. What is an ABC?
An abstract base class. An ABC is a class that has one or more pure virtual member
functions. You cannot make an object (instance) of an ABC.
6. What's the difference between how virtual and non-virtual member functions are called?
Non-virtual member functions are resolved statically. That is, the member function is
selected statically (at compile-time) based on the type of the pointer (or reference) to the object.
In contrast, virtual member functions are resolved dynamically (at run-time). That is, the
member function is selected dynamically (at run-time) based on the type of the object, not the
type of the pointer/reference to that object. This is called "dynamic binding."
Eg: A
B
class A
{ public:
void display()
{ cout<<"A"; }
};
class B : public A
{ public:
void display()
{ cout<<"B"; }
};
void main()
{ B b;
b.A :: display();
b.B :: display();
}
output:
10
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
16 MARKS:
1. Write a c++ program to illustrate the concept of base class and derived class.
11
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
2. Explain object composition with example.
3. Explain the types of inheritance with example .
4. Write a c++ program to illustrate the following concepts.
a. Abstract base class.
b. This pointer
5. Explain the visibility and accessibility of private, protected and public inheritance.
6. Write a program to illustrate the significance of virtual function and virtual
destructor.
7. Illustrate casting class pointers with an example in c++.
UNIT III
2 MARKS:
12
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
• A linked list does not waste any memory space
Disadvantages:
• Searching a particular element in a list is difficult and time consuming
• A linked list will use more storage space than an array to store the same number
of elements
8. Define a stack
Stack is an ordered collection of elements in which insertions and deletions are
restricted to one end. The end from which elements are added and/or removed is referred
to as top of the stack. Stacks are also referred as piles, push-down lists and last-in-first-
out (LIFO) lists.
10. Mention the advantages of representing stacks using linked lists than arrays
• It is not necessary to specify the number of elements to be stored in a stackduring its
declaration, since memory is allocated dynamically at run timewhen an element is
added to the stack
• Insertions and deletions can be handled easily and efficiently
• Linked list representation of stacks can grow and shrink in size withoutwasting
memory space, depending upon the insertion and deletion that occursin the list
• Multiple stacks can be represented efficiently using a chain for each stack.
13
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
Priority queue is a collection of elements, each containing a key referred as thepriority
for that element. Elements can be inserted in any order (i.e., of alternatingpriority), but are
arranged in order of their priority value in the queue. The elements aredeleted from the queue
in the order of their priority (i.e., the elements with the highestpriority is deleted first). The
elements with the same priority are given equal importanceand processed accordingly.
16 MARKS:
1. Explain in detail about the linked list implementation of list ADT using an
example.
2. Explain in detail about the array implementation of list ADT using an example.
3. Explain any three applications of linked list in detail with suitable example.
4. Explain any three polynomial manipulations with suitable algorithms.
5. Explain the operations of stack with suitable pseudo code.
6. Explain the applications of stack with suitable example.
7. Explain the operations performed on queue in detail. Write a suitable pseudo code
to implement these queue operations.
8. Explain the applications of queue with suitable example.
UNIT IV
2MARKS:
1. Define a tree
A tree is a collection of nodes. The collection can be empty; otherwise, a treeconsists of
a distinguished node r, called the root, and zero or more nonempty (sub) treesT1, T2,…,Tk,
each of whose roots are connected by a directed edge from r.
14
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
2. Define degree of the node
The total number of sub-trees attached to that node is called the degree of the
node.
8. What is meant by binary tree traversal and different binary tree traversal
techniques?
Traversing a binary tree means moving through all the nodes in the binary tree,
visiting each node in the tree only once.
• Preorder traversal
• Inorder traversal
15
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
• Postorder traversal
• Level order traversal
10. State the merit and demerits of linked representation of binary trees.
Merits:
Insertions and deletions in a node involve no data movement except the
rearrangement of pointers, hence less processing time.
Demerits:
• Given a node structure, it is difficult to determine its parent node
• Memory spaces are wasted for storing null pointers for the nodes, which have one or
no sub-trees • It requires dynamic memory allocation, which is not possible in some
Programming language.
14.DifferentiateBFSandDFS.
16 MARKS:
1. What are the types of binary trees? Explain in detail about the binary tree
representation.
2. Explain the tree traversal techniques in detail with suitable example.
3. Illustrate the application of trees using necessary examples.
4. How can a graph be represented in different ways? Explain each representation in
detail.
5. What are graph traversals? Explain each of them with suitable examples.
6. Explain breadth first search algorithm for the traversal of any graph with suitable
example.
7. Explain depth first search algorithm for the traversal of any graph with suitable
example.
UNIT V
2 MARKS:
2. What are the two main classifications of sorting based on the source of data?
a. Internal sorting
b. External sorting
External sorting is a process of sorting in which large blocks of data stored in
storage Devices are moved to the main memory and then sorted.
Internal sorting is a process of sorting the data in the main memory.
17
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
3. Working with large set of data in computers are facilitated when the data are
stored.
7. What are the three basic operations that are involved in quick sort?
1. Divide
2. Conquer
3. Combine
12. Give the worst case and best case analysis of quick sort.
Worst case: T(N) = O(N2)
Best case : O(N log N)
18
Prepared by Mr. S.Jagadeesan AP/CSE
EC6301 Object Oriented Programming and Data Structures
In the sequential search, we compare against the first item, there are at most \(n-1\)
more items to look through if the first item is not what we are looking for.
Instead of searching the list in sequence, a binary search will start by examining the
middle item. If that item is the one we are searching for, we are done. If it is not the correct
item, we can use the ordered nature of the list to eliminate half of the remaining items. If the
item we are searching for is greater than the middle item, the upper half of the array will be
considered for further searching. Otherwise, lower half of the array will be considered.
14. What is the worst case and best case no of comparison in linear search?
Best case : 1 step (i.e.,) O(1)
Worst case : n steps (i.e.,) O(n)
15. Give the worst case and best case analysis of binary search algorithm.
Worst case performance: O(log n)
Best case performance: O(1)
16 MARKS:
19
Prepared by Mr. S.Jagadeesan AP/CSE