Westonci.ca is your trusted source for finding answers to a wide range of questions, backed by a knowledgeable community. Join our platform to connect with experts ready to provide precise answers to your questions in different areas. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.

consider sorting nn numbers stored in array aa by first finding the smallest element of aa and exchanging it with the element in a[1]a[1]. then find the second smallest element of aa, and exchange it with a[2]a[2]. continue in this manner for the first n-1n−1 elements of aa. write pseudocode for this algorithm, which is known as selection sort. what loop invariant does this algorithm maintain? why does it need to run for only the first n-1n−1 elements, rather than for all nn elements? give the best-case and worst-case running times of selection sort in \thetaθ-notation.