108k views
1 vote
Apply selection sort to the following words by hand according to the following requirements. Ascending order (Largest at the right-most) - Use left-to-right progress order (the sorted data starts from the left to right). When two words are compared, the "larger" word is the longer one, and if the length is equal, the alphabetically order is used. The case is ignored in the comparison (e.g. 'A' and 'a' are considered the same). Show your working step by step on each line in the text file.

User Joemoe
by
7.5k points

1 Answer

0 votes

Final answer:

To apply selection sort to words based on given requirements, compare the lengths of the words and alphabetically if length is equal. Ignore case. Sort the words in ascending order with longest at the rightmost position. Use left-to-right progress order.

Step-by-step explanation:

To apply selection sort according to the given requirements, start by comparing the lengths of the words. If two words have equal lengths, compare them alphabetically. Ignore the case when comparing. Sort the words in ascending order, with the longest word at the rightmost position. Follow a left-to-right progress order, where the sorted data starts from the left to right.

For example, suppose we have the words: 'apple', 'Banana', 'cat', 'dog', 'elephant', 'giraffe', 'Apple', 'DOG'.

  1. The first step is to compare 'apple' and 'Banana'. Since 'Banana' is longer, it should be placed to the right of 'apple'. The updated list becomes: 'apple', 'Banana', 'cat', 'dog', 'elephant', 'giraffe', 'Apple', 'DOG'.
  2. Next, compare 'Banana' and 'cat'. Since 'cat' is shorter, it should be placed to the right of 'Banana'. The updated list becomes: 'apple', 'Banana', 'cat', 'dog', 'elephant', 'giraffe', 'Apple', 'DOG'.
  3. Continue comparing and rearranging the words until the list is sorted in the required order.

User Florian Walther
by
8.3k points