Find Out the summation Of the boundary elements Of the array

Find Out the summation Of the boundary elements Of the array


Problem 2.8:

Given a two-dimensional array, find out the summation of the boundary elements of the array. Here no element should be added twice.
Solution:
>>First, we have to identify the boundary elements.
  • In a two dimensional array, elements of first column and the last column and the first row and last row are the boundary elements as shown in the Figure-2.8.
>> Here the index, i represents the row number and j represents the column-number.
  • When i is 1, the row is the first row and when i is m (where m represents the number of rows in the array), the row is the last row.
  • Similarly, when j = 1, the column is the first column and the index of the last column is j = n. So, a number in a two-dimensional array is a boundary element if i = 1, i = m, j = 1 or j = n


The summation Of the boundary elements Of the array


  • We shall start from the first number of the array.
  • If it is a boundary element, the number will be added to the sum (which is a variable to store the result and initially it is set zero).
  • We shall check every number whether it is a boundary element or not, if the number is a boundary element it will be added to sum.
  • Otherwise, we shall proceed with the next number of the list (array) and continue the process to the end of the list.

2 comments:

  1. i need ppt file

    ReplyDelete
    Replies
    1. I need the code to solve the summation of boundary elements!!!!!

      Delete

There was an error in this gadget

Followers

About Me

Dhaka, Dhaka, Bangladesh
..