Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider a 2D array A[−5…5][10&h... Start Learning for Free
Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:
    Correct answer is '190'. Can you explain this answer?
    Most Upvoted Answer
    Consider a 2D array A[−5…5][10……15], base a...
    I][j] of size n x m where n and m are positive integers. The array A represents a grid where each element A[i][j] represents the height of the terrain at position (i, j).

    To find the highest peak in this terrain, we can iterate through each element in the array and keep track of the maximum height encountered so far.

    Here is a step-by-step algorithm to find the highest peak in the 2D array:

    1. Initialize a variable max_height to store the maximum height encountered. Set max_height to the minimum possible value for the height (e.g., -infinity).

    2. Iterate through each element in the array using two nested loops. The outer loop iterates over the rows of the array (i.e., from 0 to n-1), and the inner loop iterates over the columns of the array (i.e., from 0 to m-1).

    3. For each element A[i][j], compare its height with the current maximum height. If A[i][j] is greater than max_height, update max_height to A[i][j].

    4. After iterating through all elements in the array, max_height will contain the highest peak in the terrain.

    5. Return max_height as the highest peak in the terrain.

    Here is the pseudocode for the algorithm:

    function findHighestPeak(A):
    max_height = -infinity
    n = length(A) // number of rows in A
    m = length(A[0]) // number of columns in A
    for i = 0 to n-1:
    for j = 0 to m-1:
    if A[i][j] > max_height:
    max_height = A[i][j]
    return max_height

    The time complexity of this algorithm is O(n * m) since we iterate through each element in the 2D array exactly once.
    Free Test
    Community Answer
    Consider a 2D array A[−5…5][10……15], base a...
    Given,
    2D array:
    A[−5…5][10……15]
    As we know,
    In row major order,
    A[i][j]= Base address + W × [(i−L1) × (U2−L2+1) + (j−L2)]
    Here values are:
    Base address = 100
    W = 2B
    i = 2
    j = 13
    L1 = −5
    U1 = 5
    L2 = 10
    U2 = 15
    On substituting these values we get,
    A[2][13] = 100 + 2 × [(2−(−5)) × (15−10+1) + (13−10)]
    = 100 + 2 × [(7) × (6) + 3]
    = 100 + 2 × [45]
    A[2][13] = 190
    Hence, the correct answer is 190.
    Explore Courses for Computer Science Engineering (CSE) exam

    Similar Computer Science Engineering (CSE) Doubts

    Top Courses for Computer Science Engineering (CSE)

    Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. Can you explain this answer?
    Question Description
    Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. 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 Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. 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 Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. Can you explain this answer?.
    Solutions for Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. 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 Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. Can you explain this answer?, a detailed solution for Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. Can you explain this answer? has been provided alongside types of Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a 2D array A[−5…5][10……15], base address is 100 and word length 2B, find address of the element A[2][13] using row major order:Correct answer is '190'. 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