Merge sort is an O(n log n) comparison-based sorting algorithm.

learn more… | top users | synonyms

3
votes
2answers
74 views

Mergesort implementation in Clojure

(defn merge [pred left right] (loop [v [] l left r right] ; v is a vector, so conj will append to the end (if (and (seq l) (seq r)) ; if both left and right are not empty (if ...
4
votes
2answers
122 views

Merge sort in scala

I've implemented merge sort in scala: object Lunch { def doMergeSortExample() = { val values:Array[Int] = List(5,11,8,4,2).toArray sort(values) printArray(values) } def ...
4
votes
2answers
151 views

ANSI C Mergesort - Pedantic criticism please

This is a mergesort implementation I wrote, trying to get back into C. I am not so much interested in feedback on the optimality of the algorithm (as I could read up countless articles i'm sure), but ...
0
votes
1answer
186 views

Am I doing this right? Merging 2 ordered source arrays into one destination array

My instructions were: Add a merge() method to the OrdArray class in the orderedArray.java program (Listing 2.4) so that you can merge two ordered source arrays into an ordered destination ...
4
votes
2answers
965 views

Inversion count using merge sort

count = 0 def merge_sort(li): if len(li) < 2: return li m = len(li) / 2 return merge(merge_sort(li[:m]), merge_sort(li[m:])) def merge(l, r): global count result = [] ...
2
votes
0answers
245 views

Merge sort in Scheme

(define (merge-sort lst (lt? <)) (let sort ((lst lst) (size (length lst)) (flip #f)) (define (merge l r (res '())) (cond ((null? l) (append-reverse r res)) ...
0
votes
0answers
94 views

F# mergesort code : where to improve

I would appreciate some quick comments on this basic mergesort code. Am I missing a big block in the langage? open System open System.Windows open System.Collections.Generic let shuffle (l:'a array) ...
4
votes
2answers
442 views

How to do Merge sort on Integer class in Java?

This is a specific case in merge sort. I'm trying to do a merge sort on an array that's created using the java Integer class. My implementation is slow and therefore needs some modifications for ...
8
votes
2answers
1k views

Parallel Merge Sort

Wanted to post something here, so I wrote a parallel merge sort implementation (boring yeah). Parallism is achieved by using a simple call to tbb::parallel_invoke(). However I can't break a ...