Insertion Sort in Python

Insertion Sort in Python

Insertion Sort in Python Insertion sort examine the previously sorted sub-array and insert an element at its proper position. If you have an array a[0], a[1], a[2], a[3],……….a[n]. Then in insertion sort a[0] trivially sorted sub-array. Again compare a[0] to a[1] and if a[0]> a[1] exchange it. Now sub-array a[0],a[1] is sorted again compare a[2] … Read more Insertion Sort in Python

Selection Sort in Python

Selection Sort Selection sort uses statistical technique which finds minimum/maximum from a list and puts it at appropriate position. If you consider ascending order the smallest element will be placed at the first position, the second smallest element will be placed at the second position and the third smallest element will be placed at the … Read more Selection Sort in Python

Binary Search in Python

Binary Search in Python

Binary Search Basic idea behind binary search is to divide sorted array in two parts, and check whether the element which divides the array is desired element . And if the desired element is found then stop the search, otherwise further divide the array until the desired element is not found. Step-Wise Pictorial Demonstration of … Read more Binary Search in Python

Bubble Sort in Python

Bubble Sort in Python

Bubble Sort in Python The basic idea behind bubble sort is to compare the first element in list to second element . Compare the second element to the third element if greater swap the elements. Compare the third element to the fourth element if greater swap the elements. Do until the list is sorted. The … Read more Bubble Sort in Python

Divide and Conquer and Dynamic Programming Algorithms

Often students get confused what are differences between divide and conquer and dynamic programming. Since they solve problems in similar nature. Divide the problem into sub-problems combine them to get solution. Here I list the differences¬† between divide and conquer and dynamic programming in a table and also¬† made quizzes so that you can practice … Read more Divide and Conquer and Dynamic Programming Algorithms