Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Use mapReduce to implement bubble sort. Implement a function bubble that does one bubble sort pass.
  2.  
  3. You may use any technique you want to implement bubble. However, you may not plug a function into mapReduce that does a sort on its own.
  4.  
  5. Fill in the <?> parts to produce a result that looks like this.
  6.  
  7. bubbleSort =
  8. mapReduce
  9. <?>
  10. bubble
  11. <?>
  12. <?>
  13. <?>
  14. > bubbleSort [4, 3, 2, 7, 5, 8, 1]
  15. [1,2,3,4,5,7,8]
  16. Hint: the termination condition is not whether a list is empty.
  17.  
  18.  
  19. mapReduce mapFn wayAheadFn turnAroundCond turnAroundFn reduceFn xin
  20. | (turnAroundCond xin) = turnAroundFn xin
  21. | otherwise =
  22. reduceFn
  23. (mapFn xin)
  24. (mapReduce mapFn wayAheadFn turnAroundCond turnAroundFn reduceFn (wayAheadFn xin))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement