Vous êtes sur la page 1sur 30

Ex No.

1a

IMPLEMENTATION OF CALL BY REFERENCE, CALL BY VALUE AND


CALL BY ADDRESS

AIM:

To Write a C++ Program using Call by Reference, Call by Value and Call by Address.
OBJECTIVE:

After the completion of this exercise student will be able to

Understand the concept of pointers.

Understand the concept of functions.

Write programs using functions by passing values and address, reference.

THEORY:

Calling the function by passing the value as an argument is known as call by value. Calling
the function by passing the address of the variable as an argument is known as call by address.
Calling the function by using the reference of the variable is known as call by reference.
ALGORITHM:

STEP 1: Start the Program


STEP 2: Declare the Variables
STEP 3: Read the values by using Call by value and call by reference
STEP 4: Swap the two values of a given number
STEP 5: Print that two values
STEP 6: Stop the program
OUTPUT:

Enter the Value of A : 10


Enter the value of B : 20
Before the Swap1 : 10

20

After the Swap1

: 20

10

Before the Swap2

: 10

20

After the Swap2

: 20

10

RESULT:

Thus a C++ program for illustration of Call by Reference, Call by Value and Call by
Address has been executed successfully.

Viva Questions:
ACET/ECE/DSOOPS/2013-14

1.What is meant by Pointer?


2. What is function?
3..What is the difference between call by value and call by reference?
4.Where you can write a function definition in a program?
5.Is it possible to return a function with reference?

Ex No. 1b

CLASSES AND OBJECTS

AIM:

To write a C++ program to prepare student mark list using arrays.


OBJECTIVE:

After the completion of this exercise student will be able to

Understand the concept of arrays.

Understand the concept of classes.

Write programs using classes with array as data members.

ALGORITHM:

1. Start the process.


2. Create a class student.
3.

Functions getdata,res & display are declared under public.

4.

Read the value of name,regno,mark1,2,3.

5.

Calculate the total,average,grade.

6.

Print the result.

7.

Stop the process.

OUTPUT:

Enter the Number of Students :2


Enter Student Name : Vijay
Enter Reg No. : 1001
Enter Mark1 : 78
Enter Mark2 : 90
Enter Mark3 : 89
Enter Student Name : Raju
Enter Reg No. : 1002
Enter Mark1 : 67
Enter Mark2 : 70
Enter Mark3 : 68

MARKLIST
ACET/ECE/DSOOPS/2013-14

REG NO. NAME

M1

M2

M3

TOTAL AVERAGE GRADE

1001

Vijay

78

90

89

257

85

1002

Raju

67

70

68

215

68

RESULT:

Thus a C++ program for classes and objects mark list preparation has been executed
successfully.
Viva Questions:
1.What is meant by array?
2. List the types of arrays.
3. How will you initialize three dimensional arrays?
4. Is it possible to store string values to an array?
5. Is it possible to create array of objects in C++?
Ex No. 1c

OPERATOR OVERLOADING

AIM:

To write a C++ program for basic operations by using unary operator overloading function.
OBJECTIVE:

After the completion of this exercise student will be able to

Understand the concept of unary operators.

Write programs using classes with unary operator overloading functions.

THEORY:

Calling or overloading the function by using the unary operator is called unary operator

overloading. E.g.
class math

}}

void main ()

int a;

public:

math a;

math() { cin>>a;}
void operator ++() { cout<< c=a+5;

a++;
}

ALGORITHM:

STEP 1: Start the program


STEP 2: Declare the variable, which is used for the operation
STEP 3: Get the values for the variable, which are declared.
ACET/ECE/DSOOPS/2013-14

STEP 4: Create a class and get a value from the main and perform the operation
STEP 5: When any operator in the main is executed then it calls the corresponding
function
STEP 6: This process of calling and accessing the function by using operator is called as
operator overloading
STEP 7: Now the corresponding operator is done and the value is return that value and stop
the program
OUTPUT :

Enter the value of X: 2


The result is: -2
RESULT:

Thus a C++ program for illustration of unary operator overloading has been written and
executed successfully.
Viva Questions:
1.What are unary operators?
2.What is the difference between unary operators and binary operators?
3.How can you define operator overloading function?
4.What is the use of operator overloading?
5.What is the syntax for unary operator overloading?
6. What is the syntax for binary operator overloading?

Ex No. 1d

SINGLE INHERITANCE

AIM:

To write a C++ program for getting a mark list of the Student using Single Inheritance
OBJECTIVE:

After the completion of this exercise student will be able to

Understand the concept of inheritance.

Write programs using classes with inheritance.

Know the importance of inheritance in C++.

THEORY:

Deriving the Properties of single base class in the single derived class .It increases the
reusability of the classes. The colon ( : ) is used for inheriting the base class in the derived class.

E.g.
ACET/ECE/DSOOPS/2013-14

class math()

add() {

cout<<c=a+b;

int a,b;

math()

{ cin>>a>>b;}

void main() {

}int c;

add a;}

ALGORITHM:

STEP 1: Start the program


STEP 2: Declare the variables and functions with in the class
STEP 3: Declare the class as a inherited class
STEP 4: Read the values such as Rollno, Name, Mark1, Mark 2 values
STEP 5: Find the total values
STEP 6: Print the total values of the student
STEP 7: Create the object for the inherited class
STEP 8: print the Name,Rollno,mark1,mark2 and Total vales
STEP 9: Stop the program
OUTPUT:

Enter the Rollno: 101

Rollno: 101

Enter the Name : Ram

Name: Ram

Enter two Marks : 70 80

Mark1: 70
Mark2: 80
Total:120

RESULT:

Thus the Mark list preparation using Single Inheritance has been written and verified
successfully.
Viva Questions:
1.What do you understand by the term inheritance?
2.List the types of inheritance.
3.What is the use of inheritance?
4.Mention the available access specifiers in C++.
5.Is it possible to use constructor in inheritance?
6.What is multilevel inheritance?
EX No. 2

ARRAY IMPLEMENTATION OF LIST ADT

ACET/ECE/DSOOPS/2013-14

AIM:

To implement the list ADT using arrays in C.


OBJECTIVE:

After the completion of this exercise student will be able to

Understand the concept of data structures.

Implement Array in List ADT.

To perform insertion, deletion, search operations in List ADT.

ALGORITHM:

1.

Start the program.

2.

Create a class list.

3.

Functions create(),insert(),search(),display(),del().

4.

Declare the required number of variables and assign a value for required variables.

5.

Get the option from the user whether to create,insert,delete, Search or display the list.

6.

For create operation, get the number of elements from the user.

7.

For insert operation operation, get the position where to insert a number in the list and get
the value to be inserted, insert the number after that position.

8.

For deletion operation,get then position in the list to be Deleted and delete the value from
that position.

9.

For search operation,get the value to be searched. Search the Number and display its
position and if the value is not available, Then display that the value is not available in the
list.

10. For display operation, display all the values in the list.
11. Stop the process.

ACET/ECE/DSOOPS/2013-14

Output:
Array Implementation of Linked List.
_____________________________________

Enter Your Choice...:5

1. Creation.

The array Elements are...

2. Insertion.

496725

3. Deletion.
4. Searching.

Enter Your Choice...:3

5. Display.

Enter The Position in which element to be

6. Exit.

deleted : 4

Enter Your Choice...:1

The element is deleted successfully.

Enter The Number Of Elements :5


Enter Your Choice...:5
Enter The Elements One By One....

The array Elements are...

49725

49625

The Given Elements are Created Successfully.


Enter Your Choice...:5

Enter Your Choice...:4

The array Elements are...

Enter The element to be searched :2

49725

The Element is present at 4 position.

Enter Your Choice...:2


Enter The position after which the elements are to

Enter Your Choice...:5

be

The array Elements are...

inserted : 2

49625

Enter The Element to be inserted :6


The Element is inserted successfully.

RESULT:

Thus a C program for Array Implementation of Linked List has been written and executed
successfully.
Viva Questions:
1.Is list a linear or non linear data structure?
2.Can you insert elements at the middle of a list?
3.Write the steps to delete an element from list.
4.What is the different between linear and non linear data structures?
5.What is ADT?
EX No. 3

LINKED LIST IMPLEMENTATION OF LIST ADT

ACET/ECE/DSOOPS/2013-14

AIM:

To perform the list operations by implementing linked list in C++.


OBJECTIVE:

After the completion of this exercise student will be able to

Understand the concept of data structures.

Implement linked list in List ADT.

To perform insertion, deletion, search operations in Linked List ADT.

Understand the difference between array & linked list implementation in list ADT.

ALGORITHM:

1.

Start the program.

