Given an array of n distinct integers sorted in ascending order, write a function that returns a Fixed Point in the array, if there is any Fixed Point present in array, else returns -1. Fixed Point in an array is an index i such that arr[i] is equal to i. Note that integers in array can be negative. Examples: #include using namespace std; void removeDivByFive(int *arr,int& size) { int index=0; for(int i=0;i

Answers

Answer 1

Answer:

The function is as follows:

int returnsFixed(int arr [],int n){

   int retVal = -1;

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

       if(i == arr[i]){

           retVal = i;

           break;

       }

   }

   return retVal;

}

Explanation:

This defines the functionl it receives the array and the length of the array

int returnsFixed(int arr [],int n){

This initializes the return value to -1

   int retVal = -1;

This iterates through the array

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

This checks if i equals arr[i]

       if(i == arr[i]){

If yes, the return value (i.e. the fixed point) is set to i

           retVal = i;

And the code is exited

           break;

       } This ends the if condition

   } This ends the iteration

This returns the calculated fixed point

   return retVal;

}


Related Questions

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

How can I pass the variable argument list passed to one function to another function.

Answers

Answer:

Explanation:

#include <stdarg.h>  

main()  

{  

display("Hello", 4, 12, 13, 14, 44);  

}  

display(char *s,...)  

{  

va_list ptr;  

va_start(ptr, s);  

show(s,ptr);  

}  

show(char *t, va_list ptr1)  

{  

int a, n, i;  

a=va_arg(ptr1, int);  

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

 {  

n=va_arg(ptr1, int);  

printf("\n%d", n);  

}  

}

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.

The conversion rate would be the highest for keyword searches classified as Group of answer choices buyers grazers researchers browsers

Answers

Answer:

buyers

Explanation:

Search engine optimization (SEO) can be defined as a strategic process which typically involves improving and maximizing the quantity and quality of the number of visitors (website traffics) to a particular website by making it appear topmost among the list of results from a search engine such as Goo-gle, Bing, Yah-oo etc.

This ultimately implies that, search engine optimization (SEO) helps individuals and business firms to maximize the amount of traffic generated by their website i.e strategically placing their website at the top of the results returned by a search engine through the use of algorithms, keywords and phrases, hierarchy, website updates etc.

Hence, search engine optimization (SEO) is focused on improving the ranking in user searches by simply increasing the probability (chances) of a specific website emerging at the top of a web search.

Typically, this is achieved through the proper use of descriptive page titles and heading tags with appropriate keywords.

Generally, the conversion rate is mainly designed to be the highest for keyword searches classified as buyers because they're the main source of revenue for a business and by extension profits.

Write a recursive function that calculates the sum 11 22 33 ... nn, given an integer value of nin between 1 and 9. You can write a separate power function in this process and call that power function as needed:

Answers

Answer:

The function in Python is as follows:

def sumDig(n):

if n == 1:

 return 11

else:

 return n*11 + sumDig(n - 1)

Explanation:

This defines the function

def sumDig(n):

This represents the base case (where n = 1)

if n == 1:

The function returns 11, when it gets to the base case

 return 11

For every other value of n (n > 1)

else:

This calculates the required sum recursively

 return n*11 + sumDig(n - 1)

Can you suggest a LinkedIn Helper (automation tool) alternative?

Answers

Answer:

Have you tried LinkedCamp alternative to LinkedIn Helper?

Well, LinkedCamp is a super-efficient cloud-based LinkedIn Automation Tool that empowers businesses and sales industries to drive more LinkedIn connections, hundreds of leads, sales, and conversions automatically.

Some other LinkedIn automation tools are:

Meet Alfred Phantombuster WeConnect ZoptoExpandi

Hope you find it useful.

Good luck!

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

What is machine learning

Answers

Answer:

machine learning is the ability for computers to develop new skills and algorithms without specific instructions to do so.

Machine learning is a branch of artificial intelligence (AI) and computer science which focuses on the use of data and algorithms to imitate the way that humans learn, gradually improving its accuracy.

An e-mail program allows?
A. users to access and view web pages on the internet.
B. geographically separated people to transfer audio and video.
C. real-time exchange of messages or files with another online user.
D. transmission of messages and files via a network such as the internet.​

Answers

Answer:

C

Explanation:

Real time exchange of messages or files with another online user

