## Python Program to Sort using a Binary Search Tree

This is a Python program to sort using a binary search tree. Problem Description The program sorts a list using a binary search tree. Problem Solution 1. Create a class BSTNode with instance variables key, left, right and parent. 2. Define methods insert and inorder in BSTNode. 3. The method insert takes a node as … Read more

## Python Program to Implement Binary Insertion Sort

This is a Python program to implement binary insertion sort. Problem Description The program sorts a list by binary insertion sort. Problem Solution 1. Create a function binary insertion_sort that takes a list as argument. 2. Inside the function create a loop with a loop variable i that counts from 1 to the length of … Read more

## Python Program to Implement Introsort

This is a Python program to implement introsort. Problem Description The program sorts a list by introsort. Problem Solution 1. Create a function introsort that takes a list argument. 2. In the function, an appropriate value for maxdepth is chosen. Here maxdepth is chosen equal to 2 times floor of log base 2 of the … Read more

## Python Program to Implement Shell Sort Algorithm

This is a Python program to implement shell sort. Problem Description The program sorts a list by shell sort. Problem Solution 1. Create a generator gaps that takes the size of the list as argument and returns the next element in the sequence of gaps on each successive call. Here the gap sequence chosen is … Read more

## Python Program to Implement Comb Sort

This is a Python program to implement comb sort. Problem Description The program sorts a list by comb sort. Problem Solution 1. Create a function comb_sort that takes a list as argument. 2. Set gap equal to the length of the list. 3. Choose an appropriate shrink factor. Here shrink = 1.3. 4. Create a … Read more

## Python Program to Implement CockTail Sort

This is a Python program to implement cocktail shaker sort. Problem Description The program sorts a list by cocktail shaker sort. Problem Solution 1. Create a function cocktail_shaker_sort that takes a list as argument. 2. Set upper to length of the list – 1 and lower to 0. 3. Create a loop inside which bubble … Read more

## Python Program to Implement Gnome Sort

This is a Python program to implement gnome sort. Problem Description The program sorts a list by gnome sort. Problem Solution 1. Create a function gnome_sort that takes a list as argument. 2. Inside the function create a loop with loop variable pos that iterates from 1 to the length of the list – 1. … Read more

## Python Program to Implement Bucket Sort

This is a Python program to implement bucket sort. Problem Description The program sorts a list by bucket sort. Problem Solution 1. Create a function bucket_sort that takes a list as argument. 2. Inside the function set largest to the maximum element in the list and set length equal to the length of the list. … Read more

## Python Program to Implement Radix Sort

This is a Python program to implement radix sort. Problem Description The program sorts a list by radix sort. Problem Solution 1. Create a function radix_sort that takes a list and a variable base as arguments. 2. Create an inner function key_factory that takes two variables digit and base as arguments and returns a function. … Read more 