2.

Create a structure for list named node.

3.

Create a class slink.

4.

Functions create(),insert(),search(),display(),del().

5.

declare the required number of variables and assign a value for required variables.

6.

Get the option from the user whether to create,insert,delete,Search or display the list.

7.

For create operation, get the number of elements from the user.

8.

For insert operation , get the position where to insert a number in the list and get the value
to be inserted, insert the number after that position.

9.

For deletion operation, get then position in the list to be Deleted and delete the value from
that position.

10. For search operation, get the value to be searched. Search the Number and display its
position and if the value is not available, Then display that the value is not available in the
list.
11. For display operation,display all the values in the list.
12. Stop the process.
OUTPUT:

LINKED LIST IMPLEMENTATION


1. Creation
2. Insertion
3. Deletion
4. Search
5. Display
6. Exit
ACET/ECE/DSOOPS/2013-14

Enter your choice : 1


press 0 to stop the insertion
47930
Enter your choice : 5
4 -> 7 -> 9 -> 3-> NULL
Enter your choice : 2
Enter the Number to be inserted 6
Enter the location after which to be inserted 3
The Number is Inserted.
Enter your choice : 5
4 -> 7 -> 9 -> 6 -> 3-> NULL
Enter your choice : 3
Enter the position to be deleted. 2
The Number at the position 2 is deleted.
Enter your choice : 5
4 -> 9 -> 6 -> 3-> NULL
Enter your choice : 4
Enter the Element to Be searched. 3
The Element is found at the position 4
Enter your choice : 4
Enter the Element to Be searched. 8
Enter your choice : 6

RESULT:

Thus a C++ program for Linked list Creation of List ADT has been written and executed
successfully.
Viva questions:
1.What is linked list?
2.What is the difference between array list and linked list?
3.How will you search an element at linked list?
4.How will you delete an element from linked list?
5. How will you insert an element into linked list?
6.What is the procedure to insert an element at the beginning of linked list?

ACET/ECE/DSOOPS/2013-14

EX No.4

CURSOR IMPLEMENTATION OF LIST ADT

AIM:

To perform cursor implementation of list ADT using C++.


OBJECTIVE:

After the completion of this exercise student will be able to

Implement cursor in List ADT.

To perform insertion, deletion, search operations in cursor implementation of List ADT.

Understand the difference between cursor & linked list implementation of list ADT.

ALGORITHM:

1. Start the program.


2. Create a class cur.
3. Functions create(),del(),search(),display()and quit() are declared under public.
4. Create a menu to execute all these functions.
5. In create, get the number of elements to be inserted. If the limit is within the maximum
size then get the Elements one by one. Otherwise get the another value.
6. In display, the elements in the list are displayed.
7. In search, get the elements to be searched. If the Element is available in the list, then
its position is returned. Otherwise displays that the element is not available.
8. In del(),get the element to be deleted and it is removed from the list.
8. Stop the process.
OUTPUT :

Cursor Implementation of Linked List


1.Create.
2.Display.
3.Search
4.Delete.
5.Quit.
Enter Your Choice.. :
1
How many Elements do u want in the list : 4
Enter the Elements one by one..
4
2
7
1
The List is successfully Created.
Enter Your Choice.. : 2
ACET/ECE/DSOOPS/2013-14

10

the List is....


4
2
7

Enter Your Choice.. : 3


Enter the Number to be searched : 7
The Given Number is at the Position 3
Enter Your Choice.. : 4
Enter the Number to be searched : 6
The Given Number is not in the List.
The Element is now deleted.
Enter Your Choice.. : 4
Enter the Number to be searched : 2
The Given Number is at the Position 2
The Element is now deleted.
Enter Your Choice.. : 5
RESULT:

Thus the Cursor implementation of List ADT has been written and executed successfully.
Viva Questions:
1.What is the use of cursor?
2.How will you serach an element in cursor list?
3.How will you delete an element from cursor list?
4. How will you insert an element to cursor list?
5.what is the difference between cursor list and array list?

ACET/ECE/DSOOPS/2013-14

11

EX No. 5.A

STACK ADT
ARRAY IMPLEMENTATION OF STACK

AIM:

To perform stack operations by implementing arrays in C++.


ALGORITHM:

1.

Start the program.

2.

Create a class stack.

3.

Functions push(),pop(),display() are declared under public.

4.

Create a menu for push, pop, display and exit.

