? Q1. Given a 2D matrix A[1...n][3] in which the total number of elements in each row is 3. Sort the 2D matrix keeping t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

? Q1. Given a 2D matrix A[1...n][3] in which the total number of elements in each row is 3. Sort the 2D matrix keeping t

Post by answerhappygod »

Q1 Given A 2d Matrix A 1 N 3 In Which The Total Number Of Elements In Each Row Is 3 Sort The 2d Matrix Keeping T 1
Q1 Given A 2d Matrix A 1 N 3 In Which The Total Number Of Elements In Each Row Is 3 Sort The 2d Matrix Keeping T 1 (71.88 KiB) Viewed 61 times
please provide correct answwer i will give upvote else ready for
10 dislike
? Q1. Given a 2D matrix A[1...n][3] in which the total number of elements in each row is 3. Sort the 2D matrix keeping these things in mind: • Sort the matrix by Ascending order of their first value A[1...n][0]. • If A[0] == A[j][0], then sort the matrix by Ascending order of their second value A[1...n][1]. • If A[1] == A[j][1], then sort the matrix by Descending order of their third value A[1..n][2]. TestCase: n=5 111 116 123 311 319 O/P: 116 111 123 319 311 Explanation: • In a given test case, [1 1 1] is compared with [1 1 6] as from 3rd point A[0][0]==A[1][0] & A[0][1] ==A[1][1] so sort this with descending order so [1 1 6] comes before [1 1 1]. • Same goes for [3 1 1] & [3 1 9]. 00 ENG IN 22:39 05-06-2022
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply