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]
3 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]3 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
Given the following function definition
siniylev [52]

Answer:

B. 1 6 3

Explanation:

Given function definition for calc:

void calc (int a, int& b)

{

int c;

c = a + 2;

a = a * 3;

b = c + a;

}

Function invocation:

x = 1;

y = 2;

z = 3;

calc(x, y);

cout << x << " " << y << " " << z << endl;

  • Since x is passed by value, its value remains 1.
  • y is passed by reference to the function calc(x,y);

Tracing the function execution:

c=3

a=3

b=c+a = 6;

But b actually corresponds to y. So y=6 after function call.

  • Since z is not involved in function call, its value remain 3.

So output: 1 6 3

3 0
3 years ago
HIPAA protects which of the following kinds of data?
Gelneren [198K]
The answer is a i looked up the question and it says a
5 0
3 years ago
Read 2 more answers
Your boss asks you to transmit a small file that includes sensitive personnel data to a server on the network. The server is run
mel-nik [20]

Answer:

a. Telnet transmissions are not encrypted.

Explanation:

Indeed, since <em>Telnet transmissions are not encrypted,</em> all the information sent, and even the characters typed in the telnet console are sent in clear text.

This is a security issue, since any other device in the same network will receive a copy of the information (packets) sent. For default, all the devices, except for the server expecting to receive the information, will discard the packets. However it is easy to actively <em>listen </em>and keep those packets, wich will contain the information in plain text and human readable.

4 0
3 years ago
Which event occurs when the user clicks on an html element?
svet-max [94.6K]
Javascript can be executed i believe. but i just googled it,check it for yourself
8 0
3 years ago
What patterns do you find within the fractions in the inch on the ruler?
PtichkaEL [24]

Answer:

The markings on a standard ruler represent the fractions of an inch. The markings on a ruler from the start to the 1″ mark are: 1⁄16“, 1⁄8“, 3⁄16“, 1⁄4“, 5⁄16“, 3⁄8“, 7⁄16“, 1⁄2“, 9⁄16“, 5⁄8“, 11⁄16“, 3⁄4“, 13⁄16“, 7⁄8“, 15⁄16“, and 1”.

8 0
3 years ago
Other questions:
  • Waterpower was first harvested by ancient societies using
    5·1 answer
  • When approved for a loan, an individual essentially applied for aid in the area of...
    15·1 answer
  • Which of the following statements is true?
    12·1 answer
  • Define a function below called average_strings. The function takes one argument: a list of strings. Complete the function so tha
    11·1 answer
  • A typical analog cell phone has a frequency of 850 mhz; a digital phone a frequency of 1950 mhz. compared to the signal from an
    7·1 answer
  • Can some one help me i do not now how to give a BRANLEST. if you help i will give you one BRANLEST.
    7·2 answers
  • After separating from Mexico, Texas passed laws that made it harder for slave owners to _____________ slaves.
    12·2 answers
  • Can someone find out what this binary number thing is. Just find out the message, I'm having a difficult time
    13·1 answer
  • Imagine that a team of scientists test a certain hypothesis, and the experimental results show that it is false.
    6·1 answer
  • in a particular factory, a team leader is an hourly paid production worker who leads a small team. in addition to hourly pay, te
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!