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
miss Akunina [59]
2 years ago
13

Write a recursive function that returns 1 if an array of size n is in sorted order and 0 otherwise. Note: If array a stores 3, 6

, 7, 7, 12, then isSorted(a, 5) should return 1 . If array b stores 3, 4, 9, 8, then isSorted(b, 4) should return 0.
Computers and Technology
1 answer:
galina1969 [7]2 years ago
6 0

Answer:

The function in C++ is as follows:

int isSorted(int ar[], int n){

if (n == 1 || n == 0){

 return 1;}

if (ar[n - 1] < ar[n - 2]){

 return 0;}

return isSorted(ar, n - 1);}

Explanation:

This defines the function

int isSorted(int ar[], int n){

This represents the base case; n = 1 or 0 will return 1 (i.e. the array is sorted)

if (n == 1 || n == 0){

 return 1;}

This checks if the current element is less than the previous array element; If yes, the array is not sorted

if (ar[n - 1] < ar[n - 2]){

 return 0;}

This calls the function, recursively

return isSorted(ar, n - 1);

}

You might be interested in
Need help finding the totals and with the empty spots
Lunna [17]

Answer:

weff WEF ef ef aeF EFaef  EFE  fe efaef ea f

Explanation:

8 0
2 years ago
PLS HELP WITH MY PYTHON HW ILL GIVE YOU BRAINLIEST
Nezavi [6.7K]

Answer:

class Cat:

   isHungry = None

play = Cat().isHungry = True

eat = Cat().isHungry = False

if play:

   print("I am hungry, I cannot play")

else:

   play = Cat().isHungry = False

if eat:

   print("I am full, I cannot eat")

else:

   eat = Cat().isHungry = True

Explanation:

Just simple if and else statements.

4 0
2 years ago
Effective note-taking helps support<br><br> action.<br> distinction.<br> distraction.<br> retention.
zloy xaker [14]
It is the last one retention because writing it out will cause it to stick in your brain better
7 0
3 years ago
Read 2 more answers
The operating system is not directly involved in one of these tasks.Immersive Reader
Alex73 [517]
Displaying a web page
3 0
3 years ago
Describe two measures you can use to evaluate whether an attachment in a message is reliable to open.
meriva
<span>If a attachment is not reliable to open, terrible effects can happen, peradventure it may have a virus or even malware that can destroy a computers software. 

To avoid this and stay on the safe side, try the following:-

- Open it in protected view 
- Do not save the attachment on your computer 
- Look at the author and read the message carefully to make sure it is not biased. 
- Open it on a flash-drive </span>
8 0
3 years ago
Read 2 more answers
Other questions:
  • A model release can be either oral or written down. true or false
    13·2 answers
  • Given a one dimensional array arr, what is the correct way ofgetting the number of elements in arr
    15·1 answer
  • Jabari is writing a program which prompts a user for a value with a decimal. Which function should he use? float() int() print()
    9·2 answers
  • Please help with the question no. 5 and 7 please help ​
    6·1 answer
  • A device that make it possible for a muitiple customer to share one address is called
    13·1 answer
  • What is an operating system? What are the main functions of a modern general purpose operating system?
    7·1 answer
  • Which of these are tools used to diagnose and test code? Check all of the boxes that apply.
    9·1 answer
  • When delivering digital technologies to clients, what is a best practice to make those solutions sustainable?
    10·1 answer
  • Who is the best valorant character
    11·2 answers
  • Glenda is searching airline schedules on HolApp, a mobile Web application. While browsing the application, a banner appears on t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!