Write a function sortWords array mat does Mu following Takes

Write a function sortWords (array) mat does Mu- following: Takes as an input a cell array of .strings consisting of letters only. Returns a cell array with all the strings in alphabetical order. The function should ignore whether letters are lower case or upper case. Test your function with the following: >> sorted=sortWords({\'Hello \', \'hell\', \' abc\', \'aa\', \'aza\', \' aab\', \'AaBb\', \' a\'}) sorted = \'a\' \'aa\' \'aab\' \'AaBb\' \'abc\' \'aza\' \'hell\' \'Hello\' function sortedarray=sortWorda(array) sortedarray={}; while \"isenpty(array) [m, pos]=findSmallest (array); array(pos)= []; sortedarray-laortodarray m]; end function [n.poa]\"findSmallest(array) m =...; pos-1; for i=2:length(array) if isLessWord(..., ) m=....; pos= i; end end function less=isLessWord(vordA.vordB) worda=louer(vordA); wordb=lower(wordB);

Solution

a >= b if and only if:

i := first index such that a(i) ~= b(i);
if i exists, a(i) > b(i)
otherwise length(a)>=length(b)

 Write a function sortWords (array) mat does Mu- following: Takes as an input a cell array of .strings consisting of letters only. Returns a cell array with all

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site