5.

For push operations, read the element from the user and check
a. Whether the stack is full. If so, display stack overflow
b. Otherwise insert it to the top of the stack.

6.

For pop operations, check


a. whether the stack is empty.
b.If so,display stack empty else remove the element from the top of the stack

7.

For display operations , display all the elements of the stack.

8.

Stop the process.

OUTPUT:

STACK OPERATIONS-ARRAY IMPLEMENTATION


1.PUSH
2.POP
3.DISPLAY
4.EXIT
Enter Your Choice...: 1
Enter the item to be pushed... : 45
The Item is Pushed into the stack.
Enter Your Choice...: 1
Enter the item to be pushed... : 67
The Item is Pushed into the stack.
Enter Your Choice...: 1
Enter the item to be pushed... : 32
The Item is Pushed into the stack.
Enter Your Choice...: 3
The items pushed in the are....
ACET/ECE/DSOOPS/2013-14

12

45 67 32
Enter Your Choice...: 2
The Top Item is poped out.
Enter Your Choice...: 3
The items pushed in the are....
45 67
Enter Your Choice...: 4
RESULT:

Thus the Array implementation of Stack has been written and executed successfully.
Viva Questions:
1.
2.
3.
4.
5.
6.
7.
8.

Give the application of stack.


What is O notation?
List the characteristics of stack.
How will you delete an element from Stack?
How will you insert an element into Stack?
How will you check Stack overflow?
How will you check Stack underflow?
How do you overcome the difficulties of array implementation of list?

Ex. NO 5.B.

LINKED LIST IMPLEMENTATION OF STACK

AIM:

To perform stack operations by implementing linked list in C++.


ALGORITHM:

1.

Start the program.

2.

Create a class stack.

3.

Functions push(),pop(),display() are declared under public.

4.

Create a menu for push, pop, display and exit.

5.

For push operations, read the element from the user and check
a. Whether the stack is full. If so, display stack overflow
b. Otherwise insert it to the top of the stack.

6.

For pop operations, check


a. whether the stack is empty.
b.If so, display stack empty else remove the element from the
top of the stack

7.

For display operations , display all the elements of the stack.

8.

Stop the process.

ACET/ECE/DSOOPS/2013-14

13

OUTPUT:

List Implementation Of stack.


_________________________________
1.Push
2.Pop
3.Display
4.Exit
Enter Your Choice : 1
Enter an element to be pushed : 56
The Element is pushed into the stack.
Enter Your Choice : 1
Enter an element to be pushed : 67
The Element is pushed into the stack.
Enter Your Choice : 1
Enter an element to be pushed : 78
The Element is pushed into the stack.
Enter Your Choice : 3
The elements in the stack are...
56 -> 67 -> 78 -> NULL
Enter Your Choice : 2
78 is popped out of the stack.
The top element is popped out of the stack
Result:
Thus the Linked list implementation of Stack has been written and executed successfully
Viva Questions:
1.
2.
3.
4.
5.
6.
7.

Give the application of stack.


What is big O notation?
List the characteristics of stack.
How will you delete an element from Stack in linked list implementation?
Is stack is a linear or non linear data structure?
List the applications of Linked List.
List the advantages and disadvantages of Linked List.

ACET/ECE/DSOOPS/2013-14

14

Ex No. 6

APPLICATION OF STACK (Infix to Postfix Conversion)

AIM:

To convert the given infix expression to postfix expression.


ALGORITHM:

1. Use the stack created in 5A or 5B to convert the given infix expression to postfix
expression.
2. Start the process
3. Q is the arithmetic expression of infix form. equivalent postfix expression P is needed by
stack application.
4. scan Q from left to right and repeat steps 4 to 7 for each element of Q until stack is empty.
5. if an operand is encountered add it to P
6. if left paranthesis is encountered push it to stack
7. if an operator is encountered
a) repeatedly pop from stack and add P each operator which has the same precedence
as or higher precedence than that operator.
b) Add that operator to stack
8. if a right paranthesis is encountered tyhen
a)repeatedly pop from stack and add to P each operator.
b)remove the left paranthesis
8. Print results.
OUTPUT:

Enter infix expression :

a+b
ab+

RESULT:

Thus the given infix expression has been converted to postfix expression successfully.
Viva Questions:
1. Write the prefix and postfix form of the expression (A+B)/(C-D)
2. What is infix notation?
3. What is prefix notation?
4. What is postfix notation?
5. What are the various operations performed on the stack?
6. Is it possible to have more than one stack in an array.
7. Name any two applications of stack?
8. What are the postfix and prefix forms of the expression?
A+B*(C-D)/(P-R)
Postfix form: ABCD-*PR-/+
Prefix form: +A/*B-CD-PR
ACET/ECE/DSOOPS/2013-14

15

Ex No. 7.A.

QUEUE ADT
ARRAY IMPLEMENTATION OF QUEUE ADT

AIM:

To perform queue operations by implementing arrays in C++.


ALGORITHM:

1.

Start the program.

2.

Create a class queue.

3.

Functions enqueue(),dequeue(),display() are declared under public.

4.

Create a menu with enqueue, dequeue, display and exit.

5.

For enqueue ,get the element from the user.Check


a. if rear>=size. If so, display queue is full
b. Otherwise, insert the element at the rear end of the queue.

6. For dequeue, Check


a. if front=rear. If so,display the queue is empty.
b. else, remove the element from the front end of the queue.
7. For display, display all the elements from the queue.
8. Stop the process.
OUTPUT:

QUEUE OPERATIONS
****************
1.Enqueue
2.Dequeue
3.Display
4.Exit
Enter Your choice...: 1
Enter the item to be inserted.. : 56
The Element is inserted into the Queue.
Enter Your choice...: 1
Enter the item to be inserted.. : 34
The Element is inserted into the Queue.
Enter Your choice...: 1
Enter the item to be inserted.. : 78
ACET/ECE/DSOOPS/2013-14

16

The Element is inserted into the Queue.


Enter Your choice...: 3
The items in the Queue are...
56 34 78
Enter Your choice...: 2
The Item 56is removed from the queue.
Enter Your choice...: 3
The items in the Queue are...
34 78
.
Enter Your choice...: 4
RESULT:

Thus the Array implementation of Queue ADT has been executed and verified successfully.
Viva Questions:
1. What is meant by Queue?
2. List the applications of Queue.
3. What is meant by enqueue?
4. What is meant by dequeue?
5. What are the various operations performed on the Queue?
6. How do you test for an empty queue?
7. What is the difference between Stack & queue?
8.What kind of data structure is queue?

Ex.No. 7.B.

LINKED LIST IMPLEMENTATION OF QUEUE ADT

ACET/ECE/DSOOPS/2013-14

17

AIM:

To perform queue operations by implementing linked list in C++.


ALGORITHM:

1.
2.
3.
4.
5.
6.
7.
8.

Start the program.


Create a class queue.
Functions enqueue(),dequeue(),display() are declared public.
Create a menu with enqueue, dequeue, display and exit.
For enqueue ,get the element from the user.Check
a. if rear>=size. If so, display queue is full
b. Otherwise, insert the element at the rear end of the queue.
For dequeue, Check
a. if front=rear. If so,display the queue is empty.
b. else, remove the element from the front end of the queue.
For display, display all the elements from the queue.
Stop the process.

OUTPUT:

List Implementation of Queue.


1.Enqueue
2.Dequeue
3.Display
4.Exit
Enter Your choice : 1
Enter the Element to be inserted : 88
Enter Your choice : 1
Enter the Element to be inserted : 44
Enter Your choice : 1
Enter the Element to be inserted : 99
Enter Your choice : 1
Enter the Element to be inserted : 55
Enter Your choice : 3
The elements present in the Queue are....
88 -> 44 -> 99 -> 55 -> NULL
Enter Your choice : 2
The deleted item is 88
Enter Your choice : 3
The elements present in the Queue are....
44 -> 99 -> 55 -> NULL
Enter Your choice : 4
RESULT:

Thus the Linked list implementation of Queue ADT has been executed and verified
successfully.
Viva Questions:
1. How will you implement Queue using linked list?
ACET/ECE/DSOOPS/2013-14

18

2. List the applications of Queue.


3. How will you insert an element in linked list implementation of queue?
4. How will you delete an element in linked list implementation of queue?
5. How will you insert an element to linked list implementation of queue?

Ex No. 8

SEARCH TREE ADT BINARY SEARCH TREE

ACET/ECE/DSOOPS/2013-14

19

AIM:

To search for a number using Binary Search tree ADT.


ALGORITHM:

1.

Start the program.

2.

Create a class bsearch.

3.

Functions getdata(),bin_search() are declared under public.

4.

Read the value of number of numbers in an array and read all


The elements.

5.

Read the element to be searched in the array.

6.

Sort the elements in an ascending order in an array.

7.

Calculate the mid position and check whether the value in the
Mid position is > or < the search value.

8.

If Mid element is greater than search element then


a)

last=mid position 1

b) else first=mid position + 1


9.

Now search the element from first to last.

10. If available then return the location of the element else display
The search element is not there.
11. Stop the process.
OUTPUT:

Binary Search
Enter the number of elements in the Array : 7
Enter the Elements one by one...
45 23 78 21 56 33 66
The sorted array is ....
21
23
33
45
56
66
78
Enter the element to be searched..
56
The Element 56 is found at the position 5
RESULT:

Thus the program for Binary search has been verified successfully.
Viva questions:
ACET/ECE/DSOOPS/2013-14

20

1.
2.
3.
4.
5.
6.

What is Binary search tree?


Difference between binary tree and binary search tree.
What are the ways to delete an element in a binary search tree?
List the conditions to form a binary search tree.
What are the two properties that a binary tree satisfies?
List out the steps involved in deleting a node from a binary search tree.

Ex No. 9

HEAP SORT

AIM:

ACET/ECE/DSOOPS/2013-14

21

To sort an array of numbers using heap sort.


ALGORITHM:

1.

Start the program.

2.

Create a class heapsort

3.

Get the limit of elements to be sorted and also get the elements One by one and store it
sequentially in an array..

4.

Call the function heap(a,n)which in turn calls create_heap(a,n).

5.

In create_heap(a,n),construct a complete binary tree such that First element of array a[0]
will be the root.The left and right Childs are a[2k+1] and a[2k+2] respectively.

6.

In heap(a,n),replace the root with the last node of heap tree.

7.

Keep the last node(now root) at the proper position,and for each node,

8.
9.

Display the result.


Stop the process.

OUTPUT:

Enter the limit : 7


Enter the elements
56 23 45 90 12 55 19
Sorted list is ....
12 19 23 45 55 56 90
RESULT:

Thus the given numbers have been sorted by using Heap sort successfully.
VivaQuestions:
1.
2.
3.
4.
5.
6.
7.

What do you mean by heap?


What is the name of the basic heap operations?
Define root and node.
Define percolate up and down in binary heap.
What is the structure property of a binary heap?
What is meant by percolate-down?
What is meant by percolate-up?

Ex No.10

QUICK SORT

AIM:

ACET/ECE/DSOOPS/2013-14

22

To sort an array of numbers using Quick sort.


ALGORITHM:

1.

Start the program.

2.

Create a class sort under public.

3.

Functions q_sort(),quick() and swap() are declared under public.

4.

In q_sort(),Get the limit of elements in an array and get all the


Elements of the array one by one.

5.

Call the function quick() to sort the elements using quick sort
Algorithm and declare the sorted elements.

6.

In quick(),take the first element(a[0]) as the pivot element


& a[left],last element as a[right].

7.

Assign a[0]=a[left],i=a[left],j=a[right].

8.

a) Scan the array from left to right and check (a[i]<=pivot && i<right)for each
element.Stop left
scanning keep the location in i.
b) Scan the array from right to left and check (a[j]>=pivot && j>left) for each
element.Stop right scanning and keep the location in j.
c)Check the values at the position i and j.If i<j then call swap(a,i,j) to interchange the
values and repeat the steps a) & b) till i<j. else
swap(a,left,j)
quick(a,left,j-1)
quick(a,j+1,right)

9.

Repeat the step 8 for left and right partitions until we get the partitions of only one element.

10. Display the result.


11. Stop the process.
OUTPUT:

Enter the number of elements to be inserted : 8


Enter the elements one by one....
90 67 34 89 23 55 78 12
The Sorted List is .....
12 23 34 55 67 78 89 90
RESULT:

Thus the sorted array of numbers using Quick sort has been executed and verified
successfully.
Viva Questions:
ACET/ECE/DSOOPS/2013-14

23

1.
2.
3.
4.
5.
6.

What are the two categories of sorting?


What do you mean by sorting?
What is the application of Topological sorting?
What are the ways to pick the pivot element?
Define root and node.
What is sorting? How is sorting essential for data base applications?

EX.NO:11

COMPLEX NUMBER USING OBJECT AS ARGUMENT

ACET/ECE/DSOOPS/2013-14

24

Aim:
To write a C++ program to add two complex numbers using object as argument.
Algorithm:
Step 1: Create a class as complex.
Step 2: Declare the data members as real and img.
Step 3: Declare the member functions as
void getdata()
void show()
void sum(complex c1,complex c2)
Step 4: getdata() method is used to get the values .
Step 5: show() method is used to display the values.
Step 6: sum() method is used to perform addition operation using object as argument.
Step 7: In main, create the object for Complex class.
Step 8: Call the function using objectname.functionname();

Output:
Enter the real and img part 4 5
Enter the real and img part 2 3
The complex number of c1:
4+5i
The complex number of c2:
2+3i
The result is:
6+8i
Result:
Thus the C++ program of add two complex numbers using object as argument was verified
successfully.
Viva Questions:
1.What is meant by object?
2.How many objects can be created for a class?
3.What is the syntax for creating an object?
4.How will you create array of objects?And how can you acces array of objects?
5.How will you set pointer to objects?
EX.NO:12

OVERLOADING USING NEW AND DELETE OPERATOR

ACET/ECE/DSOOPS/2013-14

25

Aim:
To write a C++ program to overload new and delete operators.
Algorithm:
Step1: Declare the class as Vector.
Step 2: Declare the data member as *array;
Step 3: Declare the member function as
void *operator new(int size)
void operator delete(void * x)
void read()
void sum()
Step 4: In the main, create the object for the Vector class.
Step 5: Allocate the memory space for the array elements using new operator.
Step 6: Read function is used to get the array elements.
Step 7: Add the elements in the array using for loop in the sum function and display the
result.
Step 8: Delete the memory space by delete operator.
Output:
Enter Vector data...
Vector[0]=?1
Vector[1]=?5
Vector[2]=?8
Vector[3]=?7
Vector[4]=?4
Vector[5]=?6
Vector[6]=?1
Vector[7]=?8
Vector[8]=?9
Vector[9]=?10
The sum is 59
Result:
Thus the C++ program to overload new and delete operators was verified successfully.
Viva Questions:
1.What is meant by dynamic allocation?
2.What is the use of new operator?
3.What is the use of delete operator?
4.What do you understand by the term garbage collection?how it is performed in C++?
5.Define vector classes.
ACET/ECE/DSOOPS/2013-14

26

VIVA QUESTIONS DATA STRUCTORS AND OBJECT ORIENTED PROGRAMMING


1. Difference between Structured programming and Object oriented programming.
2. WriteanyfourfeaturesofOOPS.
3. WhataretheBasicconceptsofOOPS?
4. Defineobjects.
5. Defineclass.
6. GiveanyfouradvantagesofOOPS.
7. GivethestructureofaC++program.
8. GiveanyfourapplicationsofOOPS.
9. Giveanyfourapplicationsofc++.
10. Definetokens.
11. Whatiskeyword?
12. RulesfornamingtheidentifiersinC++.
13. Whatisascoperesolutionoperator?
14. Whatdoyoumeanbyenumerateddatatype?
15. Whataresymbolicconstants?
16. Whatdoyoumeanbydynamicinitializationofvariables?
17. Whatarereferencevariable?
18. Whatismemberdereferencingoperator?
19. Whatisfunctionprototype?
20. Whatisuseofnewanddeleteoperators?
21. ListoutthetypesofInheritance.
22. Mentionsomeofthestreamclasses.
23. Whatisaninlinefunction?
24. Name the operators that cannot be overloaded.
25. What is an identifier?
26. What is meant by function overloading?
27. What is a Constructor?
28. When do we need Virtual function?
29. What is put() and get() functions?
30. What is template? What is the use of it?
31. What is array? Give the syntax of it.
32. What is dynamic binding or late binding?
33. What are manipulators?
34. What is called pass by reference?
35. Define copy constructor.
36. List the types of operator overloading.
37. Difference between overloading and overriding.
38. Give examples of data abstraction.
39. List out the five basic data types in C++.
40. Differentiate Array and Structure.
41. Enumerate the advantages of inline functions.
42. Write down the syntax and usage of friend function.
43. State the difference between a non-virtual C++ member function and a virtual member
function.
44. Give the restriction in overloading of generic functions.
45. When does terminate function call carry out?
46. List out the file operations.
47. List out the different file modes in C++.
ACET/ECE/DSOOPS/2013-14

27

48. List out the functions used for random access.


49. What is polymorphism?
50. List the types of polymorphism.
51. How will you overload unary and binary operators using member functions?
52. In which situations inline expansion may not work.
53. How destructor works?
54. Give the features of pointer operators.
55. List the conditions that should be satisfied by casting operators.
56. How exception is handled by C++?
57. Trace any two advantages of constructors.
58. Define ADT.
59. List some ADTs.
60. Convert the following expression into postfix notation
4*2+7-3
61. Why we need to analysis the time complexity of an algorithm?
62. Write about dequeue.
63. What are the various hashing techniques?
64. What are the two properties that a binary tree satisfies?
65. Give a simple hash function when the input keys are integers.
66. What is an adjacencey list when it is used?
67. What is an activity node graph?
68. Why do you need biconnectivity?
69. Write the prefix and postfix form of the expression (A+B)/(C-D)
70. What is the name of the basic heap operations and its properties?
71. Define root and node.
72. What is the application of Topological sorting?
73. What are the ways to pick the pivot element?
74. What is priority queue? Give its application?
75. Define AVL tree.
76. What is graph?
77. Define minimum spanning tree.
78. Write the running time for Insertion sort and Shell sort.
79. Compare single source shortest path algorithm with all pair shortest path algorithm.
80. What is heap?
81. Compare and contrast stack and queue.
82. What the implementation methods of Stack?
83. What the implementation methods of Queue?
84. Give any two applications of Graph.
85. Why a minimum spanning tree is termed so?
86. What are the two categories of sorting?
87. Give the complexity of Merge sort.
88. What is an insertion sort?
89. What do you mean by top down design?
90. Give the application of stack.
91. What is O notation?
92. List the characteristics of stack.
93. What is Binary search tree?
94. Difference between binary tree and binary search tree.
95. What are the ways to delete an element in a binary search tree?
96. List the conditions to form a binary search tree.
ACET/ECE/DSOOPS/2013-14

28

97. What do you mean by sorting?


98. Give the binary tree representation of the formula A+B*C.
99. What is recursion?
100.What is linked list?

VIVA QUESTIONS OBJECT ORIENTED PROGRAMMING


1. Difference between Structured programming and Object oriented programming.
2. WriteanyfourfeaturesofOOPS.
3. WhataretheBasicconceptsofOOPS?
4. Defineobjectsandclasses.
5. GiveanyfouradvantagesofOOPS.
6. GivethestructureofaC++program.
7. GiveanyfourapplicationsofOOPS.
8. Giveanyfourapplicationsofc++.
9. Definetokens.
10. Whatiskeyword?
11. RulesfornamingtheidentifiersinC++.
12. Whatisascoperesolutionoperator?
13. Whatdoyoumeanbyenumerateddatatype?
14. Whataresymbolicconstants?
15. Whatdoyoumeanbydynamicinitializationofvariables?
16. Whatarereferencevariable?
17. Whatismemberdereferencingoperator?
18. Whatisfunctionprototype?
19. Whatisuseofnewanddeleteoperators?
20. ListoutthetypesofInheritance.
21. Mentionsomeofthestreamclasses.
22. Whatisaninlinefunction?
23. Name the operators that cannot be overloaded.
24. What is an identifier?
25. What is meant by function overloading?
26. What is a Constructor?
27. When do we need Virtual function?
28. What is put() and get() functions?
29. What is template? What is the use of it?
30. What is array? Give the syntax of it.
31. What is dynamic binding or late binding?
32. What are manipulators?
33. What is called pass by reference?
34. Define copy constructor.
35. List the types of operator overloading.
36. Difference between overloading and overriding.
37. Give examples of data abstraction.
38. List out the five basic data types in C++.
39. Differentiate Array and Structure.
40. Enumerate the advantages of inline functions.
41. Write down the syntax and usage of friend function.
42. State the difference between a non-virtual C++ member function and a virtual member
function.
43. Give the restriction in overloading of generic functions.
ACET/ECE/DSOOPS/2013-14

29

44. When does terminate function call carry out?


45. List out the file operations.
46. List out the different file modes in C++.
47. List out the functions used for random access.
48. What is polymorphism?
49. List the types of polymorphism.
50. How will you overload unary and binary operators using member functions?

ACET/ECE/DSOOPS/2013-14

30