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.

Answers

Answer 1

Answer:

The function in C++ is as follows:

int isSorted(int ar[], int n){

if ([tex]n == 1[/tex] || [tex]n == 0[/tex]){

 return 1;}

if ([tex]ar[n - 1][/tex] < [tex]ar[n - 2][/tex]){

 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 ([tex]n == 1[/tex] || [tex]n == 0[/tex]){

 return 1;}

This checks if the current element is less than the previous array element; If yes, the array is not sorted

if ([tex]ar[n - 1][/tex] < [tex]ar[n - 2][/tex]){

 return 0;}

This calls the function, recursively

return isSorted(ar, n - 1);

}


Related Questions

fill in the blanks Pasaline could ----- and ------- very easily.​

Answers

Answer:

Hot you too friend's house and be safe and have a great time to take care of the following is not a characteristic it was a circle whose equation o

Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a comma, including the last one.Ex: If the input is:5 2 4 6 8 10the output is:10,8,6,4,2,To achieve the above, first read the integers into a vector. Then output the vector in reverse.

Answers

Answer:

The program in C++ is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

   vector<int> intVect;

   int n;

   cin>>n;

int intInp;

for (int i = 0; i < n; i++) {

 cin >> intInp;

 intVect.push_back(intInp); }

for (int i = n-1; i >=0; i--) {  cout << intVect[i] << " "; }

 return 0;

}

Explanation:

This declares the vector

   vector<int> intVect;

This declares n as integer; which represents the number of inputs

   int n;

This gets input for n

   cin>>n;

This declares intInp as integer; it is used to get input to the vector

int intInp;

This iterates from 0 to n-1

for (int i = 0; i < n; i++) {

This gets each input

 cin >> intInp;

This passes the input to the vector

 intVect.push_back(intInp); }

This iterates from n - 1 to 0; i.e. in reverse and printe the vector elements in reverse

for (int i = n-1; i >=0; i--) {  cout << intVect[i] << " "; }

Select the correct statement(s) regarding 4B5B encoding.
a. 4B5B is used to map four codeword bits into a five bit data word
b. 4B5B information bit rate is 80% of the total (information plus overhead) bit rate
c. 4B5B information bit rate is 20% of the total (information plus overhead) bit rate
d. all statements are correct

Answers

Answer:

b. 4B5B information bit rate is 80% of the total information plus overhead bit rate.

Explanation:

4B5B bit rate encoding means there is 80% of the bit rate which included all the information plus the overheads. There is 20% of lack in bit rate due to encoding code words which converts data into smaller bits.

????????????????????????? ???????????????

Answers

Answer:

sorry, I don't know what that is

A retail department store is approximately square, 35 meters (100 feet) on each side. Each wall has two entrances equally spaced apart. Located at each entrance is a point-of-sale cash register. Suggest a local area network solution that interconnects all eight cash registers. Draw a diagram showing the room, the location of all cash registers, the wiring, the switches, and the server. What type of wiring would you suggest?

Answers

Answer:

The use of twisted pair cable ( category 5e/6 ) to connect the computers on each register and also the use of switches to connect each register to the server

Explanation:

The local area network ( LAN ) solution  that will be used to interconnect all the POS  registers is ; The use of twisted pair cable ( category 5e/6 ) to connect the computers on each register and also the use of switches to connect each register to the server .  

This is because category 5e/6 twisted pair cable has a data rate transfer of up to 10 Mbps and it is best used for LAN connections

while The function of the three switches is to connect each cash register to the the central server been used .

attached below is a schematic representation

hub stake should always be provided with a lath stake so that the information about what the hub represents can be written on the lath stake True False

Answers

Answer:

True

Explanation:

To protect them from becoming disturbed by construction operations, hub stakes are placed on both sides of a roadway at a certain distance outside the work zone. The final stakes are connected to the hub stakes, which are used to write the essential information.

As a result, hub stakes are always accompanied with stakes.

Being the Sales Manager of a company you have to hire more salesperson for the company to expand the sales territory. Kindly suggest an effective Recruitment and Selection Process to HR by explaining the all the stages in detail.

Answers

Answer:

In order to sales company to expand the sales territory in heeds to target those candidates that have long exposure in sales profile.

Explanation:

Going for a sales interview for the profile of a sales manager in a company. The HR department may require you to answer some questions. Such as what do you like most about sales, how to you motivate your team and how much experience do you have. What are philosophies for making sales Thus first round is of initial screening, reference checking, in-depth interview, employ testing, follow up, and making the selection. This helps to eliminate the undesired candidates.

