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
juin [17]
3 years ago
8

An array is sorted (in ascending order) if each element of the array is less than or equal to the next element .

Computers and Technology
1 answer:
Aleks04 [339]3 years ago
8 0

Answer:

// The program below checks if an array is sorted or not

// Program is written in C++ Programming Language.

// Comments are used for explanatory purpose

//Program Starts here

#include<iostream>

using namespace std;

//Function to check if the array is sorted starts here

int isSorted(int arr[], int count)

{

// Check if arrays has one or no elements

if (count == 1 || count == 0) {

return 1;

}

else

{

// Check first two elements

if(arr[0] >= arr[1])

{

return 0; // Not sorted

}

else

{ // Check other elements

int check = 0;

for(int I = 1; I<count; I++){

if (arr[I-1] > arr[I]) { // Equal number are allowed

check++; // Not sorted

}

}

}

if(check==0)

return isSorted(arr, count - 1); //Sorted

else

return 0; // Not sorted

}

// Main Method starts here

int main()

{

int count;

cin<<count;

int arr[count];

for(int I = 1; I<=count; I++)

{

cin>>arr[I-1];

}

int n = sizeof(arr) / sizeof(arr[0]);

if (isSorted(arr, n))

cout << "Array is sorted";

else

cout << "Array is not sorted";

}

You might be interested in
...............is a personal computer that fits on desk.​
vesna_86 [32]

Answer:

desktop computer

Explanation:

8 0
3 years ago
Read 2 more answers
Please help! first one to answer correctly gets brainliest and thanked
jonny [76]
It’s either presentation Because the software is used to create a sequence of texting, graphics and often audio and video to accompany a speech or a public presentation, or letter
6 0
3 years ago
Defeating authentication follows the method–opportunity–motive paradigm.
sashaice [31]

Answer:

Method:- This is related to hackers technique and way of accessing to copy other data. It also includes the skill, knowledge, tools and other things with which to be able to pull off the attack.

Opportunity:- this is related to how a user gives way to access to the hackers. It includes the time, the chance, and access to accomplish the attack.

Motive:- This may relate to the hacker to destroy the reputation of another or for money. It is reason to want to perform this attack against this system

3 0
2 years ago
A good algorithm should have which three components?
laila [671]

Answer:

a good algorithm must be able to accept a set of defined input. Output: a good algorithm should be able to produce results as output, preferably solutions. Finiteness: the algorithm should have a stop after a certain number of instructions. Generality: the algorithm must apply to a set of defined inputs.Explanation:

7 0
2 years ago
The __________ algorithm takes the ciphertext and the secret key and produces the original plaintext
Bad White [126]
The answer is decryption
8 0
2 years ago
Other questions:
  • ​PeroxyChem's IT staff was able to free its IT staff to spend less time on routine maintenance and more time on strategic tasks
    11·1 answer
  • You work in the Accounting Department and have been using a network drive to post Excel workbook files to your file server as yo
    9·1 answer
  • Edhesive coding practice 3.4​
    12·1 answer
  • What is the value of variable num after the following code segment is executed?
    5·1 answer
  • Your bluetooth headset is waiting for another bluetooth device to locate its signal. what is this mode known as?'
    8·1 answer
  • Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable with the value 0
    9·1 answer
  • 1. Software that is designed to intentionally cause harm to a device, server, or network is A. outware B.loggerware C.
    12·1 answer
  • You decide to test an audio clip that you have inserted into your presentation, but before you do that you make sure that the co
    6·1 answer
  • Widow in respect to word processing ​
    15·1 answer
  • Bob has started a company and registered its name with the government as a private corporation. He tries to create a domain name
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!