Download Data Structures and Object Oriented Programming in C++

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

Linked list wikipedia , lookup

Binary search tree wikipedia , lookup

Transcript
147301 -DATA STRUCTURES AND OBJECT ORIENTED PROGRAMMING IN C++
LTPC 3003
UNIT – I PRINCIPLES OF OBJECT ORIENTED PROGRAMMING
9
Introduction- Tokens-Expressions-contour Structures –Functions in C++, classes and objects, constructors
and destructors ,operators overloading and type conversions .
UNIT – II ADVANCED OBJECT ORIENTED PROGRAMMING
9
Inheritance, Extending classes, Pointers, Virtual functions and polymorphism, File Handling Templates
,Exception handling, Manipulating strings.
UNIT – III DATA STRUCTURES & ALGORITHMS
9
Algorithm, Analysis, Lists, Stacks and queues, Priority queues-Binary Heap-Application, Heaps–hashinghash tables without linked lists
UNIT – IV NONLINEAR DATA STRUCTURES
9
Trees-Binary trees, search tree ADT, AVL trees, Graph Algorithms-Topological sort, shortest path
algorithm network flow problems-minimum spanning tree - Introduction to NP - completeness.
UNIT – V SORTING AND SEARCHING
9
Sorting – Insertion sort, Shell sort, Heap sort, Merge sort, Quick sort, Indirect sorting, Bucket sort,
Introduction to Algorithm Design Techniques –Greedy algorithm (Minimum Spanning Tree), Divide and
Conquer (Merge Sort), Dynamic Programming (All pairs Shortest Path Problem).
TOTAL HOURS = 45
TEXT BOOKS:
1. Mark Allen Weiss, “Data Structures and Algorithm Analysis in C”, 3rd ed, Pearson Education
Asia, 2007.
2. E. Balagurusamy, “ Object Oriented Programming with C++”, McGraw Hill Company Ltd., 2007.
REFERENCES:
1. Michael T. Goodrich, “Data Structures and Algorithm Analysis in C++”, Wiley student edition, 2007.
2. Sahni, “Data Structures Using C++”, The McGraw-Hill, 2006.
3. Seymour, “Data Structures”, The McGraw-Hill, 2007.
4. Jean – Paul Tremblay & Paul G.Sorenson, An Introduction to data structures with applications, Tata
McGraw Hill edition, II Edition, 2002.
5. John R.Hubbard, Schaum’s outline of theory and problem of data structure with C++, McGraw-Hill,
New Delhi, 2000.
6. Bjarne Stroustrup, The C++ Programming Language, Addison Wesley, 2000
7. Robert Lafore, Object oriented programming in C++, Galgotia Publication
UNIT I
PART – A
1. What is an identifier?
Identifiers are names for various programming elements in c++ program. such as variables, arrays,
function, structures, union, labels ect., An identifier can be Composed only of uppercase, lower case
letter, underscore and digits, but should start only with an alphabet or an underscore.
2. What is a keyword?
Keywords are word whose meanings have been already defined in the c compiler. They are also called as
reserved words.
(ex) main(), if, else, else, if, scanf, printf, switch, for, goto, while ect.,
3. Define constant in c++.
Constants in c++ refers to fixed values that do not change during execution of a program.
4. Define a variable.
A quantity ,Which may vary during execution of a program is called as a variable.
5. What are unary operators?
The operators that act upon a single operand are called as unary operators. The unary operators used in
c++ are - , ++, -- and sizeof operators.
6. What are binary operators?
The operators that act upon two operands are called binary operators. The binary operators used in c++
are +, -, *, / , %, =. etc.,
7. What are ternary operators?
The operators that act upon three operands are called as ternary operators. The ternary operator available
in c++ is (?:).This operator is also referred as conditional operator.
8. What is meant by an expression?
An expression is a combination of constant, variable, operators and function calls written in any form as
per the syntax of the c++ language.
9. State the difference between c and c++.
C C++
(i). Procedural programming language Object-oriented programming anguage
(ii) Global variable can be declared It is an error to declare a variable as global
(iii) Function prototypes are optional All functions must be prototyped.
(iv) Local variables can be declared only Local variables can be declared any where
the start of a c program in a c++ program.
(v) We can call a main() function, within This is not allowed
a program.
10. List the various oops concepts
Four main OOP concepts
Abstraction
creation of well-defined interface for an object, separate from its implementation
e.g., key functionalities (init, add, delete, count, print) which can be called independently of knowing how
an object is implemented
Encapsulation
keeping implementation details “private” i.e., inside the implementation hierarchy an object is defined in
terms of other objects Composition => larger objects out of smaller ones
Inheritance => properties of smaller objects are “inherited” by larger
objects
Polymorphism
use code “transparently” for all types of same class of object
i.e., “morph” one object into another object within same hierarchy
11. Define class and object
Class: It is defined as blueprint or it is a collection of objects
Objects: is an instance of a class
Almost like struct, the default privacy specification is private whereas with struct, the default privacy
specification is public
Example:
class point
{
double x, y; // implicitly private
public:
void print();
void set( double u, double v );
};
12. Define inheritance
Inheritance
• Objects are often defined in terms of hierarchical classes with a base class and one or more levels of
classes that inherit from the classes that are above it in the hierarchy.
• For instance, graphics objects might be defined as follows:
Syntax for Inheritance
class derivedClass : public baseClass {
private :
// Declarations of additional members, if needed.
public:
// Declarations of additional members, if needed.
protected:
// Declarations of additional members, if needed.
}
13. Define encapsulation
Encapsulation is one of thr most important features of a class.It is the process os combining member
functions and the data it manipulates by logically binding the data ane keeping them safe from outside
interference.
14. Define abstraction.
Creation of well-defined interface for an object, separate from its implementation
e.g., key functionalities (init, add, delete, count, print) which can be called independently of knowing how
an object is implemented
15. Define polymorphism
Polymorphism means “having many forms”. It allows different objects to respond to the same message in
different ways, the response specific to the type of the object.
E.g. the message displayDetails() of the Person class should give different results when send to a Student
object (e.g. the enrolment number).
16. List out the benefits of oops.
• Can create new programs faster because we can reuse code
• Easier to create new data types
• Easier memory management
• Programs should be less bug-prone, as it uses a stricter syntax and type checking.
• `Data hiding', the usage of data by one program part while other program parts cannot access the data
Will whiten your teeth
17. List out the application of oops.
• Client server computing
• Simulation such as flight simulations.
• Object-oriented database applications.
• Artificial intelligence and expert system
• Computer aided design and manufacturing systems.
18. Define data hiding.
The purpose of the exception handling mechanism is to provide a means to detect and report an
“exceptional circumstance” so that appropriate action can be taken.
19. What is the use of scope resolution operator?
In C, the global version of the variable cannot be accessed from within the inner block. C++ resolves this
problem by introducing a new operator :: called the scope resolution operator. It is used to uncover a
hidden variable.
Syntax:
:: variable name
20. When will you make a function inline?
When the function definition is small, we can make that function an inline function and we can mainly go
for inline function to eliminate the cost of calls to small functions.
21. What is overloading?
Overloading refers to the use of the same thing for different purposes.
There are 2 types of overloading:
• Function overloading
• Operator overloading
22. What is the difference between normal function and a recursive function?
A recursive function is a function, which call it whereas a normal function does not.
Recursive function can’t be directly invoked by main function
23. What are objects? How are they created?
Objects are basic run-time entities in an object-oriented programming system. The class variables are
known as objects. Objects are created by using the syntax:
classname obj1,obj2,…,objn;
(or) during definition of the class:
class classname
{
------}obj1,obj2,…,objn;
24. List some of the special properties of constructor function.
• They should be declared in the public section.
• They are invoked automatically when the objects are created.
• They do not have return types, not even void and cannot return values.
• Constructors cannot be virtual.
Like other C++ functions, they can have default arguments
25. Describe the importance of destructor.
A destructor destroys the objects that have been created by a constructor upon exit from the program or
block to release memory space for future use. It is a member function whose name is the same as the class
name but is preceded by a tilde.
Syntax:
~classname(){ }
26. What do you mean by friend functions?
C++ allows some common functions to be made friendly with any number of classes, thereby allowing
the function to have access to the private data of thse classes. Such a function need not be a member of
any of these classes. Such common functions are called friend functions.
27. What are member functions?
Functions that are declared within the class definition are referred as member function.
28. Define dynamic binding.
Dynamic binding means that the code associated with a given procedure call is not known until the time
of the call at run-time.
1.
2.
3.
4.
5.
PART B
Explain the basic concepts of object oriented programming in detail with example.
List out the benefits and applications of OOPS.
Write a note on the basic data types in C++.
What are control structures?Explain its types with example.
Explain call by reference ,call by value and inline functions in detail using examples.
6.
7.
8.
9.
10.
Define function overloading.write a program to illustrate in detail using examples.
Explain arrays within a class with an example program.
What is friend function?write a program and explain friend function
Explain constructor and Destructor using an example program.
State the rules to be followed while overloading an operator. Write a program to illustrate
overloading.
UNIT-II
PART-A
1.What are the c++ operators that cannot be overloaded?
Size operator (sizeof)
Scope resolution operator (::)
member access operators(. , .*)
Conditional operator (?:)
2. What is a virtual base class?
When a class is declared as virtual c++ takes care to see that only copy of that class is inherited,
regardless of how many inheritance paths exist between the virtual base class and a derived class.
3. What is the difference between base class and derived class?
The biggest difference between the base class and the derived class is that the derived class contains the
data members of both the base and its own data members. The other difference is based on the visibility
modes of the data members.
4. What are the rules governing the declaration of a class of multiple inheritance?
• More than one class name should be specified after the : symbol.
• Visibility modes must be taken care of.
If several inheritance paths are employed for a single derived class the base class must be appropriately
declared
5. Mention the types of inheritance.
1.Single inheritance.
2. Multiple inheritance.
3. Hierarchical inheritance.
4. Multilevel inheritance.
5. Hybrid inheritance.
6. Define dynamic binding.
Dynamic binding means that the code associated with a given procedure call is not known until the time
of the call at run-time.
7. What do u mean by pure virtual functions?
A pure virtual function is a function declared in a base class that has no definition relative to the base
class. In such cases, the compiler requires each derived class to either define the function or redeclare it as
a pure virtual function. A class containing pure virtual functions cannot be used to declare any objects of
its own.
8. What are templates?
Templates enable us to define generic classes. A template can be considered as a kind of macro. When an
object of a specific type is defined for actual use, the template definition for that class is substituted with
the required data type. Since a template is defined with a parameter that would be replaced by the specific
data type at the time of actual use of the class or function, the templates are sometimes called
parameterized classes or functions
9. What is exception handling?
The purpose of the exception handling mechanism is to provide a means to detect and report an
“exceptional circumstance” so that appropriate action can be taken.
10. Give the general format of class template.
The general format of a class template is:
template
class classname
{
//………
//class member specification
//with anonymous type T
//wherever appropriate
//………
};.
11. List the kinds of exception.
Exceptions are of two kinds namely
• Synchronous exceptions
• Asynchronous exceptions
12. What are the errors in synchronous type exceptions?
Errors such as “out-of-range index” and “over-flow” belong to the synchronous type exceptions.
13. What are the errors in asynchronous type exceptions?
The errors that ware caused by errors beyond the control of the program (such as keyboard interrupts) are
called asynchronous exceptions.
14. What are the tasks that are performed by the error handling mechanism?
The mechanism suggests a separate error handling code that performs the following tasks:
1) Find the problem (Hit the exception).
2) Inform that an error has occurred (Throw the exception).
3) Receive the error information (Catch the exception).
4) Take corrective actions (Handle the exception).
15. Mention the key words used in exception handling.
The keywords used in exception handling are
• throw
• try
• catch
16. List the ios format function.
The ios format functions are as follows:
• width()
• precision()
• fill()
• setf()
• unsetf()
17. List the manipulators.
The manipulators are:
• setw()
• setprecision()
• setfill()
• setiosflags()
• resetiosflags()
18. Mention the equicalent ios function for manipulators.
Manipulator Equivalent ios function
setw(int w) width()
setprecision(int d) precision()
setfill(int c) fill()
setiosflags(long f) setf()
resetiosflags(long f) unsetf()
endl “\n”
19. Define fill functions.
The fill( ) function can be used to fill the unused positions of the field by any desired character rather than
by white spaces (by default). It is used in the following form:
cout.fill(ch);
where ch represents the character which is used for filling the unused positions. For example, the
statements
cout.fill(‘*’);
cout.width(10);
cout<<5250<<”\n”;
will produce the following output:
20 .Give the syntax of exception handling mechanism.
The syntax of exception handling mechanism is as follows:
try
{
--------------------throw exception
--------------------}
catch(type arguments)
{
----------------------------------------}
------------------------------------------PART – B
1. Explain multiple inheritances with suitable c++ coding.
2. Define polymorphism. Explain the different types of polymorphism.
3. Explain multiple catch statement with help of suitable C++ coding.
4. Describe the various file modes and its syntax.
5. What is virtual base class? Explain using a program.
6.Explain elaborately the exception handling mechanism.
7.Give an example program and explain multiple catch statement using that.
8.Explain this pointer using a program.
UNIT-III
PART-A
1.Write down the definition of data structures?
A data structure is a mathematical or logical way of organizing data in the memory that consider not
only the items stored but also the relationship to each other and also it is characterized by accessing
functions.
2. Give few examples for data structures?
Stacks, Queue, Linked list, Trees, graphs
3. Define Algorithm?
Algorithm is a solution to a problem independent of programming language. It consist of set of finite
steps which, when carried out for a given set of inputs, produce the corresponding output and terminate
in a finite time.
4. What are the features of an efficient algorithm?
• Free of ambiguity
• Efficient in execution time
• Concise and compact
• Completeness
• Definiteness
• Finiteness
5. List down any four applications of data structures?
Compiler design
Operating System
Database Management system
Network analysis
6. What is meant by an abstract data type (ADT)?
An ADT is a set of operation. A useful tool for specifying the logical properties of a datatype is the
abstract data type.ADT refers to the basic mathematical concept that defines the datatype.
Eg.Objects such as list, set and graph along their operations can be viewed as ADT's.
7. What are the operations of ADT?
Union, Intersection, size, complement and find are the various operations of ADT.
8. What is meant by list ADT?
List ADT is a sequential storage structure. General list of the form a1, a2, a3.…., an and the size of the
list is 'n'. Any element in the list at the position I is defined to be ai, ai+1 the successor of ai and ai-1 is
the predecessor of ai.
9. What are the two parts of ADT?
• Value definition
• Operator definition
10. What is a Sequence?
A sequence is simply an ordered set of elements.A sequence S is sometimes written as the enumeration
of its elements,such as
S =If S contains n elements,then length of S is n.
11. Define len(S),first(S),last(S),nilseq ?
len(S) is the length of the sequence S.
first(S) returns the value of the first element of S
last(S) returns the value of the last element of S
nilseq :Sequence of length 0 is nilseq .ie., contains no element.
12. What are the two basic operations that access an array?
Extraction:
Extraction operation is a function that accepts an array, a ,an index,i,and
returns an element of the array.
Storing:
Storing operation accepts an array , a ,an index i , and an element x.
13. Define Structure?
A Structure is a group of items in which each item is identified by its own identifier ,each of which is
known as a member of the structure.
14. Define Union ?
Union is collection of Structures ,which permits a variable to be interpreted in several different ways.
15. Define Automatic and External variables?
Automatic variables are variables that are allocated storage when the function is invoked.
External variables are variables that are declared outside any function and are allocated storage at the
point at which they are first encountered for the remeinder of the program’s execution.
16. What is a Stack?
A Stack is an ordered collection of items into which new items may be inserted and from
which items may be deleted at one end, called the top of the stack. The other name of stack is
Last-in -First-out list.
17. What are the two operations of Stack?
• _ PUSH
• _ POP
18. What is a Queue?
A Queue is an ordered collection of items from which items may be deleted at
one end called the front of the queue and into which tems may be inserted at
the other end called rear of the queue.Queue is called as First–in-FirstOut(FIFO).
19. What is a Priority Queue?
Priority queue is a data structure in which the intrinsic ordering of the elements does determine the
results of its basic operations. Ascending and Descending priority queue are the two types of Priority
queue.
20. What is a linked list?
Linked list is a kind of series of data structures, which are not necessarily adjacent in memory. Each
structure contain the element and a pointer to a record containing its successor.
21. What is a doubly linked list?
In a simple linked list, there will be one pointer named as 'NEXT POINTER' to point the next element,
where as in a doubly linked list, there will be two pointers one to point the next element and the other to
point the previous element location.
22. Define double circularly linked list?
In a doubly linked list, if the last node or pointer of the list, point to the first element of the list,then it is a
circularly linked list.
23. What is a circular queue?
The queue, which wraps around upon reaching the end of the array is called as circular queue.
24. Define max and min heap?
A heap in which the parent has a larger key than the child's is called a max heap.
A heap in which the parent has a smaller key than the child is called a min heap.
PART – B
1. Explain how pointer are used to implement linked list structure.
2. Explain various operation performed on the doubly linked list.
3. Give linked list implementation of stack operation.
4. What is a stack? Explain any two operations performed on a stack with required algorithm.
5. State and explain the priority queue with example..
6. Explain, with example the basic heap operations and write the algorithms for the same.
7. Explain the cursor implementation of list ADT with appropriate functions.
8. Explain the array implementation of queue ADT with appropriate functions.
9.What is binary heap? Mention its properties and explain its various operations.
10.How is hash tables implemented? Explain open addressing in detail.
UNIT – IV
PART – A
1. Define non-linear data structure?
Data structure which is capable of expressing more complex relationship than that of physical adjacency
is called non-linear data structure.
2. Define tree?
A tree is a data structure, which represents hierarchical relationship between individual Data items.
3.Define child and parent of a tree.
The root of each subtree is said to be a child of ‘r’ and ‘r’ is the parent of each subtree root.
4. Define leaf?
In a directed tree any node which has out degree o is called a terminal node or a leaf.
5. What is a Binary tree?
A Binary tree is a finite set of elements that is either empty or is partitioned into three disjoint subsets.
The first subset contains a single element called the root of the tree. The other two subsets are themselves
binary trees called the left and right sub trees.
6. What are the applications of binary tree?
Binary tree is used in data processing.
a. File index schemes
b. Hierarchical database management system
7. What is meant by traversing?
Traversing a tree means processing it in such a way, that each node is visited only once.
8. What are the different types of traversing?
The different types of traversing are
a.Pre-order traversal-yields prefix form of expression.
b. In-order traversal-yields infix form of expression.
c. Post-order traversal-yields postfix form of expression.
9. What are the two methods of binary tree implementation?
Two methods to implement a binary tree are,
a. Linear representation.
b. Linked representation
10. Define Graph?
A graph G consist of a nonempty set V which is a set of nodes of the graph, a set E which is the set of
edges of the graph, and a mapping from the set for edge E to a set of pairs of elements of V.
It can also be represented as G=(V, E).
11. Define adjacent nodes?
Any two nodes which are connected by an edge in a graph are called adjacent nodes. For Example, if and
edge xÎE is associated with a pair of nodes (u,v) where u, v Î V, then we say that the edge x connects the
nodes u and v.
12.Name the different ways of representing a graph?
a. Adjacency matrix
b. Adjacency list
13. What are the two traversal strategies used in traversing a graph?
a. Breadth first search
b. Depth first search
14. What is an acyclic graph?
A simple diagram which does not have any cycles is called an acyclic graph.
15. Give some example of NP complete problems.
Hamiltonian circuit.
Travelling salesmen problems
16.What are AVL trees?
An AVL tree is a binary search tree with a balancing condition.For every node in the tree the heigh of the
left and right subtrees can differ at most by 1.The height of an empty tree is defined to be -1.It ensures
that the depth of the tree is O(log N)
17.What is topological sort?
A topological sort is an ordering of vertices in a directed acyclic graph,such that if there is a path from vi
then vj appears after vi in the ordering.
18.What is single source shortest path problem?
Given as an input a weighted graph, G=(V,E) and a distinguished vertex,’s’ find the shortest weighted
path from ‘s’ to every other vertex in G.
19.Mention some shortest –path problems.
Unweighted shortest paths
Dijikstra’s algorithm
All-pairs shortest paths
20.What are the algorithms used to find the minimum spanning tree?
Prim’s algorithm
Kruskal’s algorithm
PART B
1. Explain Dijkstra’s algorithm using the following graph. Find the shortes path between
v1,v2,v3,v4,v5,v6 & v7.
2. Write ADT operation for Prim’s Algorithm.
3. Explain the topological sort algorithm.
4. Write suitable ADT operation for shortest path problem. Show the simulation of shortest path with an
example graph.
5. How do you construct a minimum cost spanning tree with Prim’s algorithm?
6. Explain depth first search on a graph with necessary data structures.
7. Discuss and write the program to perform topological sorting.
8. What is single source shortest path problem? Discuss Dijkstra’s single source shortest path algorithm
with an example.
9. Write an algorithm to find the minimum cost spanning tree of an undirected weighted graph.
10. Explain Depth – first & Breadth – First Traversal algorithms.
11. Explain Kruskal’s algorithm with an example.
UNIT V
PART A
1. What is meant by sorting?
Ordering the data in an increasing or decreasing fashion according to some relationship among the data
item is called sorting.
2. What are the two main classifications of sorting based on the source of data?
a. Internal sorting
b. External sorting
3. What is meant by 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.
4. What is meant by internal sorting?
Internal sorting is a process of sorting the data in the main memory.
5. What are the various factors to be considered in deciding a sorting algorithm?
a. Programming time
b. Execution time of the program
c. Memory needed for program environment
6. What is the main idea in Bubble sort?
The basic idea underlying the bubble sort is to pass through the file sequentially Several times. Each pass
consists of comparing each element in the file with its successor (x[i] and x[i+1] and interchanging the
two elements if they are not in proper order.
7. What is the basic idea of shell sort?
Instead of sorting the entire array at once, it is first divide the array into smaller
segments, which are then separately sorted using the insertion sort.
8. What is the purpose of quick sort?
The purpose of the quick sort is to move a data item in the correct direction, just
enough for to reach its final place in the array.
9. What is the advantage of quick sort?
Quick sort reduces unnecessary swaps and moves an item to a greater distance, in one move.
10. What is the average efficiency of heap sort?
The average efficiency of heap sort is 0 (n(log2 n)) where, n is the number of
elements sorted.
11. Define Algorithm.
An algorithm is clearly specified set of simple instructions to be followed to
solve a problem. The algorithm forms a base for program.
12. What is complexity analysis?
It is the analysis of the amount of memory and time an algorithm requires to
completion.
There are two types of Complexity
• Space Complexity
• Time Complexity
13. What is performance analysis of an algorithm?
The analysis of the performance of an algorithm based on specification is called
performance analysis. It is loosely divided into
a. Priori estimates
b. Posterior Testing
14. Define space complexity.
Space complexity of an algorithm is the amount of memory it needs to run to
completion.
15. Define time complexity.
Time complexity is the amount of computer time an algorithm requires to run
to completion.
16. What does asymptotic notation mean?
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.
17. Define best case of an algorithm.
It is the shortest time that an algorithm will use over all instances of size n for
a given problem to produce the result.
18. What is divide and conquer technique?
Divide and Conquer algorithm is based on dividing the problem to be solved
into several, smaller sub instances, solving them independently and then combining
the sub instances solutions so as to yield a solution for the original instance.
19. What is dynamic programming?
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.
20. Define Greedy method.
The greedy method suggests that one can devise an algorithm that works in stages, considering one input
at a time. At each stage, a decision is made regarding whether a particular input is an optimal solution. An
example for solution using greedy method is ‘knapsack problem’.
21.List some algorithms uses Dynamic Progrmming.
Matrix-chain multiplication
Optimal Binary Search Tree
0-1knapsack problem
All-pairs Shortest Path
22.List some algorithms uses Greedy approach.
Dijikistra’s algorithms.,Prim’s algorithms. ,Kruskal’s algorithms.
23.What is ahellsort also called?
Shellsort is also called as diminishing increment sort.
24.What is the basic strategy of merge sort?
Mergesort is the technique which has sorted subarrays which are merged to form a single sorted array.
25.What are the techniques used to choose the pivot element for quicksort?
The various techniques are First element,Random pick Median of three portioning
26.How many pointers are used for quicksort?
Quicksort requires two scans one from left to right and another from right to left,so two pointers needed
for the scans.
27.How many pointers are used in mergesort?
Three pointers are used in mergesort. ‘Aptr for the first sorted subarray,’Bptr’ for the second sorted
subarray and ‘cptr’ for the merged sorted subarray
PART B
1. Write a short note on analysis of algorithm. Discuss the various notations and their complexities.
2. Explain dynamic programming with a suitable example.
3. Explain the various notations used in the analysis of algorithms.
4. Explain any two algorithm design techniques with suitable examples.
5. Explain divide & conquer technique with a suitable example.
6. Derive the best, average, worst case time complexity of a linear search. (May/June 2007)
7. With an example, explain how you will measure the efficiency of an algorithm. (8) (April/May 2008)
8. Write quick sort algorithm and explain.
9. State and explain the algorithm to perform heap sort.
10. State and explain the huffman’s algorithm.