Data Structure: Unit V (a): Searching and Sorting

Two marks Questions with Answers

Searching and Sorting | Data Structure

Sorting is useful for arranging the data in desired order. After sorting the required element can be located easily.

Two Marks Questions with Answers

Q.1What is the importance of sorting and searching techniques ?

Ans; Sorting is useful for arranging the data in desired order. After sorting the required element can be located easily.

Searching technique is essential for locating the position of the required element from the heap of data,

Q.2 Give any two applications of sorting.

Ans. :

1. The sorting is useful in database applications for arranging the data in desired order.

2. In the dictionary like applications the data is arranged in sorted order. 39156 2

3. For searching the element from the list of elements, the sorting is required.

Q.3 What do you understand by the term sorting ?

Ans. Sorting is a mechanism of arranging the data in particular order.

Q.4 What is the need for sorting?

Ans. The sorting is useful for -

1.     Searching the desired data efficiently. 2. Responding to the queries.

Q.5 What is the meaning of sort key?

Ans; Sort key is a field in the record based on which the sorting is conducted.

Q.6 Name the slowest and fastest sorting technique.

Ans. Bubble sort is a slowest sorting technique and quick sort is the fastest sorting technique.

Q.7.Differentiate between internal and external sorting.

Internal sorting: This is a type of sorting technique in which data resides on main memory of computer.

External sorting: This is a sorting technique in which there is huge amount of data and it resides on secondary storage devices while sorting.

Q.8 Explain the meaning of the term passes in context with sorting.

Ans. : While sorting the elements in some specific order, there is lot of arrangement of elements.. The phases in which the elements are moving to acquire their proper position is called passes.

Q.9 What is ascending and descending order?

Ans. : Searching and Sorting Ascending order is the sorting order in which the elements are arranged from low value to high value. In other words it is called increasing order. For example: 10, 20, 30, 40.

Descending order is the sorting order in which the elements are arranged from high value to low value. In other words it is called decreasing order. For example: 40, 30, 20, 10.

Q.10 What is the basic principle behind the quick sort ?

Ans. : The division of the list into two sublists(which is called partition) and then sorting each sublist independently. This is the basic principle used in quick sort. Based on the value of pivot element, the list is subdivided.

Q.11Enlist four internal sorting techniques.

Ans. : Following are some internal sorting techniques

1. Insertion sort        3. Shell sort

2. Selection sort       4. Bubble sort

Q.12 What do you mean by heap?

Ans. Heap is a complete binary tree or almost complete binary tree in which every parent node be either greater or lesser than the parent node.

Q.13 What are the two stages in which heap sort is conducted?

Ans. Following are the two stages in which the heap sort is conducted Heap construction: The heap structure is build for given list of elements

Deletion of maximum key: In this phase the root key is deleted for n - 1 times.

Q.14 The way a card game player arranges his cards as he picks them one by one is an example of

Ans. :insertion sort

 Q`15 A sort which iteratively passes through a list to exchange the first element with any element less than it and then repeats with a new first element is called

Ans. : selection sort

Q.16 Explain why binary search can not be performed using linked list ?

Ans. : In binary search algorithm, the mid element needs to be searched. If binary search is implemented using arrays then by simply saying a[mid] we can access the middle element of an array in constant time. But for finding the mid element of a linked list we have to execute separate algorithm and it can not be done in constant time. Thus implementing binary search using linked list is very inefficient way. Hence it is not preferred to implement a binary search using linked list.

Q.17What do you understand by the term searching ?

Ans; Searching means locating the position of the desired record or key element from the given database.

Q.18 What are the advantages of binary search over the linear search?

Ans. : Binary search is an efficient searching method than the linear search. Using this method, the list is subdivided each time and only sublist is scanned for locating the key value.

Q.19 What is the time complexity of binary search?

Ans. : The time complexity of binary search is O(logn).

Q.20 List the sorting algorithms which uses logarithmic time complexity

Ans. : The sorting algorithms which use the logarithmic time complexity are Quick sort and merge sort.

Q.21 Compare linear search and binary search.

Ans.

Q.22 What is the time complexity of insertion sort ?

The time complexity of insertion sort is O(n2)

Q.23 State the complexity of binary search.

Ans. : The best case time complexity is O(1). The worst case and average case time complexity O (log n).

Q.24 Compare linear search and Binary search.

Ans. :


Q.25 Define radix sort.

Ans. : Radix sort is a sorting technique in which the number is sorted based on its individual digit

Data Structure: Unit V (a): Searching and Sorting : Tag: : Searching and Sorting | Data Structure - Two marks Questions with Answers