Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

n people are standing in a row according to their height in ascending-ordered except that two of them swap their position. Their height is given

image text in transcribed

image text in transcribed

n people are standing in a row according to their height in ascending-ordered except that two of them swap their position. Their height is given in a list according to their position. Your task is to sort it in linear time. Assume that no two people have the same height. Print the elements of this sorted list in a single line separated by spaces. Example: Input array: [3,8,6,7,5,9] Output: 356789 ing Window import java.util.*; class Main \{ private static void sortArray(int[] arr)\{ \} public static void main(String[] args) \{ Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int arr[]= new int [n]; for(int i=0;i<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started