Question from the Algorithmics - Fundamentals test

Archived

What does the While loop do?

         sort_insertion(Array listNumbers) 
         {
                 For i from 1 to size_of_listNumbers - 1 
                 {
                         x <-- listNumbers[i];
                          j <-- i;
                          While j > 0 and listNumbers[j - 1] > x 
                            {
                              listNumbers[j] <-- listNumbers[j - 1]
                              j <-- j-1;
                               
                           }
                            listNumbers[j] <-- x;
                }
    }
Author: KahinaStatus: Archived(New question!)(Update)Question passed 22 times
-1
Community Evaluations
developer avatar
Adrien
24/07/2022
bad code formating makes it painfull to read
developer avatar
Auteur anonyme
05/09/2022
Merci beaucoup d'avoir pris le temps de réécrire la fonction 🙏