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
What explains the discrepancy between the number of bytes you can
sergejj [24]

Answer:

This is because, the advertisers report the storage space in decimal while the computer reads the storage space in binary.

Explanation:

The advertisers report the storage space in decimal or base 10 because humans count in decimal, whereas the computer reports the storage space in binary or base 2.

Since the computer storage is in bytes and 8 bits equal 1 byte, It is easier to write a storage space of 1 kB as 1000 B but it is actually supposed to be 1024 B(2¹⁰). So, there is a discrepancy of 1024 B - 1000 B = 24 B.

As  we go higher, the discrepancy increases. For example, 1 MB is advertised as 1000 kB = 1000000 B but is actually supposed to be 1024 kB = 1024 × 1024 B = 1048576 B. So, there is a discrepancy of 1048576 B - 1000000 B = 48576 B.

So, the actual number of bytes on the storage device is actually less than that reported due to the different number systems in which they are reported in. This discrepancy is less in memory cards or flash drives though in which the stated value of storage capacity might be the actual storage size.

Note that the base 10 or decimal system was chosen by advertiser since this is what consumers understand.

8 0
2 years ago
Choose all of the items that represent functions of an operating system.
Lynna [10]

Answer:

all 5

Explanation:

operating system is the software thay runs other software

brainly.com/question/18465035

6 0
1 year ago
The movie polar express was critically acclaimed due to the unbelievably lifelike movements of Tom Hanks character
Fed [463]
I think it is greyhound
6 0
2 years ago
Keyboards that are widely used on various smartphones and other small portable devices, and which are designed primarily for com
mr Goodwill [35]

Answer:

Option A is the correct answer for the above question.

Explanation:

The keyboard is a device, by which a human can instruct the computer in the text form. There are so many keyboards in which, thumb keyboard is one of them. The thumb keyboard is found in mobile phones, smartphones or PDA phones, which is used for personal use. It is a designed layout of the keyboard that can be placed on the hand of the human and a person can type on its with the help of his thumb.

The above question asked about the type of the keyboard which is used in various smartphones and other phones. That keyboard is thumb keyboard which is described above and it is stated from the option A. So option A is the correct answer while the other is not because--

  • Option B states about the traditional keyboard which is used for the PC only.
  • Option C states about the Notebook keyboard which is used for the Notebook computers only.
  • Option D states about combination which is not a type of keyboard.
7 0
3 years ago
Which of the following statements is true of a server? Question 18 options: A) It supports processing requests from remote compu
TiliK225 [7]

Answer:

Option (A) is the correct answer of this question.

Explanation:

The server supports the processing requests from the remote computers. A system is a device built to accommodate inquiries from many other external systems and customers to execute transactions. Employees are called private computer ,tablets, including phones which connect websites.

Network resources are handled through servers.The server is a software application or tool providing a service to some other software program and its customer, also identified as those of the user.

Other options are incorrect because they are not related to the given scenario.

5 0
3 years ago
Other questions:
  • 1.
    13·1 answer
  • ________ is a program that runs on a computer to manage and control a computer's activities.
    11·1 answer
  • Create a view named ItemOrder view. It consists of the TaskID, description, price, order number, order date, and quoted price fo
    8·1 answer
  • Data as a service began with the notion that data quality could happen in a centralized place, cleansing and enriching data and
    15·1 answer
  • One key to success in a career is to be an accomplished
    15·1 answer
  • What is ‘Software Testing’?
    13·1 answer
  • Using Phyton
    9·1 answer
  • What is the purpose of application software
    12·1 answer
  • How are the waterfall and agile methods of software development similar?
    13·1 answer
  • suppose one packet switches between a sending host and a receiving host. the transmission rates between the sending host and the
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!