TORONTO KIDS COMPUTER CLUB | PMCA Sunday 12:00 Java Homework 20.07.19.
17974
post-template-default,single,single-post,postid-17974,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

PMCA Sunday 12:00 Java Homework 20.07.19.

21 Jul PMCA Sunday 12:00 Java Homework 20.07.19.

Question:

Write a code to do a zigzag sort. See the example below for more information.

Given an array as

19,3,11,17,23,1,2,14,-1

Sort the array as below:

-1,2,11,16,19,23,17,14,3,1

In the sorted array is sorted as below:

Minimum number is at index 0

2nd Minimum number is at index (arr.length-1) = 9

3rd Minimum number is at index 1

4rd Minimum number is at index (arr.length-2) = 8

5rd Minimum number is at index 2

6rd Minimum number is at index (arr.length-3) = 7

7rd Minimum number is at index 3

8rd Minimum number is at index (arr.length -4) = 6

9rd Minimum number is at index 4

Maximum number is at index (arr.length-5) = 5

No Comments

Sorry, the comment form is closed at this time.