how many copies of each static variable and each class variable are created when 10 instances of the same class are created

Answers

Answer:

Static variables are initialized only once

Explanation:

Only one copy of static variables are created when 10 objects are created of a class

A static variable is common to all instances of a class because it is a class level variable

What are the LinkedIn automation tools you are using?

Answers

Answer:

Well, for me I personally use LinkedCamap to drive more LinkedIn connections, hundreds of leads, sales, and conversions automatically.

Some other LinkedIn automation tools are;

ExpandiMeet AlfredPhantombusterWeConnectLinkedIn Helper

Hope this helps!

let's have a class named Distance having two private data members such as feet(integer), inches(float), one input function to input values to the data members, one Display function to show the distance. The distance 5 feet and 6.4 inches should be displayed as 5’- 6.4”. Then add the two objects of Distance class and then display the result (the + operator should be overloaded). You should also take care of inches if it's more than 12 then the inches should be decremented by 12 and feet to be incremented by 1.

Answers

Answer:

Humildade

Ser justo (Fair Play)

Vencer independente

We have removed
A
balls from a box that contained
N
balls and then put
B
new balls into that box. How many balls does the box contain now?
Constraints
All values in input are integers.
Input
Input is given from Standard Input in the following format: n a b
Output
Print the answer as an integer.

Answers

There were [tex]N[/tex] balls but we took [tex]A[/tex] balls out, so there are now [tex]N-A[/tex] balls. We add [tex]B[/tex] balls and now we have [tex]N-A+B[/tex] balls.

The program that computes this (I will use python as language has not been specified is the following):

n, a, b = int(input()), int(input()), int(input())

print(f"There are {n-a+b} balls in the box")

# Hope this helps

Write a program that removes all non-alpha characters from the given input. Ex: If the input is: -Hello, 1 world$! the output is: Helloworld

Also, this needs to be answered by 11:59 tonight.

Answers

Answer:

Explanation:

The following code is written in Python. It is a function that takes in a string as a parameter, loops through the string and checks if each character is an alpha char. If it is, then it adds it to an output variable and when it is done looping it prints the output variable. A test case has been provided and the output can be seen in the attached image below.

def checkLetters(str):

   output = ''

   for char in str:

       if char.isalpha() == True:

           output += char

   return output

How can an Outlook user search for contacts? Check all that apply.

the Search bar located above the list of contacts
the Search People bar on the Find command group
the Search People located on the People navigation icon
CTL + E to activate the search contacts box
advanced Find under the Search tab
the options menu in the backstage view

Answers

Answer: the Search bar located above the list of contacts.

the Search People bar on the Find command group.

the Search People located on the People navigation icon.

CTL + E to activate the search contacts box.

advanced Find under the Search tab.

Explanation:

An Outlook user can search for contacts through the following ways:

• the Search bar located above the list of contacts.

• the Search People bar on the Find command group.

• the Search People located on the People navigation icon.

• CTL + E to activate the search contacts box.

• advanced Find under the Search tab.

Therefore, the correct options are A, B, C, D and E.

Draw a Card. Write a program to simulate drawing a card. Your program will randomly select one card from a deck of 52 playing cards. Your program should display the rank (Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King) and suit (Clubs, Diamonds, Hearts, Spades) of the card. Here is a sample run of the program: in The card you picked is Jack of Heart The program should use at a minimum: sequence, selection, arrays, and random numbers.

Answers

Answer:

Explanation:

The following code is written in Java. It is a function that creates a Random object to generate random values, then uses those values to choose a random rank and suit using switch statements. It then saves the rank and suit into a String variable in the correct format and finally prints the card that was picked to the screen. The function was called 4 times in the main method and the output can be seen in the attached image below.

public static void randomCardGenerator() {

       Random rand = new Random();

       int rank = rand.nextInt(14)+1;

       int suit = rand.nextInt(4)+1;

       String chosenCard = "";

       switch (rank) {

           case 1: chosenCard += "Ace"; break;

           case 2: chosenCard += "1"; break;

           case 3: chosenCard += "2"; break;

           case 4: chosenCard += "3"; break;

           case 5: chosenCard += "4"; break;

           case 6: chosenCard += "5"; break;

           case 7: chosenCard += "6"; break;

           case 8: chosenCard += "7"; break;

           case 9: chosenCard += "8"; break;

           case 10: chosenCard += "9"; break;

           case 11: chosenCard += "10"; break;

           case 12: chosenCard += "Jack"; break;

           case 13: chosenCard += "Queen"; break;

           case 14: chosenCard += "Kind"; break;

           default: System.out.println("Wrong Value");

       }

       chosenCard += " of ";

       switch (suit) {

           case 1: chosenCard += "Clubs"; break;

           case 2: chosenCard += "Diamonds"; break;

           case 3: chosenCard += "Hearts"; break;

           case 4: chosenCard += "Spades"; break;

           default: System.out.println("Invalid Suit");

       }

       System.out.println(chosenCard);

   }