A student registers for a course in a university. Courses may have limited enrollment i.e a student must
enroll atmost 9 credit hours, the registration process must include checks that places are available. Assume
that the student accesses an electronic course catalog to find out about available courses. Which design
model should be followed by this secenario? Draw any two UML diagrams.

Answers

Answer:

Follows are the complete question to the given question:

Explanation:

The UML scheme is a UML-based diagram intended to depict the system visually, together with its key actors, roles, activities, objects, and classes, to gather information the about system, change that, or maintain it.

Every complex process is better understood via sketches or pictures. These diagrams have a higher understanding effect. By glancing about, we notice that diagrams are not a new idea but are widely used in various business types. To enhance understanding of the system, we prepare UML diagrams. There is not enough of a single diagram to represent all aspects of the system. You can also create customized diagrams to satisfy your needs. Iterative and incremental diagrams are usually done.

There are two broad diagram categories and that they are broken into subclasses again:

Diagram structureDiagrams of behavior

Please find the graph file of the question in the attachment.

what is the meaning of compiler​

Answers

Answer:

in computing it means a program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer.

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

Web-Based Game that serves multiple platforms
Recommendations
Analyze the characteristics of and techniques specific to various systems architectures and make a recommendation to The Gaming Room. Specifically, address the following:
1. Operating Platform: Recommend an appropriate operating platform that will allow The Gaming Room to expand Draw It or Lose It to other computing environments.>
2. Operating Systems Architectures:
3. Storage Management:
4. Memory Management:
5. Distributed Systems and Networks:
6. Security: Security is a must-have for the client. Explain how to protect user information on and between various platforms. Consider the user protection and security capabilities of the recommended operating platform.>

Answers

Answer:

Here the answer is given as follows,

Explanation:

Operating Platform:-  

In terms of platforms, there are differences between, mobile games and pc games within the way it's used, the operator, the most event play, the sport design, and even the way the sport work. we all know that each one the games on console platforms, PC and mobile, have their own characteristic which has advantages and disadvantages All platforms compete to win the rating for the sake of their platform continuity.  

Operating system architectures:-  

Arm: not powerful compared to x86 has many limitations maximum possibility on arm arch is mobile gaming.  

X86: very powerful, huge development so easy to develop games on platforms like unity and unreal, huge hardware compatibility and support  

Storage management:-  

On the storage side, we've few choices where HDD is slow and too old even a replacement console using SSD. so SSD is the suggested choice. But wait SSD have also many options like SATA and nvme.    

Memory management:-  

As recommended windows, Each process on 32-bit Microsoft Windows has its own virtual address space that permits addressing up to 4 gigabytes of memory. Each process on 64-bit Windows features a virtual address space of 8 terabytes. All threads of a process can access its virtual address space. However, threads cannot access memory that belongs to a different process.  

Distributed systems and networks:-  

Network-based multi-user interaction systems like network games typically include a database shared among the players that are physically distributed and interact with each other over the network. Currently, network game developers need to implement the shared database and inter-player communications from scratch.  

Security:-  

As security side every game, there's an excellent risk that, within the heat of the instant, data are going to be transmitted that you simply better keep to yourself. There are many threats to your IT.  

Define on the whole data protection matters when developing games software may cause significant competitive advantages. Data controllers are obliged under the GDPR to attenuate data collection and processing, using, as an example , anonymization or pseudonymization of private data where feasible.

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

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()

Answer to this problem

Answers

Answer:

hi..,.................................................

View "The database tutorial for beginners" and discuss how database management systems are different from spreadsheets. Describe one experience you have had working with data.

Answers

Answer and Explanation:

A spreadsheet is an interactive computer application for the analysis and storage of data. The database is a collection of data and accessed from the computer system. This is the main difference between spreadsheets and databases. The spreadsheet is accessed by the user and the database is accessed by the user. The database can store more data than a spreadsheet. The spreadsheet is used for tasks and used in enterprises to store the data. Spreadsheet and database are two methods and the main difference is the computer application that helps to arrange, manage and calculate the data. The database is a collection of data and organized to access easily. Spreadsheet applications were the first spreadsheet on the mainframe. Database stores and manipulates the data easily. The database maintains the data and stores the records of teachers and courses. The spreadsheet is the computer application and analyzing the data in table form. The spreadsheet is a standard feature for productive suite and based on an accounting worksheet.

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 ...

