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
Write your question here (Keep it clear and simple to get the best answer)
weeeeeb [17]
What is your favorite book?
4 0
3 years ago
Read 2 more answers
WNOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOW
beks73 [17]

Answer:

yes.

Explanation:

7 0
3 years ago
Which element adds a “page turn” effect to the slides in a presentation?
garri49 [273]

Answer:

D. Slide Transition

Explanation:

Hope this help you

3 0
3 years ago
Read 2 more answers
A computer that supports 10/100/1000 Ethernet allows for 10, 100, or 1000 ________ per second.
stich3 [128]

A Computer that supports 10/100/1000 Ethernet allows for 10,100,or 1000 gigabyte per second.

4 0
4 years ago
What is a major difference between a server computer and a client computer on a network?
AveGali [126]
Server computers are mostly used for internet porpoises, because server computers are carrying websites or game servers, while the client computer is actually just connecting to the server computer's network and accesses for example websites saved and uploaded on the server computer.
7 0
4 years ago
Other questions:
  • What are options in the Advanced tab in the Share Workbook dialog box? Check all that apply
    14·2 answers
  • Phase 1 RequirementsCode submitted for Phase 1 will only have the following capability. Any additional coding will result in the
    13·1 answer
  • OCR Land is a theme park aimed at children and adults. Entrance tickets are sold online. An adult ticket to OCR Land costs £19.9
    7·1 answer
  • I need help in creating a Java Program; To calculate the chapter from which you solve the programming exercise, below are the re
    7·1 answer
  • Given main() and a base Book class, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a
    10·1 answer
  • How many questions do you need unlock messages
    6·1 answer
  • Cual es el procedimientos para asistir en el transporte publico a personas discapacitadas
    6·1 answer
  • Qué es una magnitud eléctrica
    12·1 answer
  • You are supposed to do a report on something that interests you. You decided to do a report on dogs. As you research, you take n
    14·1 answer
  • How to transfer crypto from coinbase to coinbase wallet
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!