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

You are going to purchase (2) items from an online store.
If you spend $100 or more, you will get a 10% discount on your total purchase.
If you spend between $50 and $100, you will get a 5% discount on your total purchase.
If you spend less than $50, you will get no discount.
Givens:
Cost of First Item (in $)
Cost of Second Item (in $)
Result To Print Out:
"Your total purchase is $X." or "Your total purchase is $X, which includes your X% discount."

Answers

Answer:

Code:-

using System;

using System.Collections.Generic;

class MainClass {

public static void Main (string[] args) {

int Val1,Val2,total;

string input;

double overall;

Console.Write("Cost of First Item (in $)");

      input = Console.ReadLine();

Val1 = Convert.ToInt32(input);

Console.Write("Cost of Second Item (in $)");

      input = Console.ReadLine();

Val2 = Convert.ToInt32(input);

total=Val1+Val2;

if (total >= 100)

{

overall=.9*total;

Console.WriteLine("Your total purchase is $"+overall);

}

else if (total >= 50 & total < 100)

{

overall=.95*total;

Console.WriteLine("Your total purchase is $"+overall);

}  

else

{

Console.WriteLine("Your total purchase is $"+total);

}  

}

}

Output:

disadvantage of monolithic programming​

Answers

Answer:

=Tight coupling between components, as everything is in one application.

=Less reusability.

=Large code base; tough for developers and QA to understand the code and business knowledge.

=Less Scalable.

=Does not follow SRP (Single Responsibility Principle)

=More deployment and restart times.

7. Which control is used to display multiple records in List Form
a) Data Grid View b) Textbox c) Label d) Button

Answers

Answer:

I think a is correct answer.

Answer:

A

Explanation:

Explain how mobile phone production could be more sustainable​

Answers

Answer:

Sustainable design - the key features for sustainable phones are: use of sustainable and recycled materials, the use of less energy and efficient charging, durability, and last but not least they should be easy and inexpensive to repair.

Answer:

One of the best ways to change this is to voice your concern to cell phone manufacturers for more sustainable products. Request smartphones that are made with fewer hazardous chemicals, manufactured in plants powered by renewable energy, and that contain recycled materials.

Explanation:

Write and application that reads five integers from the user and determines and prints the largest and the smallest integers. Use only the programming techniques your learned in this chapter (use only if statements) 1.2. Modify your first program to add 2 more functions, the first function should determines the largest number and the second smallest. Both new functions must get invoked from the main function.

Answers

Answer:

#include <stdio.h>  

#include <limits.h>  

 

/* Define the number of times you are going  

  to ask the user for input. This allows you  

  to customize the program later and avoids the  

  hard coding of values in your code */  

#define NUMVALS 5  

 

int main(void)  

{  

   int i = 0;  

   int curval = 0;  

   /* Set your initial max as low as possible */  

   int maxval = INT_MIN;  

   /* Set your initial min as high as possible */  

   int minval = INT_MAX;  

 

   /* Loop through and ask the user for the defined  

      number of values */  

   for (i = 0; i < NUMVALS; i++)  

   {  

       /* Ask the user for the next value */  

       printf("Enter the next value: ");  

 

       /* Get the next value from the user */  

       scanf("%d", &curval);  

 

       /* Check to see if this is our biggest or  

          smallest value yet */  

       if (curval > maxval)maxval = curval;  

       if (curval < minval)minval = curval;  

   }  

 

   /* Output the results */  

   printf("The smallest value entered was: %d \n", minval);  

   printf("The largest value entered was: %d \n", maxval);  

 

   /* End the program */  

   return 0;  

}

Explanation:

cho dãy số a[] có n phần tử và dãy số b[]cõ m phần tử là các các số nguyên dương nhỏ hơn 1000 . Gọi tập hợp A là tập các số khác nhau trong a[], tập hợp B là các số khác nhau trong b[]

Answers

Answer:

please translate

Thank you✌️

How can the system administrator give the executive assistant the ability to view, edit, and transfer ownership of all records, but not allow her to delete the records

Answers

i don’t think that’s possible. giving control to edit records also means giving control to delete them. maybe discuss before hand to build trust and understanding or duplicate the records in case she does delete them

For the following scenario, indicate whether the action is a good practice or bad practice to safeguard your personally identifiable information.
Marina's personal computer requires a password to get access.

Answers

Answer:

This is most definitely a good practice to safeguard personal information. This way, people wouldn't be able to access her computer easily, since it requires a code that only she would know. of course, there is the possibility that someone can just guess or hack into her computer, but that's why computers usually have you create a unique code that consists of uppercases, lowercases, numbers, special characters, etc which would be difficult to guess. it's a good protection for anyone who wants to safely keep their personal information from everyone else.

The development of the modern computer system has been evolutionary. Discuss this phenomenon and further discuss how current trends in computing would impact future computer systems development.

Answers

Explanation:

With the great advances in computer systems today it is possible that we can connect and interact with people who are on the other side of the planet, we can study virtually without having to attend a university or school in person, we can even work from our own homes without having to travel to our workplace, which allows us to reduce transportation costs and time.

The above benefits have been possible thanks to the evolution of computer systems.But just as the evolution of computer systems brings great benefits, it also carries great risks for the future, in recent years there has been a considerable increase in cyber attacks, therefore it is necessary an advanced cybersecurity system that allows to quickly control and protect from external threats to organizations; As well as it is necessary to emphasize training in computer systems for people of all educational levels so that they are prepared and can give proper use to computer systems and thus also learn to protect themselves from cyber fraud.

Peter is a new business owner. Because Peter is on a strict budget, he uses an older Novell NetWare server. The NetWare server still relies on the legacy IPX/SPX network protocol suite. Peter needs to connect his server to the Internet. He decides to use a gateway instead of a router. What is the likely motive behind Peter's decision

Answers

The most likely motive of Peter's decision to use a gateway for connecting his serve to the internet is to get a wireless connection for the internet.

A gateway server is used to communicate to the internet service provider. It is used to receives the data. It helps to sends the data to the router in order to translate as well as distribute the wireless devices.

In the context, Peter who is on a strict budget uses gateway system to connect to the internet and he uses the older version of Novell NetWare server.

Learn More :

https://brainly.in/question/35731153

CONDUCT INTERVIEWS

Using your interview questions, interview at least three business professionals. Here are some useful tips for conducting the interviews:

Schedule an appointment for the interview for a time and place that is quiet and convenient.
Be on time and be prepared with paper and pen. You may also bring a recording device.
Be friendly and courteous; remember that the interviewee is giving you her valuable time!
Ask your questions clearly.
Don't interrupt!
Try to stay focused, but if something interesting comes up, go with it.
Take good notes. Ask the interviewee to repeat what she said if necessary, but only do this when it is something important.
Obtain all the information needed before ending the interview. If necessary, review your notes with the person.
Thank the interviewee for her time.
Write a description of the interviews in this text box.

Answers

Note that conducting a professional interview with business professionals is quite tasking and it does require skills and boldness,

Note that the questions that one need to ask are questions that are based on  the field of those business professionals, the company, your background, their dreams and aspirations and as such one should not be personal about it.

What are the  interview questions asked?

The interview questions prepared were:

Do they have the skills, expertise, and experience to carry out the job?.Are they happy and interested in current job and the current firm they are working with?.Can I fit into their team, organization culture, and firm?. etc.

Learn more about interview from

https://brainly.com/question/8846894

What is software? Why is it needed?​

Answers

Explanation:

Software is a data and information collection of computer.

It needs to protect computer from viruses.

I hope this helps you

what is 1 st genaration of computer ​

Answers

Explanation:

The period of first generation computer was from 1946-1959 AD .The computers of first generation used vacuum tubes as the basic components for memory and circuitry for CPU ( Central Processing Unit).These tubes, like electric bulbs, produced a lot of heat and were prone to frequent fusing of the installation.

Hope it helps...............

If i took my SIM card out of my phone and put it in a router then connect the router and my phone with Ethernet cable would the ping change???

Answers

Answer:

ummmmmmmmmmmmm nooooo???


Which of the following is not a data visualization technique?

Answers

Answer:

Normalization

Explanation:

From the options given :

Boxplot is a data visualization techniqye used for representing numerical data in the form of a box such that it adequately conveys the five number summary if the dataset which are the minimum, maximum, lower quartile, median and upper quartile, it also depicts the presence of outlines.

Scatter plot are used depict the relationship between two variables on the x and y axis of a graph. Each point is a representation of the (x, y) value pairs of the observation.

Tag clouds are usually used to represent word, metatdata and other free form text using different colors and font sizes to give information about the data.

Normalization is the odd option out as it is used to restructure data in other to promote integrity of data.

Many Java programs that you create will receive and process user input. In order to ensure that user input is accurate, you will need to use input validation and exception handling.

a. True
b. False

Answers

Answer: True

Explanation: True

Write a program to print all odd numbers between 20 and 50(Qbasic)​

Answers


Source Code:

total = 0

FOR x = 20 TO 50 STEP 2
total = total + x
NEXT x

PRINT "Total=";total

what is a computer memory

Answers

Answer:

it is your answer

Explanation:

it is the storage space where data is kept.

Select all steps in the list below that should be completed when using the problem-solving process discussed in this chapter.


Take action.

Take a break.

Evaluate.

Complete the task.

Consider solutions and list ideas.

Understand the task or need.

Ask a coworker for help.

Answers

Take action.

Evaluate.

Complete the task.

Consider solutions and list ideas.

Understand the task or need.

Genevieve is a student who attends classes at a campus downtown. She likes to study in the college's coffee shop, where she often accesses the Internet through the college's wireless network. Which network type is Genevieve using

Answers

Answer:

I'll let you make an educated guess off of this info! You always retain info better making an inference on a subject that you are having trouble with!

Explanation:

There are four types of wireless networks -- wireless local area networks, wireless metropolitan area networks, wireless personal area networks and wireless wide area networks -- each with its own function.

wireless local area network

A wireless local area network (WLAN) is a wireless distribution method for two or more devices. WLANs use high-frequency radio waves and often include an access point to the Internet. A WLAN allows users to move around the coverage area, often a home or small office, while maintaining a network connection.

wireless metropolitan area network

A metropolitan area network (MAN) is a computer network that connects computers within a metropolitan area, which could be a single large city, multiple cities and towns, or any given large area with multiple buildings. A MAN is larger than a local area network (LAN) but smaller than a wide area network (WAN).

wireless personal area network

A PAN provides data transmission among devices such as computers, smartphones, tablets and personal digital assistants. PANs can be used for communication among the personal devices themselves, or for connecting to a higher level network and the Internet where one master device takes up the role as gateway.

wireless wide area network

Wireless wide area network (WWAN), is a form of wireless network. ... WWAN connectivity allows a user with a laptop and a WWAN card to surf the web, check email, or connect to a virtual private network (VPN) from anywhere within the regional boundaries of cellular service.

I hope this helped!!

shania

The network type Genevieve uses is a wireless local area network.

What is a wireless local area network?

A wireless local area network (WLAN) exists as a wireless distribution procedure for two or more devices. WLANs utilize high-frequency radio waves and often contain an access issue to the Internet. A WLAN permits users to move around the coverage area, often a house or small office, while preserving a network connection.

Therefore, the correct answer is option (a) LAN.

Complete questions:

Genevieve is a student who attends classes at a campus downtown. She likes to study in the college's coffee shop, where she often accesses the Internet through the college's wireless network. Which network type is Genevieve using

(a) LAN

(b) MAN

(c) PAN

(d) WAN

To learn more about wireless local area networks refer to:

https://brainly.com/question/8985345

#SPJ2

Explain how communication has helped to the staff in organization to reach their maximum delivery of service with efficience and effectiveness ​

Answers

Answer:

i don't know

Explanation:

Write down the short history of COMPUTER? ​

Answers

Answer:

Charles Babbage, an English mechanical engineer and polymath, originated the concept of a programmable computer. Considered the "father of the computer",he conceptualized and invented the first mechanical computer in the early 19th century.

(viii) Word does not allow you to customize margins.
true/false:-​

Answers

In Word, each page automatically has a one-inch margin. You can customize or choose predefined margin settings, set margins for facing pages, allow extra margin space to allow for document binding, and change how margins are measured.

I would say false

Suppose a program written in language L1 must be executed on a machine running a program running in language L0. What important operation must take place

Answers

Question Completion with Options:

a. Translation of the entire L1 program into L0 code

b. Translation of the L0 program into L1 code

c. Creation of a language L3 that interprets L0 instructions

d. Interpretation of each L1 statement using L0 code as the L1 program is running.

Answer:

The important operations that must take place in this scenario are:

a. Translation of the entire L1 program into L0 code

d. Interpretation of each L1 statement using L0 code as the L1 program is running.

Explanation:

Translation enables decoding to take place.  This means that the L1 program is decoded into a language that the L0 program can understand and execute.  Without this translation, the higher level language of L1 will not be understood by the machine language of the L0 programs.  Translation of a code creates a shared understanding, thereby easing program execution.  Code translation is simultaneously accompanied by interpretation.

A light rag is striking the surface of earth. Which factor would make the light ray more likely to be absorbed than reflected?

Answers

Answer:

The answer is D.

Explanation:

because the other answers doesn't make sense.

How do i connect WiFi on windows xp without icon?

Answers

Right click anywhere on your taskbar, and then click Properties. Step 2: Find and click the Notification Area tab on the top bar, and then find the section labeled with System icons, check the checkbox for Network. Last, click OK to finish it.

Answer:

Right click anywhere on your taskbar, and then click Properties. Step 2: Find and click the Notification Area tab on the top bar, and then find the section labeled with System icons, check the checkbox for Network. Last, click OK to finish it.

Draw AND, OR, XOR and XNOR gates with truth table and logic gates.

.​

Answers

Answer:

see picture. let me know if you have questions.

Shawn's supervisor has tasked him with determining how the company can increase the security of its Wi-Fi. Shawn plans to present several options to his supervisor and ask her to check his work. Which of the following is not a strong security method? (Select TWO.)
a. Disabling SSID
b. WPS
c. MAC filtering
d. Setting encryption

Answers

Answer:

The not strong security methods are:

a. Disabling SSID

b. WPS

Explanation:

When you disable SSID, you only make your Wi-Fi secure for the less determined attackers.  By disabling the SSID (network name), those who are less technically inclined are prevented from connecting to the network but, this will not deter a more determined and technically savvy adversary.  The best two options are MAC filtering and setting encryption.  WPS (Wi-Fi Protected Setup) enables the process of connecting to a secure wireless network from a computer or other device easier instead of making it harder.

Write a program get_price.py with a function get_price() that takes a dictionary of fruits as an argument and returns the name of the most expensive fruit. Each item of the dictionary includes: A key: the name of the fruit A value: the price of the fruit.

Answers

Answer:

The program is as follows:

def get_price(fruits):

   AllPrice = fruits.values()

   value_iterator = iter(AllPrice)

   mostExpensive = next(value_iterator)  

   for item in fruits:

       if fruits[item]>=mostExpensive:

           mostExpensive = fruits[item]

           fruitName = item

   print(fruitName)

fruits = {}

n = int(input("Number of Fruits: "))

for i in range(n):

   name = input("Fruit name: ")

   price = int(input("Fruit price: "))

   fruits[name] = price

get_price(fruits)

Explanation:

This defines the get_price function

def get_price(fruits):

This gets all price in the dictionary fruit

   AllPrice = fruits.values()

This passes the values to a value iterator

   value_iterator = iter(AllPrice)

This initializes mostExpensive to the first price in the dictionary

   mostExpensive = next(value_iterator)

This iterates through the elements of the dictionary  

   for item in fruits:

If current element is greater than or equals most expensive

       if fruits[item]>=mostExpensive:

Set most expensive to the current element

           mostExpensive = fruits[item]

Get the corresponding fruit name

           fruitName = item

Print fruit name

   print(fruitName)

The main begins here

This initializes the fruit dictionary

fruits = {}

This gets input for the number of fruits

n = int(input("Number of Fruits: "))

This is repeated for every inputs

for i in range(n):

Get fruit name

   name = input("Fruit name: ")

Get fruit price

   price = int(input("Fruit price: "))

Append name and price to dictionary

   fruits[name] = price

Call the get_price function

get_price(fruits)

Help Pls
I need about 5 advantages of E-learning​

Answers

Answer:

Explanation:

E-learning saves time and money. With online learning, your learners can access content anywhere and anytime. ...

E-learning leads to better retention. ...

E-learning is consistent. ...

E-learning is scalable. ...

E-learning offers personalization.

Answer:

E- learning saves time and money

E-learning makes work easier and faster

E- learning is convenient

E- learning is consistent

E- learning is scalable

Explanation:

when you learn using the internet, you save a lot of time by just typing and not searching through books

Other Questions
Which number line model represents the expression 5/2 + 3 conclusion de la Moral Companies can use a spreadsheet to complete the statement of cash flows. Each item that follows is recorded in the transaction analysis columns of the spreadsheet. Net incomeIncreases in current assets (other than Cash)Decreases in current liabilitiesCash payment for the acquisition of plant assetsCash receipt from the issuance of common stockDepreciation expenseIdentify each as being recorded by a Debit or Credit in the statement of cash flows section of the spreadsheet. Find the measure of the missing angle using the exterior angle sum theorm. What is the simplest form of 0.0115 You are to receive the following payments at the end of the following periods: Year 1 : $250 Year 2: $300 Year 3: $450The interest rate is 15% per year.Required:What is the future value of these cash flows 20 years from now? Blocks A and B each have a mass m. Determine the largest horizontal force P which can be applied to B so that A will not move relative to B. All surfaces are smooth. Mark purchashed 3 giant jawbreakers at 75cents each.he also bought 1/4 pound of hot tamales.which sell for $2.76 a pound.he gave the clerk a $5 bill.how much change did mark recieve? Whith his change,mark decided to buy 1/2 pound of m&ms at $3.24 a pound.how much money does mark have left? Stan wants to invest in real property. Rather than be a sole owner, Stan would prefer to pool his resources with other people to own and develop a small office building. He would prefer not to take part in the day-to-day responsibilities of the organization. What type of business venture would best fit his goals? Plateau Indian tribal leaders were chosen based onhereditary rules.likability.merit.social status. Is 8 a solution to the equation 3x = 16 5x? How do you know? If the government of Mexico decides to spend less on the military and more on health care, the foregone spending on military items represents the: Which of the following is an arithmetic sequence? The weight gain of beef steers were measured over a 140 day test period. the average daily gains (lb/day) of 10 steers on the same diet were as follows. The tenth steer had a weight gain of 4.02 lb/day. 3.89 3.51 3.97 3.31 3.21 3.36 3.67 3.24 3.27determine the mean and median. Express the unit of force in terms of fundamental unit Barry and Robin walk to Dunkin' Donuts each Saturday to meet for coffee and donuts. Barry walks the 2 miles from his house in 30 minutes and Robin walks the 3 miles from his house in 36 minutes. Find the unit rate in minutes per mile for Barry. Find the unit rate in minutes per mile for Robin. Who walks faster, Barry or Robin Choose the correct statement about growth in labor productivity. A. Potential GDP per hour of labor increases. B. The real wage rate falls and the equilibrium quantity of labor increases. C. Potential GDP remains unchanged. D. The demand for labor increases, the production function does not change, but a movement occurs along the production function. The area of a rectangle is (4x2 49y2) square units. Determine the dimensions of the rectangle by factoring the area expression completely. Slope intercept 6times+5y=15 If a speaker were preparing a speech for the city council, what style should he or she aim for?