Why input screens are better data entry than entreing data dirrctly to a table

Answers

Answer:

are better data entry designs than entering data directly to a table. ... hence a user can design input fields linked to several tables/queries.

Explanation:

Input screens are better data entry designs than entering data directly to a table because a user can design input fields linked to several tables/queries.

What is digital information?

Digital information generally consists of data that is created or prepared for electronic systems and devices such as computers, screens, calculators, communication devices. These information are stored by cloud.

They are converted from digital to analog and vice versa with the help of a device.

Data entered in the table directly is easier than data entry method.

Thus, input screens are better data entry than entering data directly to a table.

Learn more about digital information.

https://brainly.com/question/4507942

#SPJ2

9.18 LAB: Exact change - methods Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per line. The coin types are dollars, quarters, dimes, nickels, and pennies. Use singular and plural coin names as appropriate, like 1 penny vs. 2 pennies. Ex: If the input is:

Answers

Answer:

Explanation:

The following code is written in Java. It asks the user to enter the amount of change needed. This is done as a double since we are dealing with coins and not full dollar values alone. It then makes the necessary calculations to calculate the number of each coin needed and outputs it back to the user. A test case has been provided in the picture below with a sample output.

import java.util.Scanner;

class Brainly {

   public static void main(String[] args) {

       int dollars = 1;

       double quarters = 0.25;

       double dimes = 0.10;

       double nickels = 0.05;

       double pennies = 0.01;

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Change Value: ");

       double change = in.nextDouble();

       int numDollars, numQuarters, numDimes, numNickels, numPennies;

       double newChange;

       numDollars = (int) (change / dollars);

       newChange = change % dollars;

       numQuarters = (int) (newChange / quarters);

       newChange = newChange % quarters;

       numDimes = (int) (newChange / dimes);

       newChange = newChange % dimes;

       numNickels = (int) (newChange / nickels);

       newChange = newChange % nickels + 0.001;

       numPennies = (int) (newChange / pennies);

       newChange = newChange % pennies;

       

       System.out.println("Minimum Num of Coins needed: ");

       if (numDollars != 1) {

           System.out.println(numDollars + " Dollars");

       } else {

           System.out.println(numDollars + " Dollar");

       }

       if (numQuarters != 1) {

           System.out.println(numQuarters + " Quarters");

       } else {

           System.out.println(numQuarters + " Quarter");

       }

       if (numDimes != 1) {

           System.out.println(numDimes + " Dimes");

       } else {

           System.out.println(numDimes + " Dime");

       }

       if (numNickels != 1) {

           System.out.println(numNickels + " Nickels");

       } else {

           System.out.println(numNickels + " Nickel");

       }

       if (numPennies != 1) {

           System.out.println(numPennies + " Pennies");

       } else {

           System.out.println(numPennies + " Penny");

       }

   }

}

The program is an illustration of conditional statements

Conditional statements are used to make decisions

The program in C++ where comments are used to explain each line is as follows

#include<iostream>

using namespace std;

int main() {

// This line declare all the variables

int amount, dollar, quarter, dime, nickel, penny;

// This prompts the user for input (i.e. the amount)

cout<<"Amount: ";

//This gets the amount from the user

cin>>amount;

// This checks if the amount is 0 or less

if(amount<=0)  {

//This prints "No Change"

cout<<"No Change";

}

//If the amount is greater than 0

else {

// These convert the amount to various coins

dollar = amount/100;

amount = amount%100;

quarter = amount/25;

amount = amount%25;

dime = amount/10;

amount = amount%10;

nickel = amount/5;

penny = amount%5;

// The next lines print the coins

if(dollar>=1)  {

if(dollar == 1) {

cout<<dollar<<" dollar\n"; }

else {

cout<<dollar<<" dollars\n"; }

}

if(quarter>=1) {

if(quarter== 1) {

cout<<quarter<<" quarter\n";

}

else {

cout<<quarter<<" quarters\n";

}

}

if(dime>=1) {

if(dime == 1) {

cout<<dime<<" dime\n";

}

else {

cout<<dime<<" dimes\n";

}

}

if(nickel>=1) {

if(nickel == 1) {

cout<<nickel<<" nickel\n";

}

else {

cout<<nickel<<" nickels\n";

}

}

if(penny>=1) {

if(penny == 1) {

cout<<penny<<" penny\n";

}

else {

cout<<penny<<" pennies\n";

}

}

}

return 0;

}

