reset password
Author Message
dcacere4
Posts: 10
Posted 01:22 Oct 20, 2017 |

Need clarification for question 4, don't completely understand.

Last edited by dcacere4 at 01:32 Oct 20, 2017.
jingchao
Posts: 25
Posted 10:35 Oct 20, 2017 |

same here!

jingchao
Posts: 25
Posted 10:39 Oct 20, 2017 |

I assume max stands for the repeated numbers, then we put those repeated numbers at the end of the list, and then sort those unique numbers from least to greatest?

this is how i understand it.

for example, you have a list [2,6,3,4,4,5,1,7,7,8] it would be [1,2,3,4,5,6,7,8,4,7], something like this, not 100% sure.

Last edited by jingchao at 10:41 Oct 20, 2017.
msargent
Posts: 519
Posted 11:56 Oct 20, 2017 |

Remove max is just to remove the max element from the list. If there are duplicates of the max element, just remove one of them. 

For instance, [2, 3, 5, 5, 1] would become [2, 3, 5, 1], since there is more than one 5.

Do not sort the list. Just remove the max.

Last edited by msargent at 11:59 Oct 20, 2017.
jingchao
Posts: 25
Posted 13:51 Oct 20, 2017 |

Professor msargent, you misunderstood, we didn't understood #4, which is this one

8 pts) Implement a sorting algorithm that finds the max, puts it at the end of the list, then recursively sorts the remainder of the list. You can create/use any helper functions you need, provide that you wrote it yourself, or it's built into Haskell.

msargent
Posts: 519
Posted 15:36 Oct 20, 2017 |

For that question, here's a hint:

a sorted list = [sorted elements of (list - max of the list)] plus [max element of list]

max element of the list is the element with the highest value. For example: in [1,2,3], 3 is the max

If there are duplicate max, the first list would include everything but one instance of the max.

I can't say anymore than this without giving it away. You need to figure out how this works recursively.

 

 

Last edited by msargent at 15:47 Oct 20, 2017.