how much is this worth in dollars​

Answers

Answer:

This is worth 50 dollars.

Explanation:

١ - one

٢ - two

٣ - three

٤ - four

٥ - five

٦ - six

٧ - seven

٨ - eight

٩ - nine

٠ - zero

What you see above is the ten digits in Arabic.

Both 5 (٥) and 0 (٠) appear here, thus representing 50.

command create database in oracle database ::((

Answers

Answer:

kdkskskiisidiodoosooddodod

Write a program that uses a stack to test input strings to determine whether they are palindromes. A palindrome is a sequence of characters that reads the same as the sequence in reverse; for example, noon.

Answers

Answer:

Here the code is given as follows,

Explanation:

def isPalindrome(x):

   stack = []

   #for strings with even length

   if len(x)%2==0:

       for i in range(0,len(x)):

           if i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True

   #for strings with odd length    

   else:

       for i in range(0,len(x)):

           if i==int(len(x)/2):

               continue

           elif i<int(len(x)/2):

               stack.append(x[i])

           elif stack.pop()!=x[i]:

               return False

       if len(stack)>0:

           return false

       return True  

def main():  

   while True:  

       string = input("Enter a string or Return to quit: ")  

       if string == "":  

           break  

       elif isPalindrome(string):  

           print("It's a palindrome")  

       else:  

           print("It's not a palindrome")  

if __name__ == '__main__':  

   main()

If you fail a course as a MAIN (residency) course, you can repeat that course as either a MAIN (residency) or an online (IG or IIG) course.
A. True
B. False

Answers

it depends on where you are taking your courses. In most cases the answer would be true

Write a java program that reads a list of integers and outputs those integers in reverse. The input begins with an integer indicating the number of integers that follow. For coding simplicity, follow each output integer by a comma, including the last one. Assume that the list will always contain fewer than 20 integers.


Ex: If the input is:


5 2 4 6 8 10

the output is:


10,8,6,4,2,

To achieve the above, first read the integers into an array. Then output the array in reverse.

Answers

Answer:

Explanation:

using namespace std;

#include <iostream>

int Go()

{

 

int N;

int A[20];

 

 

cout << " How many integers do you have ??? :>";

cin >> N;

if (N>20) { N=20; }

 

for (int iLoop=0; iLoop<N; iLoop++)

{

 

 cout << "Input integer # " << (iLoop+1) << " :>";  

  cin >> A[iLoop];  

 

}

 

for (int iLoop=N-1; iLoop>=0; iLoop--)

{

 cout << A[iLoop] << " ";

}

cout << endl;

 

 

}

int main()

{

Go();

}

A Java program that reads a list of integers and outputs them in reverse is written as,

import java.util.Scanner;

public class ReverseList {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       

       // Read the number of integers

       int numIntegers = scnr.nextInt();

       

       // Create an array to store the integers

       int[] integers = new int[numIntegers];

       

       // Read the integers into the array

       for (int i = 0; i < numIntegers; i++) {

           integers[i] = scnr.nextInt();

       }

       

       // Output the integers in reverse order

       for (int i = numIntegers - 1; i >= 0; i--) {

           System.out.print(integers[i]);

           

           // Add comma unless it's the last integer

           if (i > 0) {

               System.out.print(",");

           }

       }

       

       System.out.println(); // Add a new line at the end

   }

}

Given that,

Write a Java program that reads a list of integers and outputs those integers in reverse.

Here, The input begins with an integer indicating the number of integers that follow.

For coding simplicity, follow each output integer by a comma, including the last one.

So, A Java program that reads a list of integers and outputs them in reverse:

import java.util.Scanner;

public class ReverseList {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       

       // Read the number of integers

       int numIntegers = scnr.nextInt();

       

       // Create an array to store the integers

       int[] integers = new int[numIntegers];

       

       // Read the integers into the array

       for (int i = 0; i < numIntegers; i++) {

           integers[i] = scnr.nextInt();

       }

       

       // Output the integers in reverse order

       for (int i = numIntegers - 1; i >= 0; i--) {

           System.out.print(integers[i]);

           

           // Add comma unless it's the last integer

           if (i > 0) {

               System.out.print(",");

           }

       }

       

       System.out.println(); // Add a new line at the end

   }

}

