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]
3 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]3 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 view allows you to make changes to the content of your presentation?
Neporo4naja [7]

Answer:

Share your screen and edits the parts you want. What meet are you using, zoom or something else?

6 0
3 years ago
Why is Touchpad used in the laptop computer​
Ber [7]

Answer:

in controlling the mouse or cursor

Explanation:

as is it known tha a cursor is a poniting device. and the only way to control it without a mouse is the touchpad

3 0
3 years ago
Where does the report footer section appear?
faltersainse [42]

The report footer section appear in pinnacle margin, even as the footer is a phase of the record that looks withinside the backside margin.

<h3>What is document footer access?</h3>

Add info in your Access shape or document with footers. If you've got got unique facts inclusive of an equation, date or time that does not in shape withinside the frame of your shape or document, you could upload it to a footer. Footers seem at the lowest of the file or the web page, relying at the alternatives you choose.

The Report Header, which prints as soon as on the pinnacle of the document, for the title. The Footer, which prints as soon as on the quit of the document, for combination totals.

Read more about the footer section:

brainly.com/question/1327497

#SPJ1

3 0
2 years ago
Write a while loop that prints 1 to user_num. Sample output for the given program: 1 2 3 4
Scorpion4ik [409]
Given 1234
i=1
user num=4#assume positive
while (user-num>=i);
print(i)
i+=1
#include <iostream>
using namespace std;
int main()
{int userNum=0;
int i=0;
userNum=4; ##assume positive
i=1;
while (i <=userNum){
cout<<i>>" ";
i=i+1;
cout <<endl;
return0;
}
6 0
4 years ago
Read 2 more answers
What are the advantages of the java.util.Stack implementation of a stack?
klemol [59]

Explanation:

The advantages of java.util.Stack are as following:-

  1. java.util.Stack is an implementation of the vector class hence it can keep track of position of elements in the stack hence it is not required to store an additional pointer for each node.
  2. In the implementation it allocates space only that much is needed.

These are the two advantages of java.util.Stack.

3 0
3 years ago
Other questions:
  • Can you give me a free neon legendary pet in Adopt Me on Roblox!!!​ my user is: IamNathan215
    15·2 answers
  • Two types of business communications enhanced by desktop publishing are
    7·2 answers
  • (MCQ question). Which of the following files stores information about a local Google Drive installation such as User email ID, L
    6·1 answer
  • How we can get NET I'D by IP Address?
    11·1 answer
  • How do I get rid of this?
    14·2 answers
  • You are about to install a new USB camera on your Linux system and you realize that there is no device special file available fo
    13·1 answer
  • Why computer literacy is vital to access in business work
    7·1 answer
  • Im lonnnelllly........................who want to date
    11·1 answer
  • What is control structure write it's types​ .
    15·1 answer
  • Is a device used to test the network connection.
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!