Algorithms question: Assumptions: Integers in each row are sorted in ascending from left to right. Integers in each colu

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

Algorithms question: Assumptions: Integers in each row are sorted in ascending from left to right. Integers in each colu

Post by answerhappygod »

Algorithms question:
Algorithms Question Assumptions Integers In Each Row Are Sorted In Ascending From Left To Right Integers In Each Colu 1
Algorithms Question Assumptions Integers In Each Row Are Sorted In Ascending From Left To Right Integers In Each Colu 1 (22.32 KiB) Viewed 29 times
Assumptions:
Integers in each row are sorted in ascending from left toright.
Integers in each column are sorted in ascending from top tobottom.
Special Assumptions:
The matrix may have missing elements. If that is the case: thecell value will be replaced with a special value called INF. Thinkof INF as a value that is bigger than any number (similar toinfinity in mathematics).
If a row contains this INF value, it will be the last value onthe row.
If a column contains this INF value, it will be the last valueon the column.
Example: if our matrix contains one INF value (and the rest arenumbers), the INF value will be located at the bottom row of therightmost column.
If our matrix has NO numbers, all cells will have INF values
Question:
Create an efficient algorithm valueInsert(B, n, value)where B is a non-full 2D matrix (thus a matrix satisfying the aboveassumptions and containing at least one INF value), value is anumber to be inserted. The algorithm must be in-place thusadditional matrix/array can NOT be used.
147 11 15 5 8 12 19 6 9 16 22 2 3 10 13 14 17 14 17 24 18 21 23 26 30
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply