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
Zinaida [17]
2 years ago
6

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.int isSorted(int *array, int n){
Computers and Technology
1 answer:
Tanzania [10]2 years ago
4 0

Answer:

Here the code is given as follows,

Explanation:

Code:-

#include <stdio.h>  

int isSorted(int *array, int n) {

   if (n <= 1) {

       return 1;

   } else {

       return isSorted(array, n-1) && array[n-2] <= array[n-1];

   }

}  

int main() {

   int arr1[] = {3, 6, 7, 7, 12}, size1 = 5;

   int arr2[] = {3, 4, 9, 8}, size2 = 4;  

   printf("%d\n", isSorted(arr1, size1));

   printf("%d\n", isSorted(arr2, size2));

   return 0;

}

Output:-

You might be interested in
What are the advantages of Napier bones?​
Alja [10]

Answer:

portability and simplicaity are the featues of napier bones

8 0
3 years ago
Can someone help me asap​
vichka [17]

Sorry but Your screwed

4 0
2 years ago
Which method of deleting files can be used in windows xp and vista?
Makovka662 [10]
The correct answer is C.

4 0
2 years ago
PLEASE HURRY
creativ13 [48]
I'm pretty sure it's C) or D) because it seems those make the most sense because providing excitement does not matter if that is not their point, repeating a previous point is practically useless because that point has already been said.
5 0
3 years ago
Read 2 more answers
Write a program to draw a text-based graph of a mathematical function f(x)
Makovka662 [10]
I have a very good example of the program you need written on Python. You can use this (sorry for bad tabulation):
import math import math def main(): function = input("Enter a function f(x):\n") x = 0 y = 0 for rows in range(10,-11,-1): for col in range(-10,11,1): x=col roundfx = round(eval(function)) if roundfx == rows: print("o", end="") if rows==0 and col==0 and not rows == roundfx: print("+", end="") if col == 0 and not rows == 0 and not rows == roundfx: print("|", end="") if rows==0 and not col==0 and not rows == roundfx: print("-", end="") else: if not rows == 0: if not col == 0: if not rows == roundfx: print(" ", end="") print() main()
4 0
3 years ago
Other questions:
  • Drag each storage device to its category.
    7·1 answer
  • What is the energy conversion of solar water heaters?
    12·1 answer
  • Select all ways that databases may help you manage and manipulate data and records.
    11·1 answer
  • If you were setting up a network with 100 nodes and you wanted no more than 25 nodes per segment: what devices and connections w
    9·1 answer
  • Given n ropes of different lengths, we need to connect these ropes into one rope. We can connect only 2 ropes at a time. The cos
    9·1 answer
  • What are input masks most useful for in data validation? moving data from one field to another hiding parts of a value that are
    9·2 answers
  • Why When I change my pfp It be blurry and it be ugly- if you know what I mean :c
    15·2 answers
  • If C2=20 and D2=10 what is the result of the function = mathcal I F(C2=D2,^ prime prime Ful "Open")?
    11·1 answer
  • Difine Mainframe Computer~<br><br><br><br><br><br><br><img src="https://tex.z-dn.net/?f=%20%5C%3A%20%20%5C%3A%20" id="TexFormula
    12·2 answers
  • Which of the following is not a reason to choose a community college?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!