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
The underline format will underline ____.
alisha [4.7K]
<span>The underline format will underline </span>the selected text
7 0
3 years ago
The goal expressed in this definition states that data visualization is about ________________ .
RSB [31]

Answer:

4. Interpreting.

Explanation:

Data visualization is used to represent data using graphics. It narrates the values of data graphically, creating a relationship between the inputted group of data and the images being viewed by observers.

In big data technology, data visualization helps to show or interpret the large amount of data for both descriptive analysis and predictive analysis of the presented data. The communication of the data and image is made possible through the mapping of a graph marks and individual data sets or values.

8 0
3 years ago
Read 2 more answers
How did Bill Gates benefit from free enterprise? Need a paragraph please. Will give the branliest!!
olchik [2.2K]

Answer:

Bill Gates used his skills and brains to build a business. In conclusion, Bill Gates was very successful with his industry thanks to free enterprise. He, along with his employees and friends, created and almost perfected the software known as Microsoft. The free enterprise system provides the right to private enterprise, which allowed him to choose his own business and to run it without governmental influence. Because he could create his own business and design his own products, Gates was able to specialize in technology.

Explanation:

8 0
2 years ago
Pls awnser if awnser is wrong I will unmark brainliest
choli [55]

Answer: i think 1, 3, and 4

Explanation:

3 0
2 years ago
1. Write a generic method that compares its 2 arguments using the equals method and returns true if they are equal and false oth
Ganezh [65]

Answer:

Explanation:

The following piece of code is written in Java. It creates the method as requested that takes in two generic objects and compares them using the .equals() built in Java method. This method will return True if the objects are identical or False if they are not. A test case is used in the code and the output can be seen in the attached image below.

   public static <T> boolean comparePerez(T a, T b) {

       return a.equals(b);

   }

5 0
3 years ago
Other questions:
  • Which of the following functions and expressions will convert the ASCII character "Z" to its numeric equivalent ASCII code?
    7·1 answer
  • Tanya has received an email, apparently from her bank, stating that some of her records were lost during server maintenance work
    13·2 answers
  • Univariate linear regression Note: Solutions to this problem must follow the method described in class and the linear regression
    7·1 answer
  • The calls radioed to patrol officers, or assignments given to police patrol units by 911 dispatchers, reveal the types of proble
    9·1 answer
  • How does virtualization factor into a layered vs. non-layered design discussion?
    14·2 answers
  • Jane receives an email claiming that her bank account information has been lost and that she needs to click a link to update the
    13·1 answer
  • Write a program that prompts the user for the name of two files each containing a single line that represents a decimal integerc
    11·1 answer
  • What is the alogarithm for solving the perimeter of a triangle
    11·1 answer
  • Lol WAKE UP!!! and get ready to answer my questions.
    12·1 answer
  • You learned that "The CPU interacts with memory in a process that is known as
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!