Question: Convert this C Code: # void sort(char **list, int n){ # int sorted=0, i=1, j; # char *temp; # while(i < n && !sorted){ #

Convert this C Code:

# void sort(char **list, int n){ # int sorted=0, i=1, j; # char *temp; # while(i < n && !sorted){ # j=0; # sorted = 1; # while(j 0){ # temp = list[j]; # list[j] = list[j+1]; # list[j+1] = temp; # sorted = 0; # } # j++; # } # i++; # } # } # int cmp(char *str1, char *str2){ # while(*str1 && (*str1 == *str2)){ # str1++; # str2++; # } # return *str1 - *str2; # }

To assembly sort function starting with ".globl sort" that receives a pointer to an array of strings and the number of elements in the array. The function uses bubble sort to sort the array. test cases include "./prog2 sort bla blo obl abl lab bol bal lob" giving "sorted list = {abl, bal, bla, blo, bol, lab, lob, obl}"; "./prog2 sort 300 500 200 600 400 100 800 700" outputting "sorted list = {100, 200, 300, 400, 500, 600, 700, 800}", and "./prog2 sort kiwi strawberry apple orange banana peach blueberry mango" outputting "sorted list = {apple, banana, blueberry, kiwi, mango, orange, peach, strawberry}"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!