Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Use mapReduce to implement bubble sort. Implement a function bubble that does one bubble sort pass.
- 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.
- Fill in the <?> parts to produce a result that looks like this.
- bubbleSort =
- mapReduce
- <?>
- bubble
- <?>
- <?>
- <?>
- > bubbleSort [4, 3, 2, 7, 5, 8, 1]
- [1,2,3,4,5,7,8]
- Hint: the termination condition is not whether a list is empty.
- mapReduce mapFn wayAheadFn turnAroundCond turnAroundFn reduceFn xin
- | (turnAroundCond xin) = turnAroundFn xin
- | otherwise =
- reduceFn
- (mapFn xin)
- (mapReduce mapFn wayAheadFn turnAroundCond turnAroundFn reduceFn (wayAheadFn xin))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement