0% found this document useful (0 votes)
1 views3 pages

DS Lab Viva

Data structure lab viva questions

Uploaded by

kanchana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views3 pages

DS Lab Viva

Data structure lab viva questions

Uploaded by

kanchana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DATA STRUCTURE LAB

VIVA QUESTIONS WITH ANSWERS

1. Define searching process.


Ans: The process of finding an element within the list of elements is called searching.

2. How many types of searching are there?


Ans: There is basically two types of searching:-Linear search and Binary search.

3. Define Linear search.


Ans: In linear search, we access each elements of an array one by one sequentially and see
whether it is desired element or not.

4. Define Binary search.


Ans: Binary search works on the principle of divide and conquer. For this algorithm to work
properly, the data collection should be in the sorted form.
Binary search looks for a particular item by comparing the middle most item of the list. If a
match occurs, then the index of item is returned. If the middle item is greater than the item, then
the item is searched in the sub-array to the left of the middle item. Otherwise, the item is
searched for in the sub-array to the right of the middle item. This process is repeated until the
item is found in the list.
5. Define Sorting.
Ans: Sorting is a process of arranging the given data elements into either ascending order or
descending order.

6. What are the different types of sorting techniques in data structures ?


Ans: 1) Insertion sort 2) Selection sort 3) Bubble sort 4) Merge sort 5) Quick sort etc.

7. What is Insertion sort?


Ans: In insertion sorting method, sorting is done by inserting elements into an existing
sorted list. Initially, the sorted list has only one element. Other elements are gradually added into
the list in the proper position.

8. What is Selection sort?


Ans: The selection sort algorithm sorts an array by repeatedly finding the minimum element
(considering ascending order) from unsorted part and putting it at the beginning. The algorithm
maintains two subarrays in a given array.
1) The subarray which is already sorted. 2) Remaining subarray which is unsorted.
In every iteration, the minimum element from the unsorted subarray is picked and moved to the
sorted subarray.
9. What is Bubble sort?
Ans: Bubble Sort method works by repeatedly swapping the adjacent elements in the array if
they are in wrong order until a completely sorted array is found.
10. What is Merge sort?
Ans: Merge sort works on the principle of divide and conquer. This method split the list into
two halves and recursively sort each half, and then merge the two sorted sub-lists.

11. What is Stack?


Ans: A Stack is a linear data structure where elements are inserted and deleted from the
same end. It is also called as Last-In-Fist-Out (LIFO) data structure.

12. What are the operations performed on stack?


Ans: Push for insertion and Pop for deletion.

13. Define Queue.


Ans: A Queue is a linear data structure where elements are inserted from one end (rear
end)and deleted from another end (front end). It is also called as First-In-Fist-Out (FIFO) data
structure.

14. Define Linked list.


Ans: Linked list are special list of some data elements linked to one another .The logical
ordering is represented by having each element pointing to the next element. Each element is
called a node which has two parts: INFO – it stores the information and POINTER – which
points to the next element.

15. What are the different types of linked list?


Ans: Linked list are of four types: 1. Singly linked list 2. Doubly linked list 3. Circular
linked list 4. Circular doubly linked list.

16. What are the different operations performed on a linked list?


Ans: Basic operations performed on a linked list are: creation, insertion, deletion ,
traversing, searching , concatenation and display.

17. What are the advantages of linked list?


Ans: Advantages are:
1. linked lists are dynamic data structures 2. Efficient memory utilizations and
3. Insertion and deletions are easier and efficient
18. What is a File? Name some of the File operations.
Ans: A file is a named collection of related information that is recorded on secondary
storage. File operations are: create, read, write, rename, truncate, delete, etc.
19. What are ofstream , ifstream and fstream classes?
Ans: These are C++ classes which are declared in the File handling header file named
fstream.h.

The function of these classes are:

 ofstream: It represents output Stream and this is used for writing in files.
 ifstream: It represents input Stream and this is used for reading from files.
 fstream: It represents both output Stream and input Stream. So it can read from files and
write to files.

20. What is open( ) function in C++?


Ans: open( ) function in C++ is used to create a file and its syntax is:

Syntax:

file-stream-class stream-object;
stream-object.open("filename",mode);

Where filename is a string representing the name of the file to be opened, and mode is an
optional parameter which represents the different types of file operations such as read, write,
append, truncate etc.

You might also like