Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Two matrices M1 and M2 are to be stored in ar... Start Learning for Free
Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will be
  • a)
    best if A is in row-major, and B is in column- major order
  • b)
    best if both are in row-major order
  • c)
    best if both are in column-major order
  • d)
    independent of the storage scheme
Correct answer is option 'D'. Can you explain this answer?
Verified Answer
Two matrices M1 and M2 are to be stored in arrays A and B respectively...
This is a trick question. Note that the questions asks about time complexity, not time taken by the program. for time complexity, it doesn't matter how we store array elements, we always need to access same number of elements of M1 and M2 to multiply the matrices. It is always constant or O(1) time to do element access in arrays, the constants may differ for different schemes, but not the time complexity.
View all questions of this test
Most Upvoted Answer
Two matrices M1 and M2 are to be stored in arrays A and B respectively...
And M2 in row-major order and store the result in array C in row-major order would be O(n^2), where n is the size of the matrices.

In row-major order, the elements of the matrices are stored sequentially in memory row by row. To compute the result matrix C, we need to iterate over each element in M1 and M2 and perform the corresponding operations. This requires iterating over n^2 elements in total.

The time complexity of accessing an element in a row-major order array is O(1), as the elements are stored sequentially and can be accessed directly. Therefore, the overall time complexity of computing M1 and M2 in row-major order and storing the result in array C in row-major order is O(n^2).

Note that if the matrices are extremely large, the actual time complexity may depend on the specific implementation and hardware limitations. However, in general, the time complexity of this algorithm is O(n^2).
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer?
Question Description
Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer?.
Solutions for Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer?, a detailed solution for Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer? has been provided alongside types of Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Two matrices M1 and M2 are to be stored in arrays A and B respectively. Each array can be stored either in row-major or column-major order in contiguous memory locations. The time complexity of an algorithm to compute M1 × M2 will bea)best if A is in row-major, and B is in column- major orderb)best if both are in row-major orderc)best if both are in column-major orderd)independent of the storage schemeCorrect answer is option 'D'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev