Bin sort and radix sort

Bin sort is one of the most efficient algorithms, wherein an input vector is split into multiple bins, and then sorting is performed within each bin. The elements are assigned to the bins based on the computations performed on each element. The bins can be a list of multiple vectors or a linked list. The current execution uses a list of multiple vectors as bins. The following R code performs the bin sort operation on a numeric vector (V) containing n elements. The maxValue variable denotes the element with maximum value within the input vector:

Bin_Sort=function(V,n,maxValue){ bin <-list("binValues"=list(), "nElement"=NA) ## create empty bins for(i in 1:n){ bin[["binValues"]][[i]]<-NA bin[["nElement"]][i]<-0 } ## add elements ...

Get R Data Structures and Algorithms now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.