Download odd semester (2014 – 2015)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Quadtree wikipedia , lookup

Interval tree wikipedia , lookup

Binary search tree wikipedia , lookup

Transcript
1
ANAND INSTITUTE OF HIGHER TECHNOLOGY
KAZHIPATTUR, CHENNAI-603 103
DEPARTMENT OF INFORMATION TECHNOLOGY
ODD SEMESTER (2014 – 2015)
SUBJECT: OOPS and DS / EC6301
BRANCH: ECE
STAFF: Ms.R.Ranjani
SEM: III
______________________________________________________________________________
UNIT – I
PART – A
1. Define Data Encapsulation? (Nov/dec 2013)
The wrapping up of data and function together into a single unit is called data
encapsulation
2. What is static member function? (Nov/dec 2013 , Nov/dec 2011)
A member function that is declared as static has the following properties
A static function can have access to only other static member declared in the same class
A static member function can be called using the classname as follows
classname ::function_name;
3. What are basic concepts of OOPS?(Nov/dec 2012)
i.
Objects.
ii.
Classes.
iii.
Data abstraction and Encapsulation.
iv.
Inheritance.
v.
Polymorphism.
vi.
Dynamic binding.
vii.
Message passing.
4. What are objects? (Nov/Dec 2012)
Objects are basic run-time entities in an object – oriented system. They may represent
a person, a place, a bank account, a table of data or any item that the program has to handle.
Each object has the data and code to manipulate the data and these objects interact with each
other.
5.List out the operators that cannot be overloaded. (Nov/dec 2012)
Class member access operator (. , .*)
Scope resolution operator (::)
Size operator ( sizeof )
Conditional operator (?:)
6. Define constructor (Nov/dec 2012)
A constructor is a special member function whose task is to initialize the objects of
its class. It is special because its name is same as class name. The constructor is invoked
DEPT OF IT
AIHT
2
whenever an object of its associated class is created. It is called constructor because it
constructs the values of data members of the class
Eg:
Class integer
{
……
public:
integer( );//constructor
………
}
7. Define default constructor (Nov/dec 2011)
The constructor with no arguments is called default constructor
Eg:
Class integer
{
int m,n;
Public:
Integer( );
…….
};
integer::integer( )//default constructor
{
m=0;n=0;
}
the statement
integer a;
invokes the default constructor
8. Define copy constructor (September 2011)
A copy constructor is used to declare and initialize an object from another object. It
takes a reference to an object of the same class as an argument
Eg: integer i2(i1);
would define the object i2 at the same time initialize it to the values of i1.
Another form of this statement is
Eg: integer i2=i1;
The process of initializing through a copy constructor is known as copy initialization.
function body
}
9. what is an inline function?(Nov 2011)
An inline function is a function that is expanded in line when it is invoked. That is
compiler replaces the function call with the corresponding function code.
The inline functions are defined as
Inline function-header
{
DEPT OF IT
AIHT
3
function body
}
10. What is operator overloading and its advantages?(Nov/Dec 2010 & 2009)
C++ has the ability to provide the operators with a special meaning for a data type. This
mechanism of giving such special meanings to an operator is known as Operator overloading. It
provides a flexible option for the creation of new definitions for C++ operators.
11.What is a class? How is a class declared in C++? (April/May 2010)
The entire set of data and code of an object can be made a user – defined data type
with the help of a class. Once a class has been defined, we can create any number of objects
belonging to the classes.
12. What is dynamic binding or late binding? (April/May 2010)
Binding refers to the linking of a procedure to the code to be executed in response to
the call. Dynamic binding means that the code associated with a given procedure call is not
known until the time of the call at the run – time.
13. What is a scope resolution operator? (April/May 2010)
Scope resolution operator is used to uncover the hidden variables. It also allows access
to global version of variables.
Eg:
#include<iostream.h>
int m=10; // global variable m
void main ( )
{
int m=20; // local variable m
cout<<”m=”<<m<<”\n”;
cout<<”: : m=”<<: : m<<”\n”;
}
output:
20
10 (: : m access global m)
Scope resolution operator is used to define the function outside the class.
Syntax:
Return type <class name> : : <function name>
Eg:
Void x : : getdata()
14. What is static data member?(Nov/Dec 2009)
Static variable are normally used to maintain values common to the entire class.
Feature:
It is initialized to zero when the first object is created. No other initialization is
permitted
only one copy of that member is created for the entire class and is shared by all
the objects
It is only visible within the class, but its life time is the entire class
type and scope of each static member variable must be defined outside the class
DEPT OF IT
AIHT
4
It is stored separately rather than objects
Eg: static int count//count is initialized to zero when an object is created.
int class_name::count;//definition of static data member.
PART – B
1. Explain with examples the types Constructors C++ (Nov/dec 2013).
2. Write a C-I+ program that contains a class String and overloads the following operators on
Strings.
 +to concatenate two strings
 -to delete a substring from the given String
 ==to check for the equivalence of both atring (Nov/dec 2013).
3. Write a Menu driven program for accept two integers and an operator to perform the operation
(+,-,*,/,%) and print the result(16)
(Nov/dec 2012)
4. Specify the class called complex to represent the complex numbers overload (+,-,*) operators
When working on the objects of this class?(16)
(Nov/dec 2012)
5. Explain the merits and demerits of Object oriented paradigm?(6) (Nov/dec 2011)
6. Write a c++ Program to define overloaded constructors and to perform string initialization and
String copy(10)(Nov/dec 2011)
7. Explain the use of copy constructor and function overloading in C++ program(16)
(Nov/dec 2011)
8. Compare and contrast Structured Programming and Object Oriented Programming.
(8)(Nov/dec 2010)
9. Distinguish between Data Encapsulation and Data Abstraction. (4)(Nov/dec 2010)
10. Mention the purpose of Constructor and Destructor functions. (4)(Nov/dec 2010)
11. Explain the control structures of C++ with suitable examples. (12) (Nov/dec 2010)
12 Define function overloading with a simple example. (4) (Nov/dec 2010)
13.Give the syntax and usage of the reserved word in line with two examples.(8) (Apr 2010)
14. What is a friend function? What are the merits and demerits of using friend function?
(8) (Nov 2009)
15. Define a class ‘string’. Use overload ‘= =’ operator to compare two strings. (8) (Nov 2009)
16. What is a parameterized constructor? Explain with example. (8) (Nov 2009)
17. What is a conversion function? How is it created? Explain its syntax. (8) (Nov 2009)
UNIT-II
PART-A
1. What is the need to declare base classes as virtual? (Nov/Dec 2013)
When two or more objects are derived from a common base class, we can prevent multiple
copies of the base class being present in an object derived from those objects by declaring the
base class as virtual when it is being inherited. Such a base class is known as virtual base class.
DEPT OF IT
AIHT
5
2. What is the use of virtual functions in C++? (Nov/Dec 2013)
 Virtual Functions are used to support " Run time Polymorphism".
 You can make a function virtual by preceeding its declaration within the class by
keyword'virtual'.
 When a Base Class has a virtual member function, any class that inherits from the
Base Class can redefine the function with exactly the same prototype i.e. only
functionality can be redefined, not the interface of the function.
3. Define multiple inheritance? (Nov/dec 2012)
If a derived class is derived from more than one base class, then it is called multiple
inheritance.
4. Define Polymorphism?(Nov/dec 2012)
Polymorphism is the feature that allows one interface to be used for a general
class of actions.(ie) “one interface multiple methods”.
This means that it is possible to design a generic interface to a group of related
activites.This helps reduce complexity by allowing the same interface to be used to
specify a general class of action.
5. What is an virtual function? (September 2011, Nov/Dec 2010)
A member function whose definition can be changed during run time is called
virtual function. The class which contains virtual function is called polymorphic class and it
should be a base class. Different versions for the virtual function should be present in different
derived classes with same name as virtual function name.
6. What is meant by inheritance? (Nov/Dec 2010)
Inheritance is the process by which objects of one class acquire the properties of
another class. It supports the concept of hierarchical classification. It provides the idea of
reusability. We can add additional features to an existing class without modifying it by
deriving a new class from it.
7. What are the advantages of inheritance? (Nov/Dec 2010)
 New classes can be derived by the user from the existing classes without any
