Selection Sort

1.7

8 votes
Very-Easy
Problem
  • Consider an Array a of size N
  • Iterate from 1 to N
  • In ith iteration select the ith minimum and swap it with a[i]

You are given an array a, size of the array N and an integer x. Follow the above algorithm and print the state of the array after x iterations have been performed.

Input Format

The first line contains two integer N and x denoting the size of the array and the steps of the above algorithm to be performed respectively. The next line contains N space separated integers denoting the elements of the array.

Output Format

Print N space separated integers denoting the state of the array after x steps

Constraints

1N100

1a[i]100

1xN

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?