1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
abruzzese [7]
2 years ago
11

We informally define the term corresponding element as follows: The first element in an array and the last element of the array

are corresponding elements. Similarly, the second element and the element just before the last element are corresponding elements. The third element and the element just before the element just before the last element are corresponding elements -- and so on. Given an array a, write an expression for the corresponding element of a[i].
Computers and Technology
1 answer:
yanalaym [24]2 years ago
7 0

The corresponding element in an array can be written as follows.

The given array is arr[len] whose size is given by integer variable len. We take another integer variable k.

Corresponding element for arr[k] = arr[len-1-k]

This applies for all expressions of k beginning from 0 upto half the size of len, i.e., len/2.

For element, arr[0], the corresponding element is arr[10-1-0] = arr[9].

The above expression is valid if the sum of index of both element and its corresponding element adds upto the index of the last element of the array.

Example: k + (len – 1 - k)  

= k + len – 1 - k

= len – 1

= index of the last element of the array

The number of elements that an array can hold is one more than the index of the last element of the array.

Suppose an array of 10 elements is given. The above expression holds true since first element of the array is always written as arr[0] and last element will be written as arr[9] for an array of 10 elements.

This is illustrated below.

The c++ program to display the element and its corresponding element along with their index is shown below.

#include <iostream>

using namespace std;

int main() {    

   int len=10, arr[len],k;    

   for(k=0; k<len; k++)

   {

       // elements are initialized to twice their index

       arr[k] = k*2;

   }

   cout<<"Element "<<" Index "<<"\t"<<" Corresponding "<<" Index"<<endl;

   for(k=0; k<len/2; k++)

   {

       cout<<arr[k]<<"\t"<<"\t"<<"\t"<<k<<"\t"<<"\t"<<"\t"<<arr[len-1-k]<<"\t"<<"\t"<<len-1-k<<endl;

   }

}

OUTPUT

Element Index    Corresponding   Index

0  0   18  9

2  1   16  8

4  2   14  7

6  3   12  6

8  4   10  5

 

The above program initializes all the elements of the array to twice the value of their corresponding index. Following this, the element, its index, the corresponding element and its index is displayed.

All the above is achieved using for loop. The size of the array and its elements can be changed.

The expression for the corresponding element is thus explained.

You might be interested in
Which best describes IMEI?
Delicious77 [7]

Answer:

A unique identifier for a mobile phone

Explanation:

There are different codes and tracking number assigned to different devices such as laptop, mobiles and other devices. The purpose of this task is to make sure the security of device in all aspects. The tracking number that is used to track mobile phone is named as IMEI that stands for International Mobile Equipment Identity.

IMEI is the the unique identity of mobile phone device that consists of 15 digits. It is the unique number that is assigned to phones.

8 0
2 years ago
Which one can be used as watermark in a word document?​
otez555 [7]

Answer:

On the Design tab, select Watermark.

In the Insert Watermark dialog, select Text and either type your own watermark text or select one, like DRAFT, from the list. Then, customize the watermark by setting the font, layout, size, colors, and orientation. ...

Select OK.

4 0
3 years ago
Which of the following is a basic principle of improvement?
lesya [120]

From the given the statement, "every system is perfectly designed to get the results it gets" is a basic principle of improvement.

Option B

<u>Explanation:</u>

The improvement activity begins with the quote ‘every system is perfectly designed to get the results it gets’, by W. Edwards Deming; The quote states both the unintended and intended effects are designed into our systems.

For example: Healthcare in the UK has been perfectly designed to lower the waiting times to 18 weeks for various procedures over last twelve years. Reflecting on Safer Patients Initiative (SPI), this can be true to improvement systems: every improvement system is perfectly designed to get the results its gets and SPI is a case in point.

The leading improvements that need to be designed into our improvement systems:

  • Improvement activity needs to be built on strong foundations
  • Greater engagement with people’s intrinsic motivation
  • Embrace a wider set of methods
  • Greater understanding of how systems and processes outside direct clinical care contribute to safety and quality.

So, it can be concluded that the line given by W. Edwards Deming tends to be the principle of improvement.

6 0
3 years ago
User name ideas for ro blox? I'm changing mine and I dont know what I want. No numbers or underscores!
SpyIntel [72]
Lil.younging or 2k(your name)
8 0
2 years ago
Read 2 more answers
Plz hurry !!!
lakkis [162]

Answer: The <u>Ordering Tag List </u>defines the numbering styles of lists in HTML pages.

<ol>

</ol>

Inside this tag, you have <li></li> which will contain individual lists.

For example:

<ol>

   <li> This is my first point. </li>

   <li> This is my second point. </li>

   <li> This is my second point. </li>

</ol>

is displayed as:

1. This is my first point. 

2. This is my second point. 

3. This is my second point.

Read more on Brainly.com - brainly.com/question/9724249#readmore

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • What is true about an electric field around a negative charge?
    8·2 answers
  • ____ is designed for short-distance connections and has only a few lambdas, with a greater space between lambdas. Group of answe
    9·2 answers
  • Which of the following is most often added to safety glasses to provide better protection from impact and flying particles? A. S
    14·1 answer
  • Which of the following occurs during data cleansing?
    9·1 answer
  • Please help I upped the points and please don't answer if you don't have the answer..
    13·1 answer
  • You attempt to telnet to system 192.168.1.240. You receive the following message: "Connecting To 192.168.1.240...Could not open
    5·1 answer
  • Why do many experts recommand longer time horizonal if you are doing high risk investment
    7·1 answer
  • Michael needs to ensure that those items that are automatically archived are still easily accessible within Outlook. Which optio
    5·2 answers
  • Applications of the e-government​
    9·2 answers
  • Question 2 of 10
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!