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
A pangram is a sentence that contains all the letters of the English alphabet at least once. For example, the quick brown fox ju
erma4kov [3.2K]
Do you want this in paragraph form ?
5 0
3 years ago
How do you change a LAN (local area network) to a WAN (wide-area network)
ahrayia [7]

Answer:

Go to internet, click use as LAN under the cable section and click yes to confirm

4 0
2 years ago
Three PCs are on an Ethernet LAN, connected by a hub. Describe how the Ethernet protocol deals with collisions in this situation
sdas [7]

Answer:

All the ports in a hub are in the same collision domain and a hub sends frames from one host to all other hosts in the network. This makes it prone to collision and poor network throughput. Just like a network switch, it uses the CSMA/CD protocol to detect collision in its network.

A network switch reduces its collision domain to just a port and sends frames from one host to another using its mac table as a route. This makes the network very efficient with high throughput. It also uses the CSMA/CD protocol to detect collision

Explanation:

Switches and hubs are used in networking to connect computer devices in a network. A hub is an obsolete device networking that broadcast a frame to all other ports or host in the network except for the send host port. This increases the rate of collision as all the ports in a hub share the same collision domain. A switch is an efficient frame switching device in a network, which uses its MAC table to decide and find a destination host.

CSMA/CD is a collision detection protocol used in a network to detect and prevent a collision. With this protocol, a host is able to listen, wait, send and resend frames to prevent a collision.

3 0
3 years ago
Qual parâmetro é usado é usado na query sql para a presentar os dados em ordem decrescente?Leitura Avançada
nikitadnepr [17]

Answer:

gg

Explanation:

gg

4 0
3 years ago
pen the PT Activity. Perform the tasks in the activity instructions and then answer the question. Which event will take place if
zysi [14]

Answer:

Packets with unknown source addresses will be dropped.

Explanation:

This question is incomplete, we must add the number "1" in Fa0/1.

Which event will take place if there is a port security violation on switch S1 interface Fa0/1?

There are four options:

- A notification is sent.

- A syslog message is logged.

-The interface will go into error-disabled state.

- Packets with unknown source addresses will be dropped.

In this specific example, we have configured a security protection mode, if there is an unknown MAC address,  every package will be dropped.

We can configure in our switch with different Mac address, if there is not a MAC address in our configuration, the security mode will active, and we could receive any package.

5 0
3 years ago
Other questions:
  • g Write a program to sort an array of 100,000 random elements using quicksort as follows: Sort the arrays using pivot as the mid
    7·1 answer
  • You work for a large company. You need to implement a backup solution for your company that will allow you to perform multiple b
    11·1 answer
  • Is anyone really good at immerse 2 learn??
    9·1 answer
  • Boardman College maintains two files—one for Sociology majors and another for Anthropology majors. Each file contains students'
    5·1 answer
  • Which of the following OSI layers is responsible for the segmentation, multiplexing, flow control and host-to-host communication
    6·1 answer
  • HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HEL
    15·2 answers
  • Sally has 4 quarters, 2 dimes, 6 nickels, and 10 pennies.
    13·2 answers
  • Dose anyone know how to change username, grade level, and gender here? I have tried it in the change preferences and it says it
    8·2 answers
  • What is your impression on the subject fundamentals of database systems?​
    7·1 answer
  • Which of the following statements about interpreting colors are true? Select 3 options.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!