AUTH's THMMY "Parallel and distributed systems" course assignments.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

elbowmerge.jl 384 B

1234567891011121314151617181920212223
  1. # given a bitonic sequence b, merge it into a sorted sequence s
  2. @inbounds function elbowmerge!(s, b)
  3. n = length(b)
  4. l = argmin(b)
  5. r = l == n ? 1 : l + 1
  6. i = 1
  7. while i <= n
  8. if b[l] < b[r]
  9. s[i] = b[l]
  10. l = l == 1 ? n : l - 1
  11. else
  12. s[i] = b[r]
  13. r = r == n ? 1 : r + 1
  14. end
  15. i += 1
  16. end
  17. nothing
  18. end