modification.
 It saves time and money.
 It reduces program coding time.
 It increases the reliability of the program.
8. Write short notes on virtual base class.(Apr 2010)
A base class that is qualified as virtual in the inheritance definition. In case of
multiple inheritance, if the base class is not virtual the derived class will inherit more than
one copy of members of the base class. For a virtual base class only one copy of members
will be inherited regardless of number of inheritance paths between base class and
derived class.
Eg: Processing of students’ results. Assume that class sports derive the roll
number from class student. Class test is derived from class Student. Class result is
derived from class Test and sports.
As a virtual base class As a virtual base class
DEPT OF IT
AIHT
6
9. What is meant by Abstract base class? (Nov/Dec 2009)
A class that serves only as a base class from which derived classes are derived. No
objects of an abstract base class are created. A base class that contains pure virtual
function is an abstract base class.
10. Define abstract class? (Nov/Dec 2009)
A class is said to be an abstract class if it satisfies the following conditions:
 It should act as a base class
 It should not be used to create any objects
PART-B
1.(i) What is inheritance? Explain with examples the different types of inheritance in C++
(ii) What are the different modes in which you can open a file in C++?(4) (Nov2013)
2. (i) Explain how to overload template function with an example.(8)
(Nov2013)
(ii) Explain how to handle multiple exceptions in C++ with an example.(8)
3 Define friend function? What is polymorphism? Explain multiple inheritance? (16)
(Nov/Dec 2012)
4. What is String? Write a c++ Program to sort the given strings alphabetically?(16)
(Nov/Dec 2012)
5. What are the different forms of inheritance supported by c++? Explain with relevant
example code.(16) (Nov/dec 2011)
6. Explain the following concepts with example code :
(a) Exception Handling mechanism(8) (Nov/dec 2011)
(b) Runtime Polymorphism(8) (Nov/dec 2011)
7. What is the use of template? Write an overloaded function template called max( ), which
will find the maximum of any two given integers. (8) (Nov/2010)
8. Explain the exception handling mechanism of C++ in detail. (8) (Nov/2010)
9. Define friend class and specify its importance. Explain with suitable example. (8)
(Apr 2010)
10. Discuss Virtual function and polymorphism with example. (8) (Apr 2010)
11. Explain the concept of inheritance by considering an example of “vehicle”. (8)
(Apr 2010)
12. Explain the operators used for dynamic memory allocation with examples. (8)
(Apr 2009)
DEPT OF IT
AIHT
7
UNIT –III
PART – A
1. What is a priority queue? (Nov 2013)
A priority queue is a queue data structure that has the particular property of being sorted by
priority. You can decide what priority to give items depending on the data type - more on this in
a minute.
2. Define recursion and specify the data structures used to perform recursion.(Nov 2013)
Recursion is an approach in which a function calls itself with an argument. Upon
reaching a termination condition, the control returns to the calling function.
3. Define ADT (Abstract Data Type)? (Nov/dec 2012)
An ADT is a mathematical model with a collection of operations defined on that model.
4. Explain the types of Data Structure? (Nov/dec 2012)
1. PRIMITIVE
These are basic structures and are directly operated upon by the machine instructions.
a. Integer
b. Float
c. Char
d. Pointer.
2. NON-PRIMITIVE
This type of data structure emphasize on structuring of a group of homogeneous or
heterogeneous data items.
a. Arrays
b. Lists
i.
Linear Lists
a. Stack
b. Queue
ii. Non Linear List
a. Graph
b. Tree
c. Files
5. Define dynamic programming algorithm? (Nov 2011)
Dynamic programming algorithm is a general class of algorithms which solve problems
by solving smaller versions of the problem, saving the solutions to the small problems and then
combining them to solve the larger problems.
6. Define Data Structures? (Nov 2011)
Data Structures is a way of organizing data that considers the data to stored and their
relationship with each other. It is representation of the logical relationship between individual
elements of data.
DEPT OF IT
AIHT
8
7. What is binary heap? What are its types? (Nov/dec 2011)
A binary heap is a complete binary tree which satisfies the heap ordering property. The
ordering can be one of two types:


