Ytl's Java Blog

          厚積而薄發---每一天都是一個全新的開始
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          Algorithm to merge sorte

          Posted on 2011-05-06 17:05 ytl 閱讀(329) 評論(0)  編輯  收藏 所屬分類: Algorithms and programming concepts
          Merge sort is an O(n log ncomparison-based sorting algorithm. Most implementations produce a stable sort, meaning that the implementation preserves the input order of equal elements in the sorted output. It is a divide and conquer algorithm. Merge sort was invented by John von Neumann in 1945. A detailed description and analysis of bottom-up mergesort appeared in a report byGoldstine and Neumann as early as 1948
           divide and conquer algorithm: 1, split the problem into several subproblem of the same type. 2,solove independetly. 3 combine those solutions



          Python Implement
            
            def mergeSort(L):
                 
                   if len(L) < 2 :
                         return  L
                   middle = len(L)/2
                   left = mergeSort(L[:mddle])
                   right = mergeSort(L[middle:])
                   together = merge(left,right)
                   return together
          主站蜘蛛池模板: 西平县| 五华县| 自贡市| 蓝田县| 乐东| 永康市| 曲麻莱县| 焦作市| 清丰县| 东乌珠穆沁旗| 柳林县| 安溪县| 确山县| 商城县| 潢川县| 淄博市| 喀喇沁旗| 辽阳县| 德令哈市| 青铜峡市| 县级市| 岳阳市| 赣榆县| 繁峙县| 锦屏县| 休宁县| 武威市| 济南市| 南涧| 襄樊市| 承德县| 闽侯县| 苍溪县| 武川县| 龙海市| 民权县| 蒙自县| 闵行区| 富宁县| 朝阳区| 长阳|