Read more about java programming language at:

brainly.com/question/2266606

#SPJ4

If the signal is going through a 2 MHz Bandwidth Channel, what will be the maximum bit rate that can be achieved in this channel? What will be the appropriate signal level?

Answers

Answer:

caca

Explanation:

Fill in multiple blanks for [x], [y], [z]. Consider a given TCP connection between host A and host B. Host B has received all from A all bytes up to and including byte number 2000. Suppose host A then sends three segments to host B back-to-back. The first, second and third segments contain 50, 600 and 100 bytes of user data respectively. In the first segment, the sequence number is 2001, the source port number is 80, and the destination port number is 12000. If the first segment, then third segment, then second segment arrive at host B in that order, consider the acknowledgment sent by B in response to receiving the third segment. What is the acknowledgement number [x], source port number [y] and destination port number [z] of that acknowledgement

Answers

b _ i did this already

When rating ads, I should only consider my personal feelings on the ad.

Answers

Answer:

yes when rating ads you should only consider your personal feelings on the ad

Computer data that is suitable for text​

Answers

Answer:

Answer:Data Types. Computer systems work with different types of digital data. In the early days of computing, data consisted primarily of text and ...

In confirmatory visualization Group of answer choices Users expect to see a certain pattern in the data Users confirm the quality of data visualization Users don't know what they are looking for Users typically look for anomaly in the data

Answers

Answer: Users expect to see a certain pattern in the data

Explanation:

Confirmatory Data Analysis occurs when the evidence is being evaluated through the use of traditional statistical tools like confidence, significance, and inference.

In this case, there's an hypothesis and the aim is to determine if the hypothesis is true. In this case, we want to know if a particular pattern on the data visualization conforms to what we have.

How many ways are there to arrange the letters in the word ALGORITHMS? Note, the letter arrangement does not have to spell a word in the dictionary, but the new word must contain all the letters and each letter can be used only once.

Answers

there are ten letters in the word, so for the first position we can choose out of 10 option.

no matter wich specific option we choose, we will have 9 letters left for the 2nd letter.

and 8 for the third place.

...

when we will have used up 9 of 10 letters, there will be only one option for the last place.

the number of possible decision-paths is therefore given by this expression:

10*9*8*7*6*5*4*3*2*1

wich is 3,628,800

there are quite a few ways to rearrange 10 letters

The sorting method which commands entries in a going to head predicated on each character without regard to space as well as punctuation, therefore there are 3628800 ways.

The word 'ALGORITHMS' has 10 letters. There is no repeated letter so, the first Letter can hold 10 places if we start taking one letter at a time. The second can then hold nine positions, the third can hold eight, and so on.

So, as [tex]\bold{ 10\times 9 \times 8.... \times 3 \times 2 \times 1 = 362,8800}[/tex] ways, we have such a total number of ways.

Learn more:

brainly.com/question/17276660

The computer that is used in scientific research is ........​

Answers

Answer:

supercomputers are the computer that is used in scientific research.

Answer:

super computer is the right answer

the id selector uses the id attribute of an html element to select a specific element give Example ?​

Answers

Answer:

The id selector selects a particular html element

Explanation:

The id selector is uses the id attribute to select a specific html element. For example, if we have a particular header which is an html element and we want to give it a particular background color, we use the id selector and give it an id attribute in the CSS file. An example of an html header with id = 'blue' is shown below. The style sheet is an internal style sheet.

!doctype html

<html>

<head>

<title>Test</title>

<style>

#blue { background-color: blue;

}

</style>

</head>

<body>

<h1 id = 'blue'>Our holiday</h1>

<p>This is the weekend</p>

</body>

</html>

What order? (function templates) Define a generic function called CheckOrder() that checks if four items are in ascending, neither, or descending order. The function should return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order. The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, strings, characters, or doubles. Ex. If the input is:

Answers

Answer:

Explanation:

