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
Need the answer for this code hs will give brainly
Masteriza [31]

Answer:

3

Explanation:

Given

The code segment

Required

How many times will move() be executed

The move() function is executed when the loop is executed.

The range and condition of the loop is as follows:

i = 0; i < 3; i ++

i = 0; i < 3 and i ++ means i= 0, 1, 2

<em>So move() will be executed for the values of i= 0, 1, 2 (i.e. 3 values or 3 times).</em>

7 0
3 years ago
A user who enters americanbank.net into a web browser instead of the correct americanbank and is then taken to a fake look-alike
Vlada [557]

Answer:

Typosquatting is the correct answer.

Explanation:

Typosquatting is another type of cybersquatting in which any user or person enters into the others sites from the web browser and then, they create another fake that is usually same as that site. They also create that type of address of the fake websites that is somewhere similar to the original and these are illegal in many countries.

6 0
4 years ago
Read 2 more answers
Connect 5 LEDs with any random colors. Iteratively, turn ON 1 to 5 LED(s) that will take 5 iterations in total, and in every ite
vlabodo [156]

Answer:

See explaination for program code.

Explanation:

C++ programming language is a powerful general-purpose programming language. It can be used to develop operating systems, browsers, games, and so on.

C++ supports different ways of programming like procedural, object-oriented, functional, and so on. This makes C++ powerful as well as flexible.

Please kindly refer to attachment for a C++ programming code that performs the operation.

7 0
4 years ago
For which of the four game elements will you give a detailed description about the challenges that the player will face, such as
vaieri [72.5K]

The four game elements that will give you  a detailed description about the challenges that the player will face is option D: objective.

<h3>What goals does game development have?</h3>

To bring about creativity and originality in task completion and issue solving. to prepare pupils for group collaboration.

Note that giving the player a clear objective gives them something to aim for. Make sure the player can relate to this motivation.

Therefore, The most crucial component of a game can be its objectives, which determine how the game is won or lost, what the player is instructed to perform in-game, and what the player must do to gain optional <em>Achievements</em>.

Learn more about objective from

brainly.com/question/18516671
#SPJ1

3 0
1 year ago
Which of these is NOT an advantage of the impact of computer careers.
Illusion [34]

An increase in the number of stress and health concerns that result from working in a computer environment.  
Let's look at the available options and see what is, or is not an advantage.  
Web designers have created websites that allow individuals to shop, promote business, bank, and communicate via social media sites.
 * This means that people don't actually have to travel in order to do their business and meet new people. Sounds like an advantage to me, so this is a bad choice.  
An increase in the number of stress and health concerns that result from working in a computer environment. 
* Hmm. People getting sick. Doesn't sound like anything I'd like. So this isn't an advantage and is the correct answer.  
Medical diagnoses can be made earlier 
* Faster diagnoses of diseases. Sounds like an advantage to me. So this is a bad choice.  
Businesses can save costs on travel by meeting online using teleconference options 
* Saving money and time. Sounds like an advantage. So this is a bad choice.
5 0
4 years ago
Other questions:
  • Which of the following guidelines about forwarding e-mail messages is most appropriate?
    12·2 answers
  • Which of the following tasks can you perform using a word processor?
    12·1 answer
  • What is a mortgage?
    8·2 answers
  • Create a class called Home that contains 4 pieces of information as instance variables: county (datatype string), street (dataty
    5·1 answer
  • Which quality is likely to ensure consistent career growth in the computer field?
    9·2 answers
  • Write a C++ Win32 Console Application that will use nested for loops to generate a multiplication table from 1 x 1 to 10 x 10. U
    12·1 answer
  • You might have trouble interpreting a message if:
    15·1 answer
  • You are creating a mobile version of a community discussion site for busy moms. Users post questions and other topics for discus
    10·1 answer
  • The int function can convert floating-point values to integers, and it performs rounding up/down as needed.
    11·1 answer
  • How communication skills are different from self management skills
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!