Read more about conditions at:

https://brainly.com/question/15683939

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

2. Which tab is used to edit objects on the Slide Master and layouts?
A. View
B. Insert
C. Shape format
D. Design

Answer is not A. View
It’s B. Insert

Answers

Answer:

it is....insert tab..B

Explanation:

insert tab includes editing options

Write a recursive method to form the sum of two positive integers a and b. Test your program by calling it from a main program that reads two integers from the keyboard and users your method to complete and print their sum, along with two numbers.

Answers

Answer:

see the code snippet below writing in Kotlin Language

Explanation:

fun main(args: Array<String>) {

   sumOfNumbers()

}

fun sumOfNumbers(): Int{

   var firstNum:Int

   var secondNum:Int

   println("Enter the value of first +ve Number")

   firstNum= Integer.valueOf(readLine())

   println("Enter the value of second +ve Number")

   secondNum= Integer.valueOf(readLine())

   var sum:Int= firstNum+secondNum

  println("The sum of $firstNum and $secondNum is $sum")

   return sum

}

Resize vector countDown to have newSize elements. Populate the vector with integers {newSize, newSize - 1, ..., 1}. Ex: If newSize = 3, then countDown = {3, 2, 1}, and the sample program outputs:
#include
#include
using namespace std;
int main() {
vector countDown(0);
int newSize = 0;
int i = 0;
newSize = 3;
STUDENT CODE
for (i = 0; i < newSize; ++i) {
cout << countDown.at(i) << " ";
}
cout << "Go!" << endl;
return 0;
}

Answers

Answer:

Following are the code to the given question:

#include <iostream>//defining header file

#include <vector>//defining header file

#include <numeric>//defining header file

using namespace std;

int main()//main method

{

vector<int> countDown(0);//defing an integer array variable countDown

int newSize = 0;//defing an integer variable newSize that holds a value 0

int i = 0;//defing an integer variable i that initialize with 0

newSize = 3;// //use newSize to hold a value

countDown.resize(newSize,0);// calling the resize method that accepts two parameters

for (i = 0; i < newSize; ++i)//defining a loop that reverse the integer value

{

countDown[i] = newSize -i;//reverse the value and store it into countDown array

cout << countDown.at(i) << " ";//print reverse array value

}

cout << "Go!" << endl;//print message

return 0;

}

Output:

3 2 1 Go!

Explanation:

In the given code inside the main method an integer array "countDown" and two integer variables "newSize and i" is declared that initializes a value that is 0.

In the next step, an array is used that calls the resize method that accepts two parameters, and define a for a loop.

In this loop, the array is used to reverse the value and print its value with the message.

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. True False

Answers

Answer: False

Explanation:

The statement that "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" is false.

It should be noted that if one fail a course as a residency course, the course can only be repeated as a main (residency) course and not an online course. When a course is failed, such course has to be repeated the following semester and this will give the person the chance to improve their GPA.

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

Answers

Answer:

sorry, I don't know what that is

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;

   }

}

How would you type the word floor

Answers

Answer:

f l o o r

Explanation:

Java !!!
A common problem in parsing computer languages and compiler implementations is determining if an input string is balanced. That is, a string can be considered balanced if for every opening element ( (, [, <, etc) there is a corresponding closing element ( ), ], >, etc).
Today, we’re interested in writing a method that will determine if a String is balanced. Write a method, isBalanced(String s) that returns true if every opening element is matched by a closing element of exactly the same type. Extra opening elements, or extra closing elements, result in an unbalanced string. For this problem, we are only interested in three sets of characters -- {, (, and [ (and their closing equivalents, }, ), and ]). Other characters, such as <, can be skipped. Extra characters (letters, numbers, other symbols) should all be skipped. Additionally, the ordering of each closing element must match the ordering of each opening element. This is illustrated by examples below.
The following examples illustrate the expected behaviour:
is Balanced ("{{mustache templates use double curly braces}}") should return true
is Balanced("{{but here we have our template wrong!}") should return false
is Balanced("{ ( ( some text ) ) }") should return true
is Balanced("{ ( ( some text ) } )") should return false (note that the ordering of the last two elements is wrong)
Write an implementation that uses one or more Stacks to solve this problem. As a client of the Stack class, you are not concerned with how it works directly, just that it does work.

Answers

Answer:

Explanation:

import java.util.*;

public class BalancedBrackets {

// function to check if brackets are balanced

static boolean isBalanced(String expr)

{

Stack<Character> stack = new Stack<Character>();

for (int i = 0; i < expr.length(); i++)

{

char x = expr.charAt(i);

if (x == '(' || x == '[' || x == '{')

{

// Push the element in the stack

stack.push(x);

continue;

}

if (stack.isEmpty())

return false;

char check;

switch (x) {

case ')':

check = stack.pop();

if (check == '{' || check == '[')

return false;

break;

case '}':

check = stack.pop();

if (check == '(' || check == '[')

return false;

break;

case ']':

check = stack.pop();

if (check == '(' || check == '{')

return false;

break;

}

}

// Check Empty Stack

return (stack.isEmpty());

}

public static void main(String[] args)

{

Scanner scan = new Scanner(System.in);

System.out.println("\nEnter the expression to check is balanced or not !");

String expr = scan.nextLine();

boolean output;

output = isBalanced(expr);

System.out.println(output);

if (output)

System.out.println("Balanced ");

else

System.out.println("Not Balanced ");

scan.close();

}

}

Write a program in c++ that will:1. Call a function to input temperatures for consecutive days in 1D array. NOTE: The temperatures will be integer numbers. There will be no more than 10 temperatures.The user will input the number of temperatures to be read. There will be no more than 10 temperatures.2. Call a function to sort the array by ascending order. You can use any sorting algorithm you wish as long as you can explain it.3. Call a function that will return the average of the temperatures. The average should be displayed to two decimal places.Sample Run:Please input the number of temperatures to be read5Input temperature 1:68Input temperature 2:75Input temperature 3:36Input temperature 4:91Input temperature 5:84Sorted temperature array in ascending order is 36 68 75 84 91The average temperature is 70.80The highest temperature is 91.00The lowest temperature is 36.00

Answers

Answer:

The program in C++ is as follows:

#include <iostream>

#include <iomanip>

using namespace std;

int* sortArray(int temp [], int n){

   int tmp;

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

 for (int j = i + 1;j < n;j++){

  if (temp[i] > temp[j]){

   tmp  = temp[i];

   temp[i] = temp[j];

   temp[j] = tmp;   }  } }

return temp;

}

float average(int temp [], int n){

   float sum = 0;

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

       sum+=temp[i];    }

   return sum/n;

}

int main(){

   int n;

   cout<<"Number of temperatures: ";    cin>>n;

   while(n>10){

       cout<<"Number of temperatures: ";    cin>>n;    }

   int temp[n];

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

       cout<<"Input temperature "<<i+1<<": ";

       cin>>temp[i];    }

   int *sorted = sortArray(temp, n);

   cout<<"The sorted temperature in ascending order: ";

   for( int i = 0; i < n; i++ ) {  cout << *(sorted + i) << " ";   }

   cout<<endl;

   float ave = average(temp,n);

   cout<<"Average Temperature: "<<setprecision(2)<<ave<<endl;

   cout<<"Highest Temperature: "<<*(sorted + n - 1)<<endl;

   cout<<"Lowest Temperature: "<<*(sorted + 0)<<endl;

   return 0;

}

Explanation:

See attachment for complete source file with explanation

