Homework 2: CMSC 15200
Due: Wednesday, 21 Jan, 5pm
Your first problem is to implement the selection sort algorithm, described below.
You should proceed in two steps:
- Write a function that takes a list of n integers and returns the index
of the largest element in the list (not the value of the largest element)
- Hence, implement selection sort as a function. This algorithm performs
comparably to the bubble sort. What you do is take an array of integers
and swap element 0 with the maximum element in the rest of the array.
Then, you swap element 1 with the maximum element in the rest of the array.
Note you only need to check from element 2 down to the bottom of the list.
For more information, you can look at problem 4.31 in Deitel, but you
do not need to implement the algorithm as a recursive function, though
you may if you choose.
Your second problem will get you some familiarity with string
manipulation in C. Do problem 5.35 in Deitel, in which you will
need to use the strtok function and provide a new function in order
to convert English phrases into Pig Latin phrases