Question: C# Given a rectangular array, perform an insertion sort on each and every diagonal segment that go in the south-east direction (i.e., rightwards and downwards)

C#

Given a rectangular array, perform an insertion sort on each and every diagonal segment that go in the south-east direction (i.e., rightwards and downwards) without crossing other diagonal segments. See examples.

a non-null rectangular array

/// Input Sorted

/// 12 11 10 9 2 1 5 9

/// 8 7 6 5 3 7 6 10

/// 4 3 2 1 4 8 12 11

/// You are sorting the following segments:

/// 4, 8 3, 12 7 2, 11 6 1, 10 5, and 9.

/// Input Sorted

/// 20 19 18 17 5 9 13 17

/// 16 15 14 13 1 10 14 18

/// 12 11 10 9 2 6 15 19

/// 8 7 6 5 3 7 11 20

/// 4 3 2 1 4 8 12 16

/// You are sorting the following segments:

/// 4, 8 3, 12 7 2, 16 11 6 1, 20 15 10 5, 19 14 9, 18 13, and 17.

Return the reference to the original array

public int[,] DiagonalSort(int[,] a)

{

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!