Question: #include #include #include void order_two_players(player_t* player1_p, player_t* player2_p) { /* This function compares two players. If *player1_p is older than the *player2_p, swap them. In

#include #include #include

void order_two_players(player_t* player1_p, player_t* player2_p)

{

/*

This function compares two players. If *player1_p is older than the *player2_p,

swap them. In all other cases, do not swap them.

Inputs:

player1_p - memory location of the first player

player2_p - memory location of the second player

Post:

After the function has been called, the age of *player1_p is always less than

or equal to *player2_p age.

*/

}

void order_all_players(player_t* players, int players_len)

{

/*

Sort an array of players in non-decreasing order of the age by implementing the

following algorithm:

1. Compare two adjacent players, if the first player is older than the second,

swap the first and second players.

2. Keep comparing the next two adjacent players in the array, until the end of

the array is reached.

3. Repeat the above steps for players_len times.

This simple algorithm is also known as bubble sort.

Inputs:

players - player_t array (memory location of 0th element in the array)

players_len - number of players in the array

*/

}

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!