Page 160 - Algorithms Notes for Professionals
P. 160

Chapter 31: Insertion Sort



       Section 31.1: Haskell Implementation



       insertSort :: Ord a => [a] -> [a]
       insertSort [] = []
       insertSort (x:xs) = insert x (insertSort xs)

       insert :: Ord a => a-> [a] -> [a]
       insert n [] = [n]
       insert n (x:xs) | n <= x    = (n:x:xs)
                       | otherwise = x:insert n xs











































































       colegiohispanomexicano.net – Algorithms Notes                                                           156
   155   156   157   158   159   160   161   162   163   164   165