Other Questions
The concept of market efficiency underpins almost all financial theory and decision models. When financial markets are efficient, the price of a securitysuch as a share of a particular corporations common stockshould be____the present value estimate of the firms expected cash flows discounted by its appropriate rate of return (also called the intrinsic value of the stock).Almost all financial theory and decision models assume that the financial markets are efficient. The informational efficiency of financial markets determines the ability of investors to "beat" the market and earn excess (or abnormal) becomes available. Financial theorists have identified three levels of informational efficiency that reflect what information is incorporated in stock prices. Consider the following statement, and identify the form of capital market efficiency under the efficient market hypothesis based on this statement. Current market prices reflect all relevant publicly available information. This statement is consistent with:_____.A. Strong-form efficiency.B. Weak-form efficiency.C. Semistrong form efficiency. Consider that there is a semistrong-form of efficiency in the markets. A pharmaceutical company announces that it has received Federal Drug Administration approval for a new allergy drug that completely prevents hay fever The consensus analyst forecast for the company's earnings per share (EPS) is $4.50, but insiders know that, with this new drug, earnings will increase and drive the EPS to $5.00. What will happen when the company releases its next earnings report? A. There will be some volatility in the stock price when the earnings report is released: it is difficult to determine the impact on the stock price. B. The stock price will not change, because the market already incorporated that information in the stock price when the announcement was made. C. The stock price will increase and settle at a new equilibrium level. 1.I buy a book.Yo_____ un libro. (comprar)2.I need a calculator.Yo____ una calculadora. (necesitar)3.I dont look for a ruler.Yo no ____ una regla. (buscar)4.Pablo buys a book.Pablo _____ un libro. (comprar)5.Lorena needs a pen.Lorena_____ un bolgrafo. (necesitar)6.Daniel doesnt need a book Daniel no______ un libro. (necesitar)7.Do you need a pen?T______ un bolgrafo? (necesitar)8.Are you buying a backpack? T_____ una mochila? (comprar)9.Are you looking for a pencil? T_____ un lpiz? (buscar)10.Are you buying a calculator? T_____ una calculadora? (comprar) Find the length of side xx in simplest radical form with a rational denominator. Which of the following equations describes this graph? A. y=(x-1)^2- B. y=(x-3)^2+2 C. y=(x+1)^2-2 D. y=(x-2)^2+3 MC Qu. 120 Dallas Company uses a job order... Dallas Company uses a job order costing system. The company's executives estimated that direct labor would be $4,160,000 (260,000 hours at $16/hour) and that factory overhead would be $1,560,000 for the current period. At the end of the period, the records show that there had been 240,000 hours of direct labor and $1,260,000 of actual overhead costs. Using direct labor hours as a base, what was the predetermined overhead rate Type the correct answer in each box. Use numerals instead of words Solve the inequality and write the solution set using both set-builder notation and interval notation. -3a-15-2a+6 kxndjdkdkdkkdkskskdkdjdjdjskskskdjdjddjd * Insert a digit to make numbers that are divisible by 6 if it is possible:234_6 The tables below show the values of y corresponding to different values of x: Table A x 3 3 2 y 1 0 0 Table B x 3 5 5 y 2 2 2 Which statement is true for the tables? (1 point) Both Table A and Table B represent functions. Both Table A and Table B do not represent functions. Table A does not represent a function, but Table B represents a function. Table A represents a function, but Table B does not represent a function. definition of public administration 1 points Time Remaining 41 minutes 43 seconds00:41:43 Item 13 Time Remaining 41 minutes 43 seconds00:41:43 Richards Corporation uses the FIFO method of process costing. The following information is available for October in its Fabricating Department: Units: Beginning Inventory: 80,000 units, 60% complete as to materials and 20% complete as to conversion. Units started and completed: 250,000. Units completed and transferred out: 330,000. Ending Inventory: 30,000 units, 40% complete as to materials and 10% complete as to conversion. Costs: Costs in beginning Work in Process - Direct Materials: $37,200. Costs in beginning Work in Process - Conversion: $79,700. Costs incurred in October - Direct Materials: $646,800. Costs incurred in October - Conversion: $919,300. Calculate the equivalent units of materials. Two forces act on the screw eye. If F = 600 N, determine the magnitude of the resultant force and the angle if the resultant force is directed vertically upward. what were the Browns and other families asking the supreme court to do? Thinking directed toward the discovery of a single established correct answer is known as __________ thinking. Required-: JOURNAL ENTRY (ACCOUNT)Paid Rs. 28,000 to Sansee stores in fullsettlement of Rs. 30,000 by cheque please help Me with this. I'm still confused in it. Whats the answer please help Ling must spend no more than $40.00 on decorations for a party. She has spent $10.00 on streamers and wants to buy bags of balloons as well. Each bag of balloons costs $2.50. The inequality below represents x, the number of bags she can buy given the spending limit and how much she has already spent on streamers.10 + 2.5 x less-than-or-equal-to 40Which best describes the number of bags of balloons she can buy? Which things do you associate with ideas and concepts? Check all that apply.O Gateway ArchLiberty BellSmokey the BearStatue of Libertya bald eagleO a diamond ringO a snake How to do the writing task 1 from the 2020 GAT