the min-heap property: the value of each node is greater than or equal to the value of its
parent, with the minimum-value element at the root.
the max-heap property: the value of each node is less than or equal to the value of its
8. What are the representations of Big and small ‘O’ notations? (Apr 2010)
Big O notation describes the limiting behavior of a function when the argument tends
towards a particular value or infinity, usually in terms of simpler functions. It is a member of a
larger family of notations that is called Landau notation, Bachmann–Landau notation
9. What do asymptotic notation means? (Apr 2010)
Asymptotic notations are terminology that is introduced to enable us to make meaningful
statements about the time and space complexity of an algorithm.
The different notations are
Big – Oh notation
Omega notation
Theta notation.
10. Define a stack?(Nov/Dec 2010)
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” and “push-down lists”.
11. Write operations that can be done on stack? (Nov/Dec 2010)
PUSH and POP
PART-B
1. Explain the process of inserting and deleting an element. in a circular queue With an
example. (16) (Nov/dec 2013)
2. Explain with an example the formfltion of heap data structure and the properties to be
found in a heap.(16) (Nov/dec 2013)
3. Explain the operations of binary heap(16)(Nov/dec 2012)
4. Write algorithms for insertion and deletion in linked stack(16)(Nov/dec 2012)
5. Write an algorithm and c++ Program for inserting and deleting an element from doubly
linked list(16) (Nov/dec 2011)
6.Describe hash functions? Explain the concept of conflict resolution techniques in
hashing?(16) (Nov/dec 2011)
7. Explain the operations performed on queue in detail. Write a C++ program to implement
these queue operations. (10) (Nov/dec 2010)
8. Explain insertion, deletion and replacement of nodes in a heap. (6) (Nov/dec 2010)
DEPT OF IT
AIHT
9
9. Explain Priority Queues and how are binary heaps used in that. (8) (apr 2010)
10. Explain the properties of heap. (8) (Nov/dec 2010)
11. Write a C ++ program to implement Stack and its operations PUSH and POP. (10)
(Apr 2010)
12. What is hashing? Classify hashing functions based on the various methods. (6)
(Apr 2010)
13. Define double linked list. Explain the various operations of double linked list with
algorithm. (16) (Nov/dec 2009)
14. What is hashing? Explain the various hash functions with example.(10) (Nov/dec 2009)
15. What is priority queue? Discuss the array implementation of priority queue. (6)
(Nov/dec 2009)
UNIT-IV
PART-A
1. What is binary tree? Give example. (Nov/dec 2013)
A binary tree is a finite set of nodes which is either empty or consists of a root and two disjoint
binary trees called the left subtree and the right subtree.
2. In an AVL tree, at what condition the balancing is to be done? (Nov/dec 2013)
In an AVL tree, at what condition the balancing is to be done : If the 'pivotal value' (or the
'Height factor') is greater than 1 or less than -1
3.What is meant by spanning tree? (Nov/dec 2012)
Spanning tree S is a subset of a tree T in which all the vertices of tree T are
Present but it may not contain all the edges.
4.What is meant by minimum spanning tree?(Nov/dec 2011)
The minimum spanning tree of a weighted connected graph G is called
minimum spanning tree if its weight is minimum.
5. How many trees are possible with 3 nodes? (April 2010)
The minimum amount of nodes a binary tree can have is n and the maximum is 2^n-1
6. Define Tree?(Apr 2010)
A tree is a finite set of one or more nodes,there is an distinguished node called root node and
remaining nodes are referred as subtree of the root
7. What is meant by an adjacency matrix? (Nov/dec 2010)
Specifically, the adjacency matrix of a finite graph G on n vertices is the n × n matrix
where the non-diagonal entry aij is the number of edges from vertex i to vertex j, and the
diagonal entry aii, depending on the convention, is either once or twice the number of edges
(loops) from vertex i to itself. Undirected graphs often use the latter convention of counting
loops twice, whereas directed graphs typically use the former convention
DEPT OF IT
AIHT
10
8. State the properties of binary search tree? (Nov/dec 2010)
Each node of a Binary Search Tree (BST) stores a piece of data, called the key . Each node
has below it a left subtree and a right subtree. The topmost node is called the root and a
node with no subtrees is called aleaf.
The most important property of a BST is that
for a node with key k , every key in the left subtree is less
than k and every key in the right subtree is greater than k.
9.Define Graph? (Nov/dec 2009)
The Graph is a collection of Vertices and edges. Let G be the graph then it can be denoted by
G=(V,E) where V is the total number of vertices or nodes in the graph and E is the total number
of edges in the graph.
10. Define AVL tree? (Nov/Dec 2009)
An AVL tree is a binary search tree whose left subtree and right subtree differ in height by no
more than 1, and whose left and right subtrees are themselves AVL trees.
PART –B
1. Explain the process of inserting and deleting an element in the AVL tree with an
example. (16) (Nov/dec 2013)
2. What is a mmimum spanning tree? Explain with an example an algorithm for
constructing a minimum spanning tree. (Nov/dec 2013)
3. Describe the shortest path identification using Dijkstra’s Algorithm?(16) (Nov/dec 2012)
4. What is graph? Explain the depth first search tree?(16) (Nov/dec 2012)
5. Describe an AVL Tree write the algorithm to perform insertion and deletion of a node in
an AVL Tree and justify its worst case with suitable example(16) (Nov/dec 2011)
6. Write the Kruskal’s and Prims algorithms for computing minimal spanning tree?(16)
(Nov/dec 2011)
7. Write an algorithm to traverse binary tree level by level, with each level of the tree being
traversed from left to right. (10) (Nov/dec 2010)
8. Explain spanning tree and minimal spanning tree with examples.(6) (Nov/dec 2010)
9. Define AVL tree. Explain the operations on AVL tree with illustrations. (6)
(Nov/dec 2010)
10. Explain breadth first search algorithm for the traversal of any graph with suitable
examples. Define time complexity of the algorithm. (10) (Nov/dec 2010)
11. Traverse the tree given below using Inorder, Preorder and Postorder traversals. (10)
(Apr 2010)
DEPT OF IT
AIHT
11
12. Convert the expression ((A + B) * C - (D - E) ^ (F + G)) to equivalent Prefix and postfix
notations. (6) (Apr 2010)
13. Convert the given graph with weighted edges to minimal spanning tree. (10) (Apr 2010)
14. Write a short note on AVL trees. (6) (Apr 2010)
15. Discuss the different methods of traversing a binary tree with algorithm.(16)
(Nov/dec 2009)
16. Discuss Prim’s and Kruskal’s algorithm for computing the minimal spanning tree
weighted undirected graph. (16) (Nov/dec 2009)
Unit V Sorting
PART-A
1.Does the minimum spanning tree of a graph give the shortest distance between any2
specified nodes?
(Nov/Dec 2013)
No. The Minimal spanning tree assures that the total weight of the tree is kept at its
minimum. But it doesn't mean that the distance between any two nodes involved in the
minimum-spanning tree is minimum.
2. State why quick sort is more efficient than merge sort
(Nov/Dec 2013)
Quick sort doesn't require extra storage than merge sort dose. it has less complexity
Quicksort also competes with mergesort, another recursive sort algorithm but with the benefit of
worst-case O(n log n) running time. Mergesort is a stable sort, unlike standard in-place quicksort
and heapsort, and can be easily adapted to operate on linked lists and very large lists stored on
slow-to-access media such as disk storage or network attached storage. Although quicksort can
DEPT OF IT
AIHT
12
easily be implemented as a stable sort using linked lists, it will often suffer from poor pivot
choices without random access. The main disadvantage of mergesort is that, when operating on
arrays, efficient implementations require O(n) auxiliary space, whereas the variant of quicksort
with in-place partitioning and tail recursion uses only O(log n) space.
3.What is the worst case,best case and average case analysis of shell sort?(Nov/Dec 2012)
Worst case analysis-O(N2)
Best case analysis-O(NlogN)
Average case analysis-O(N1.5)\
4. List the various sorting techniques?(Nov/Dec 2011)
1. Insertion Sort
2. shell sort
3. Heap sort
4. Quick sort
5. Merge sort
5.What is the worst case,best case and average case analysis of merge sort?(Nov/Dec
2011)
Worst case analysis-O(NlogN)
Best case analysis-O(NlogN)
Average case analysis-O(NlogN)
6. What is dynamic programming?(April/May2010, Nov/Dec 2011)
Dynamic programming algorithm is a general class of algorithms which solve problems
by solving smaller versions of the problem, saving the solutions to the small problems and
then combining them to solve the larger problems.
7.Defie Sorting? (Nov/Dec 2010)
Sorting is the process of arranging the elements either in ascending or descending order.
8.what is the advantage of Merge sort?(Nov/Dec 2010)
Bucket sort, or bin sort, is a sorting algorithm that works by partitioning an array into a
number of buckets. Each bucket is then sorted individually, either using a different sorting
algorithm, or by recursively applying the bucket sorting algorithm. It is a distribution sort, and is
a cousin of radix sort in the most to least significant digit flavor. Bucket sort is a generalization
of pigeonhole sort. Since bucket sort is not a comparison sort, the Ω(n log n) lower bound is
inapplicable. The computational complexity estimates involve the number of buckets.
Bucket sort works as follows:
1. Set up an array of initially empty "buckets".
2. Scatter: Go over the original array, putting each object in its bucket.
3. Sort each non-empty bucket.
DEPT OF IT
AIHT
13
4. Gather: Visit the buckets in order and put all elements back into the original array.
9. What is best case and worst case for binary tree?(Nov/dec 2009)
In either version, this operation requires time proportional to the height of the tree in the
Worst case, which is O(log n) time in the average case over all trees, but O(n) time in the
Worst case.
10. What is Indexed Sequential Search?(Nov/dec 2009)
Sequential search is the simplest form of search. Records can be arranged in a file in two
Ways; one, sequentially one after the other. The other is non-sequential.
PART –B
1. Sort the following values using Quick Sort and estimate its time and space
complexity: 65 70 75 80 85 60 55 50 45 Illustrate each step of the sorting process.
(16)(Nov/dec 2013)
2. Explain any two application areas that use dynamic programming
concept with an example. (16)(Nov/dec 2013)
3. Describe the concepts of bubble sort and merge sort with example?(16)(Nov/dec
2012)
4. With example Explain the binary search techniques(16)(Nov/dec 2012)
5. Write an algorithm of heap sort and bucket sort and implement the C++ Program for
heap sort.(16) (Nov/dec 2011)
6. Explain Greedy algorithm with an example(8) (Nov/dec 2011)
7. What is dynamic programming? List its applications and explain any one?(8)
8. (Nov/dec 2011)
9. Explain heap sort with an illustration. (8) (Nov/dec 2010)
10. Explain the greedy algorithm to find minimum spanning tree. (8) (Nov/dec 2010)
11. Explain the insertion sort with its time complexity. (8) (Nov/dec 2010)
12. Explain as to how divide and conquer technique can be applied for merge sort. (8)
13. (Nov/dec 2010)
14. Explain the algorithm of Quick sort by sorting the following set of numbers as an
example: 42 47 52 57 62 37 32 27 22 (16) (Apr 2010)
15. Describe divide and conquer technique with the help of merge sort. (16) (Apr 2010)
16. Write a ‘C’ program to implement binary search and compute its complexity. (8)
(Nov/dec 2009)
17. Compare the worst case and best case time complexity of various sorting techniques.
(8) (Nov/dec 2009)
18. Explain the all pairs shortest path algorithm with an example. (16) (Nov/dec 2009)
DEPT OF IT
AIHT