Guest User

Untitled

a guest
Feb 27th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. def insertionSort(unsortedList : List[String]) = {
  2. val F = unsortedList.toArray
  3. for(i <- (2 until F.length)){
  4. val m = F(i)
  5. var j = i;
  6. while(j > 1 && !sorted){
  7. if (F(j-1) >= m) {
  8. F(j) = F(j-1)
  9. j -= 1
  10. }
  11. }
  12. F(j) = m
  13. }
  14. F.toList
  15. }
  16.  
  17. // Note:
  18. // This algorithm has been transcribed from:
  19. // Saake and Sattler. "Algorithmen und Datenstrukturen. Eine Einführung in Java".
  20. // dpunkt.verlag Heidelberg, 2004. page 123f
Add Comment
Please, Sign In to add comment