Thursday, 11 May 2017

CPP DS

There are two types of search :

1. Linear Search :
In this, the element to be searched is compared one by one with each element of given list, starting with first element. The process of comparisons remain continue until the element is not found or list gets exhausted.

2. Binary Search : 
It is another technique of searching an element in a given list in minimum possible comparisons. But for applying binary search on a list, there are two pre-conditions :
i. The elements of list must be arranged either in ascending or descending order.
ii. The list must be of finite size and should be in form of linear array.

.Binary Search Algorithm



Bubble Sorting

Bubble Sort is an algorithm which is used to sort N elements that are given in a memory for eg: an Array with N number of elements. Bubble Sort compares all the element one by one and sort them based on their values..

Bubble Sort for Data Structures

 

Quick Sort Algorithm

Quick Sort, as the name suggests, sorts any list very quickly. Quick sort is not stable search, but it is very fast and requires very less aditional space.

this algorithm divides the list into three main parts :
  1. Elements less than the Pivot element
  2. Pivot element
  3. Elements greater than the pivot element
  4. Quick Sorting in Data Structures

 

No comments:

Post a Comment