The following code was written in Java and creates the generic class to allow you to compare any type of data structure. Three different test cases were used using both integers and strings. The first is an ascending list of integers, the second is a descending list of integers, and the third is an unordered list of strings. The output can be seen in the attached image below.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Order: " + checkOrder(10, 22, 51, 53));

       System.out.println("Order: " + checkOrder(55, 44, 33, 22));

       System.out.println("Order: " + checkOrder("John", " Gabriel", "Daniela", "Zendaya"));

   }

   public static <E extends Comparable<E>> int checkOrder(E var1, E var2, E var3, E var4) {

       E prevVar = var1;

       if (var2.compareTo(prevVar) > 0) {

           prevVar = var2;

       } else {

           if (var3.compareTo(prevVar) < 0) {

               prevVar = var3;

           } else {

               return 0;

           }

           if (var4.compareTo(prevVar) < 0) {

               return 1;

           }  else {

               return 0;

           }

       }

       if (var3.compareTo(prevVar) > 0) {

           prevVar = var3;

       }

       if (var4.compareTo(prevVar) > 0) {

           return -1;

       }

       return 0;

   }

}

What type of device is a computer? Where does it use​

Answers

Answer:A computer is an electronic device that manipulates information, or data. It has the ability to store, retrieve, and process data. You may already know that you can use a computer to type documents, send email, play games, and browse the Web.

Preserving confidentiality, integrity, and availability is a restatement of the concern over interruption, interception, modification, and fabrication.
i. Briefly explain the 4 attacks: interruption, interception, modification, and fabrication.
ii. How do the first three security concepts relate to these four attacks

Answers

Answer and Explanation:

I and II answered

Interruption: interruption occurs when network is tampered with or communication between systems in a network is obstructed for illegitimate purposes.

Interception: interception occurs when data sent between systems is intercepted such that the message sent to another system is seen by an unauthorized user before it reaches destination. Interception violates confidentiality of a message.

Modification: modification occurs when data sent from a system to another system on the network is altered by an authorized user before it reaches it's destination. Modification attacks violate integrity, confidentiality and authenticity of a message.

Fabrication: fabrication occurs when an unauthorized user poses as a valid user and sends a fake message to a system in the network. Fabrication violates confidentiality, integrity and authenticity.

Other Questions
I want my answer please help hello can u help me plz i need a essay for louis vuittonplz help asapessay with 150-200 words the cost of 7 shirts is $63. find the cost of 5 shirts1. $352. $453. $524. $70 a man invested 800.00in a bank at a simple interest rate of 5% per annum .Find his total amou year PLEASE HELP! Use the graph to solve the system of equations. A. (-5,0)B. (0,5)C. (0,0)D. (2,3) What are the domain and range of the function represented by the set ofordered pairs?{(-16, 0), (-8, -11), (0, 12), (12,4)} The nurse provides dietary instructions to a client with diabetes mellitus regarding the prescribed diet. Which statement if made by the client indicates a need fir further teaching one main responsibilities of the judicial branch Select the correct statement(s) regarding 4B5B encoding. a. 4B5B is used to map four codeword bits into a five bit data word b. 4B5B information bit rate is 80% of the total (information plus overhead) bit rate c. 4B5B information bit rate is 20% of the total (information plus overhead) bit rate d. all statements are correct what events weakened the last dynasty of china? don't answer this unless your brainly name is xXtherealXx How did the leaders of early labor unions differ from industrialistentrepreneurs in their views on the U.S. economy?O A. Labor union leaders argued that the police and U.S. military shouldintervene in strikes and other aspects of labor negotiations.O B. Labor union leaders were more committed to promoting the idealsof social Darwinism in American factories.C. Labor union leaders were more interested in maintainingtraditional elements of American capitalism.O D. Labor union leaders believed that even low-level employees shouldhave some influence over their wages and conditions. The transformation from the function (x) = 3x to the function (x) = 3x + 4 indicates: a. A breakdown of U.S. household garbage reveals the largest amount percentage-wise is paper and paperboard. b. In U.S. households most of the water usage is in the bathroom. c. The founder of the modern environmental movement and author of Silent Spring is Rachel Carson d. Deciduous trees such as most pines do not lose their leaves/foliage in winter. Ronald brought a jacket on Friday that had original price if $45. It was on sale at 10% off its original price. Which formula shows what Ronald paid after 7% sales tax was added?A. 1.07(45-10)B. 1.03(45)C. 1.07(45-45(.1))D. 1.1(45-45(.7)) Which kind of scientist works with fossilized human bone?archaeologistanthropologisthistorianpaleontologist With respect to the debate over the process of language development, nature is to nurture as ________ is to ________. A 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is that of the middle element in the middle row. Which of the following is the minimum value of the equation y = 2x2 + 5?5052 The _____ characteristic of a sophisticated intelligent agent demonstrates its ability to interact with users in a more natural language.