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
pogonyaev
3 years ago
14

Given an array of n distinct integers sorted in ascending order, write a function that returns a Fixed Point in the array, if th

ere is any Fixed Point present in array, else returns -1. Fixed Point in an array is an index i such that arr[i] is equal to i. Note that integers in array can be negative. Examples: #include using namespace std; void removeDivByFive(int *arr,int& size) { int index=0; for(int i=0;i
Computers and Technology
1 answer:
Zinaida [17]3 years ago
6 0

Answer:

The function is as follows:

int returnsFixed(int arr [],int n){

   int retVal = -1;

   for(int i = 0; i<n;i++){

       if(i == arr[i]){

           retVal = i;

           break;

       }

   }

   return retVal;

}

Explanation:

This defines the functionl it receives the array and the length of the array

int returnsFixed(int arr [],int n){

This initializes the return value to -1

   int retVal = -1;

This iterates through the array

   for(int i = 0; i<n;i++){

This checks if i equals arr[i]

       if(i == arr[i]){

If yes, the return value (i.e. the fixed point) is set to i

           retVal = i;

And the code is exited

           break;

       } This ends the if condition

   } This ends the iteration

This returns the calculated fixed point

   return retVal;

}

You might be interested in
What is HTML. What is HTML ​
Afina-wow [57]

Answer:

HTML stands for Hyper Text Markup Language. HTML is the standard markup language for creating Web pages. HTML describes the structure of a Web page. HTML consists of a series of elements. HTML elements tell the browser how to display the content.

Explanation:

6 0
3 years ago
Read 2 more answers
What is the processing speed for the second generation of computers​
Helga [31]

10mbp

I hope it helps you

5 0
3 years ago
You work as the IT security administrator for a small corporate network. You have designed the physical security of the offices
ladessa [460]

The security IT administrator he or she is planning to install smart card communications over the network which is can be access through TCP IP address.

Smart card key reader to be placed or installed where is required  such as an opening door  or entrance of office or organization extra.

Key card readers should be contactless and record more volume of data and it should synchized with the system at regular intervals.

By Installing smart card and it readers unauthorized  person entry to lab or network server can be avoided. Since smart card reader connected to the network, IT SECURITY administrator can generate log reports.

5 0
3 years ago
What research method in sociology is also referred as fieldwork
Tanya [424]
The answer is Field research  
8 0
3 years ago
Help with prg 140 class it is really giving me a hard time understanding it<br>​
Snowcat [4.5K]

Answer:

post your homework so we can help you.

Explanation:

8 0
3 years ago
Other questions:
  • What is one strengths of line graph? a) Line graphs show percentage in a whole b) Line graphs show change over time c) Line grap
    13·2 answers
  • 11. If the following pseudocode were an actual program, what would it display:
    6·2 answers
  • If num is an int which expression always evaluates to true if num holds an odd number
    15·1 answer
  • Technologies that function within the established system are called
    12·1 answer
  • How do I change the selected cell to 20 pt
    8·2 answers
  • When preparing to communicate a solution to a design problem, you must:?
    5·1 answer
  • The IT department in a company is looking for a solution to consolidate the functionality of several mission critical server com
    14·1 answer
  • True or false Encryption prevents hackers from hacking data?
    8·1 answer
  • you are teaching a class about basic camera functions like power, basic date/time, menu navigation, and how to properly attach a
    9·1 answer
  • What are some benefits that each computer system being used?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!