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]
3 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]3 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
Ryan is looking to buy a new HDTV set. He knows from friends that LCD set screens reflect less light than plasma set screens, bu
lbvjy [14]

Answer: Cognitive

Explanation:

 According to the question, the Ryan shows cognitive attitude towards the HDTV. The cognitive component basically refers to the three main components that are:

  • Thoughts
  • Beliefs
  • Attributes

The cognitive component is one of the type of attitude which basically consist of various types of thoughts, knowledge and the beliefs towards the any type of object. It is one of the belief and opinion of the attitude.  

3 0
3 years ago
Will, there be any presents this year
garri49 [273]

Answer:

no why

Explanation:

8 0
3 years ago
How does a hard drive
stealth61 [152]
Your answer is incomplpete<span>Native Americans have lived there for thousands of years, long before ... On July 4, 1776, people from the thirteen colonies created the United States ... In the early 1800s, the new nation faced many controversial issues, such as slavery ..... the United Stateswould not become involved in a war the two countries were fighting ...</span>‎Pre-Columbian America - ‎Colonial America - ‎<span>American Revolution</span>
8 0
4 years ago
In Linux, the /etc/inittab file describes the processes that are started up during boot up. Each entry in the /etc/inittab file
Softa [21]

Answer:

The answer is "Action".

Explanation:

The directory /etc/inittab file is also known as a configuration file that is used by the System V (SysV) initialization system in Linux. where System V stands for system version that is used for Unix and Linux both. It was developed in AT&T. This configuration file includes three items that are:

  • Runlevel norm
  • Which procedures should you begin, track and restart when you end?
  • Which actions to perform when a new run level is introduced?

Example: id:runlevels:action:process

  • id stands for identification code. It includes a sequence of one to four characters that identify in function.
  • runlevels it is a list that runs on levels in which this applies.
  • action is a specifies code in the field that describes to init how to run the process.  
  • A process is a command that is ready to execute.
3 0
3 years ago
A cathedral hull allows the boat to do what
Hoochie [10]
It allows power boats to have stability while cruising. The cathedral hull  is like a trimaran in terehat it has one main  and two side hulls stuck together so that has a somewhat square to rectangular shape and therefore exhibits greater stability than a single hulled boat. It became more popular with the advent of fibreglass boats in the 1960's and '70s.
5 0
3 years ago
Other questions:
  • If you are going to attach more than 15 devices to your wireless network, you should make sure your router supports which standa
    14·1 answer
  • Can i configure my entire network as a dmz
    6·1 answer
  • True or false? risk assessment should cover personnel, as well as technical support such as firewalls, secure operating systems
    13·1 answer
  • The appropriate software to use for creating research papers is ________ software. Select one: A. presentation B. word processin
    15·1 answer
  • You and your project team have been asked to generate a solution to a problem. The problem is not complicated, and you are sure
    6·1 answer
  • PowerPoint:
    7·2 answers
  • The ____ attribute can be used only with input boxes that store text. Group of answer choices type pattern required value
    9·1 answer
  • Julie is purchasing new shoes on a website for her favorite store. Which of the following would indicate that a website is a sec
    6·1 answer
  • 2 4.1.2 Quiz: Information Systems and Business Planning
    11·1 answer
  • The ______________<br> holds data only while the computer is on.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!