Question: for V(i) explain V. (20 points) Consider an n x n table T(1..n, 1..n) of distinct numbers (i.e., a two dimensional array/matrix of n rows

for V(i) explain
V. (20 points) Consider an n x n table T(1..n, 1..n) of distinct numbers (i.e., a two dimensional array/matrix of n rows and n columns). As- sume that the rows are indexed 1,...,n from top to bottom (row 1 is the topmost row), and the columns are indexed 1,...,n from left to right (column 1 is the leftmost column). (i) (15 points) Say that T is (row & column)-sorted if each row in T is sorted in increasing order (from left to right), and each column in T is sorted in increasing order (from top to bottom). See Figure 1 for illustration. 5, 10 12 20 11 15 17 30 14 25 40 50 33 35 75 90 Figure 1: An illustration of a 4 x 4 (row & column)-sorted table. (a) (5 points) Using BINARY SEARCH, explain how to decide in Onlgn) time whether a number key is in a row & column)- sorted n x n table T. (b) (10 points) Give an O(n)-time algorithm that, given a (row & column)-sorted n x n table T and a number key, decides if key is in T. (Hint. Start at entry T(1, n and proceed in a staircase-like fashion.) V. (20 points) Consider an n x n table T(1..n, 1..n) of distinct numbers (i.e., a two dimensional array/matrix of n rows and n columns). As- sume that the rows are indexed 1,...,n from top to bottom (row 1 is the topmost row), and the columns are indexed 1,...,n from left to right (column 1 is the leftmost column). (i) (15 points) Say that T is (row & column)-sorted if each row in T is sorted in increasing order (from left to right), and each column in T is sorted in increasing order (from top to bottom). See Figure 1 for illustration. 5, 10 12 20 11 15 17 30 14 25 40 50 33 35 75 90 Figure 1: An illustration of a 4 x 4 (row & column)-sorted table. (a) (5 points) Using BINARY SEARCH, explain how to decide in Onlgn) time whether a number key is in a row & column)- sorted n x n table T. (b) (10 points) Give an O(n)-time algorithm that, given a (row & column)-sorted n x n table T and a number key, decides if key is in T. (Hint. Start at entry T(1, n and proceed in a staircase-like fashion.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
