Given the following Java code:
public static boolean f(int [] arr) {
for (int i = 0; i < arr.length - 1; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i] < arr[j]) // *HERE*
return false;}
return true;}
(i) Find the number of times the comparison marked by *HERE* will be evaluated for each input:
{1, 2}
{10, 20, 30}
{30, 20, 10}
{-4, 7, 1}
(ii) For an array of size ????, what is the big-oh runtime of this code in the worst case?

Answers

Answer 1

Answer:

See explaination

Explanation:

{1, 2}

Runs only once for 1 < 2

{10, 20, 30}

Runs 1 for 10 < 20

Runs 1 for 10 < 30

Runs 1 for 20 < 30

Total 3 times

{30, 20, 10}

Runs 1 for 30 < 20

Runs 1 for 30 < 10

Runs 1 for 20 < 10

Total 3 times

{-4, 7, 1}

Runs 1 for -4 < 7

Runs 1 for -4 < 1

Runs 1 for -7 < 1

​​​​​​​Total 3 times

Generalizing it will run for n*(n-1)/2 so for 2 element it will run for 2*1/2 = 1

For 3 element it will run for 3*2/2 = 3 times

(ii) (3 points) For an array of size , what is the big-oh runtime of this code in the worst case?

Time complexity in Worst case is O(n^2). Reason being it uses two for loop where first loop runs for n time and the second loop runs for n*n time in worst case hence its O(n^2)


Related Questions

i need the solution to this task please anyone

Answers

Answer:

.

Explanation:

Part 2 Graduate Students Only Architectural simulation is widely used in computer architecture studies because it allows us to estimate the performance impact of new designs. In this part of the project, you are asked to implement a pseudo-LRU (least recently used) cache replacement policy and report its performance impact. For highly associative caches, the implementation cost of true LRU replacement policy might be too high because it needs to keep tracking the access order of all blocks within a set. A pseudoLRU replacement policy that has much lower implementation cost and performs well in practice works as follows: when a replacement is needed, it will replace a random block other than the MRU (most recently used) one. You are asked to implement this pseudo-LRU policy and compare its performance with that of the true LRU policy. For the experiments, please use the default configuration as Question 3 of Project Part 1, fastforward the first 1000 million instructions and then collect detailed statistics on the next 500 million instructions. Please also vary the associativity of L2 cache from 4 to 8 and 16 (the L2 size should be kept as 256KB). Compare the performance of the pseudo-LRU and true-LRU in terms of L2 cache miss rates and IPC values. Based on your experimental results, what is your recommendation on cache associativity and replacement policy? Please include your experimental results and source code (the part that has been modified) in your report. Hint: The major changes of your code would be in cache.c.

Answers

The  outline that a person can use to implement as well as compare the pseudo-LRU and that of the  true-LRU cache replacement policies is given below

What is the code  about?

First, one need to make changes the cache replacement policy that can be see in the cache.c file of a person's code.

Thereafter one need to Run simulations with the use of the already modified  or changed code via the use of the default configuration as said in Question 3 of Project Part 1.

Therefore, one can take detailed statistics, such as L2 cache miss rates and IPC (Instructions Per Cycle) values, for all of the next 500 million instructions.  etc.

Learn more about code  from

https://brainly.com/question/26134656

#SPJ1

In what year was napier bone invented ​

Answers

The Napier's Bones is a manually-operated calculating device, invented by the Scottish mathematician John Napier in the early 17th century, around the year 1617.

What is Napier bone used for?

Napier's Bones, also known as Napier's rods, are used for multiplication, division, and square root calculations. The device consists of a set of rectangular rods or bones with each bone representing a single digit in the multiplication table.

By manipulating the rods, users can quickly perform calculations that would otherwise be time-consuming to complete by hand. The Napier bone is an early example of a calculating device and is considered a predecessor to modern mechanical calculators.

Learn more about Napier bone  at:

https://brainly.com/question/24242764

#SPJ1

touching touching color color is touelung ask What's your name? and wait NOUS MOUW mouse down? key pacmpressed distance to reset timer tamer gation of Sprite loudnese Dend aldur sensor value sensor button pressed Q. What is the function of the light blue blocks?

it is an Options Question. And the Options are: Motion. Operation. Sensing​

Answers

Answer:

Sensing.

These are all sensing blocks in a coding language called Snap! Build your own blocks. The same goes for Scratch.

The when touching brick calls a function if a sprite is touching a certain thing.

The mouse down calls a function when the mouse is down.

The reset timer declares a reset for the timer box.

Lastly, the when key pressed? declares that when a certain key is pressed, a function is called.

Answer:

sensing because the motion is green and operating is red.

Explanation:

I need help to pick what programming language is best to make videogames

Answers

Answer:

In my opion its java script

Explanation:

a personal statement should be submitted

Answers

Answer:

Prospective employers and universities may ask for a personal statement that details your qualifications for a position or degree program. Writing a compelling personal statement is an excellent way to highlight your skills and goals to an employer or university.

Yes, submitting a personal statement is often required or advised when applying for specific academic programs, scholarships, or jobs.

A person's background, experience, objectives and motivations can all be expressed in a personal statement, which is a written declaration. This gives the applicant a chance to highlight personal successes, abilities and characteristics that make them an excellent contender for the position they are pursuing.

A well-written personal statement can help tell a compelling story and make a good impression on the hiring manager or committee. It is important to follow closely any instructions or prompts given and to adjust individual details to the particular needs of the application.

Learn more about personal statement, here:

https://brainly.com/question/3660905

#SPJ1

. What projects would Excel best be used for?

Answers

Answer:

Projects that require spreadsheet organization and/or calculations between data

Explanation:

That is why Excel is a spreadsheet program

numMembers is read from input as the size of the vector. Then, numMembers elements are read from input into the vector walkingLogs. Use a loop to access each element in the vector and if the element is greater than averageMembers, output the element followed by a space.

Ex: If the input is 4 182 82 39 81, then the output is:

Average: 96
Numbers greater than average: 182

Answers

A loop is used to make a specific piece of code repeat several times in a program.

Thus, You can choose from a variety of loop types since each loop type satisfies a certain requirement. For instance, the Do While loop causes a program to repeatedly run a particular type of code while it is carrying out another task.

Many experts use Excel and VBA to perform fantastic and highly efficient work. Check out the Udemy course Ultimate Excel VBA if you wish to use Excel to its greatest potential and integrate programming with data work.

VBA You should be aware of the significance of each loop. Every loop is intended for a certain circumstance. A do while loop, for instance, repeats a certain amount of code while a condition is met.

Thus, A loop is used to make a specific piece of code repeat several times in a program.

Learn more about Loop, refer to the link:

https://brainly.com/question/14390367

#SPJ1

First Resource is offering a 5% discount off registration fees for all EventTypes except for Survey/Study.

In cell K11 enter a formula that will return 0.05 if the event is NOT a Survey/Study, otherwise return a blank value ("").

Use a VLOOKUP function to return the EventType from the EventDetails named range.

Use a NOT function so that any event type other than Survey/Study will return TRUE.

Use an IF function to return 0.05 for the value_if_true and "" for the value_if_false.

Incorporate an IFERROR function to return a blank value if the VLOOKUP function returns an error.

Format the result as Percentage with 0 decimal places and copy the formula down through K34.

Answers

Use a VLOOKUP function to return the EventType from the EventDetails named range. Use a NOT function so that any event type other than Survey/Study will return TRUE.

Use an IF function to return 0.05 for the value_if_true and "" for the value_if_false. Vlookup is a technique in excel which enables users to search for criterion values. It is vertical lookup function in excel which return a value from a different column.

Vlookup'select cell you want to look up in' select cell you want to lookup from' select column index number' true/false. where true is approximate match and false is exact match.

Learn more about technician on:

https://brainly.com/question/14290207

#SPJ1

. Write a program that creates a list and adds to it 20 random numbers under 1000. Once you’ve
created the list write some code to find and output the smallest number in the list.

Answers

Randint(1, 1000) # Choose an arbitrary integer between 1 and 1000. The Python randint() method is used to produce random numbers. In the random module, this function is defined.

How can a random integer between 1 and 20 be generated in Python?

Utilize the random function to generate a random integer number from the provided exclusive range. The increment randrange parameter (0, 10, 2) will generate any random number between 0 and 20.

Python supports initializing lists with list(), list multiplication, list comprehension, and square brackets. An empty list or a list with some default values can be initialized using square brackets. Similar to how square brackets function, the list() method also does.

To know more about Python randint visit:-

https://brainly.com/question/28163367

#SPJ1

List to String (0.5 points) Since we are often dealing with a list of strings, it would be useful to have a function to tum a list of strings back into one single concatenated string, This function will return a string that is each element of input_list concatenated together with each separated by the string Separator For example, the following function call: list_to_string('This', 'is's 'fun' should return; "This is fun To do this, write a function called list_to_string This function should have the following inputs, outputs, and internal procedures: Input(s) input_list - list of strings . separator - string Output(s); . output - string Procedure(s): - assign a variable called output to be the first (index 0) element from input_list - loop through the rest of input_list, looping from the 2nd element index 1) through to the end of the list - Within the loop, use string concatenator to combine output with the current element, separated by separator • Assign the output of this to be the new value of output • return output, which should now be a list of the elements of input_list joined together into a single string

Answers

Answer:

The function is as follows:

def list_to_string(input_list,separator):

   output = ""

   for inp in input_list:

       output+=inp+separator

       

   output = output[:-1]

   return output

Explanation:

Given

See attachment for instruction

Required

A function to convert list to string

This defines the string

def list_to_string(input_list,separator):

This initializes the output to an empty string

   output = ""

This iterates through the input list

   for inp in input_list:

This concatenates every string in the list including the separator

       output+=inp+separator

This removes the last character of the string

   output = output[:-1]

This returns the output string

   return output

List to String (0.5 points) Since we are often dealing with a list of strings, it would be useful to

3. A file has 250 pages, each page contains 50 lines. Each line can be represented by
9 bits. Your network can download the whole file within 50 seconds. What is the
bit rate for your network?
(6 Points)​

Answers

Answer:

2,250b/s

Explanation:

50*250=12,500 (Lines in total)

12,500*9=112,500 (Bits in total)

12,500/50=2,250 (Bits per second)

For given natural number n, e.g n=3, print string "1 sheep...2 sheep...3 sheep". Can someone help?​

Answers

The code that is used to count sheep aloud in Javascript is given as:

var countSheep = function (num){

 //start with a counter i = 1

 // increment i

 // stop until i == num

 // "interpolation" to insert variables

 // return joint array

   let smallArr = "";

   for (let x = 1; x <= num; x++)

   {

      smallArr += `${x} sheep...`

   }

   return smallArr;

};

Read more about javascript here:

https://brainly.com/question/16698901

#SPJ1

You are tasked with designing the following 3bit counter using D flip flops. If the current state is represented as A B C, what are the simplified equations for each of the next state representations shown as AP BP CP?

The number sequence is : 0 - 1 - 2 - 4 - 3 - 5 - 7 - 6 - 0

Answers

How to solve this

In the given 3-bit counter, the next state of A, B, and C (represented as A', B', and C') depends on the current state ABC.

The sequence is 0-1-2-4-3-5-7-6 (in binary: 000, 001, 010, 100, 011, 101, 111, 110).

The simplified next state equations for D flip-flops are:

A' = A ⊕ B ⊕ C

B' = A · B ⊕ A · C ⊕ B · C

C' = A · B · C

This counter follows the mentioned sequence and recycles back to 0 after reaching the state 6 (110). These equations can be implemented using XOR and AND gates connected to D flip-flops.

Read more about XOR and AND gates here:

https://brainly.com/question/30890234

#SPJ1

Based on the description below which website is more appropriate


A. a site that asks you to send $10 to help schoolchildren in Uganda
B. a site that describe violent behavior
C. a site that asks for your personal information to win a contest for a new bike
D. a site sponsored by a government agency that gives you factual information

Answers

Answer:

D

Explanation:

Answer:

The answer is d

Explanation:

because asking for 10 dollars is the first website is not normal and in the second describing violent behavior is not ok and the third asking for personal information for a free bike is not good but d a site sponsored giving you factual information that made by the government is trustworthy

2. Select the things you can do when working with rows in columns in a spreadsheet:
Freeze a row or column
Delete a row or column
Hide a row or column
Add a row or column
Move rows or columns

Answers

I think you can do all of those things to rows and columns when working with a spreadsheet.

Convert (3ABC) 16 to decimal number systam ​

Answers

I’m not sure about this and please give me some poitns because I need help

1. It is a technique of creating a picture or pattern by forcing ink or metal on to a surface though a screen of fine material.​

Answers

Answer:

hmm

Explanation:

I'm pretty sure it's screen painting? it's a print making method that forces ink through fine mesh

In which sections of your organizer should the outline be located?

Answers

The outline of a research proposal should be located in the Introduction section of your organizer.

Why should it be located here ?

The outline of a research proposal should be located in the Introduction section of your organizer. The outline should provide a brief overview of the research problem, the research questions, the approach, the timeline, the budget, and the expected outcomes. The outline should be clear and concise, and it should be easy for the reader to follow.

The outline should be updated as the research proposal evolves. As you conduct more research, you may need to add or remove sections from the outline. You may also need to revise the outline to reflect changes in the project's scope, timeline, or budget.

Find out more on outline at https://brainly.com/question/4194581

#SPJ1

explain float data [100]​

explain float data [100]

Answers

Answer:

useless

Explanation:

float data[100] allocates an array of 100 floats on the stack. In the attached program however, these values are never used. A sum is accumulated on the fly, so there is no need to store the individual values for later use, as there is no later use.

In fact, if the number entered for setSize exceeds 99, the program will even corrupt memory, as you will write beyond the allocated size for the array.

Which of the following is not a form of technology?

A) computer

B) ketchup

C) pencil

D) umbrella

Answers

Answer:

ketchup because all of the others are objects with certain creative functions but ketchup is just K e t c h u p.

Answer:
A well known answer yes u guessed ryt it’s “Ketchup”.
Horaayy felicitations to u


Now back to the question, according to the definition of “technology”:
“An equipment or machinery made by engineering or applied science/sciences is called technology”.
As u can c that ketchup is this certainly not a technology rather a recipe/food item etc.

The game often becomes stuck on landscape mode when tilting the device during gameplay, which cuts off some peripheral text. A workaround exists: by pausing and resuming the game, the app will return to portrait mode. This bug has the following severity​

Answers

Answer:

The overview of the given situation is described in the explanation segment below.

Explanation:

Bug Severity seems to be the extent of influence that somehow a fault will have on the device, while its primary concern is indeed the command of severity that had already affected that same device.You should consider this error as top importance as another framework hangs. I would say you may be lacking the configuration manager settings in your system.

Therefore the above is the right answer.

The coordinates for the section element need not be defined as long as its position is set to

Answers

Answer:

relative.

Explanation:

The coordinates for the section element need not be defined as long as its position is set to relative.

If the position is set as relative, then it will have no effect on the positioning attributes, it will consider as static position. If positioning is mentioned explicitly like top: 20px; then it will position 10 pixels down from where it is located. An ability for positional shifts is extremely helpful.

Two things happen when an element is set as relative, one is it introduces the ability to use z-index on that element, second is it limits the scope of absolutely positioned child elements.  

To rename a worksheet, you change the text on the ? HELP ASAP

A. Sheet Columns
B. Sheet Header
C. Sheet tab

Answers

If this is Excel, it would be C. Sheet tab

Suppose, you are planning to start a software development business in Pakistan. You are required to develop a complete plan while keep in mind the available experienced tech employee ratio in Pakistan’s cities. You are required to answer the following:
 

§ What kind of software development (specialized technology) you want to start?

§ Write a plan that describes the purpose of your business, product, branding
approach, market audience and product competition

§ Mention city name and reason.

§ Starting Budget

§ Number of employees

Answers

Based on the information given, it can be deduced that the software development that will be started is web development.

Web development simply means the work that's involved in the development of a website for the internet. It's is the building of websites.

The target market will be companies especially start-ups that need a web developer to help them create websites. The starting budget will be about $300 with a cost of $100 to maintain it monthly.

Learn more about web development on:

https://brainly.com/question/25241318

Java Eclipse homework. I need help coding this

Project 5A - Mixed Results

package: proj5A
class: MixedResults

Create a new project called MixedResults with a class called Tester. Within the main method of Tester you will eventually printout the result of the following problems. However, you should first calculate by hand what you expect the answers to be. For example, in the parenthesis of the first problem, you should realize that strictly integer arithmetic is taking place that results in a value of 0 for the parenthesis.

double d1 = 37.9; //Initialize these variables at the top of your program
double d2 = 1004.128;
int i1 = 12;
int i2 = 18;

Problem 1: 57.2 * (i1 / i2) +1
Problem 2: 57.2 * ( (double)i1 / i2 ) + 1
Problem 3: 15 – i1 * ( d1 * 3) + 4
Problem 4: 15 – i1 * (int)( d1 * 3) + 4
Problem 5: 15 – i1 * ( (int)d1 * 3) + 4

Your printout should look like the following:

Problem 1: 1.0
Problem 2: 39.13333333333333
Problem 3: -1345.39999999999
Problem 4: -1337
Problem 5: -1313

Answers

Java clips homework I need help loading this create a new project called the mix results

Change the screen resolution so you can view more information on your screen. Use the resolution that enables you to fit the most information on the screen while still being able to read the display.

Use the space below to indicate your screen resolution and to describe the steps you used to do this.

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

My laptop's current screen resolution is (1366 by 768 recommended). When you change your screen resolution, your pc automatically suggests the recommended screen resolution that helps you to view more information on your screen and enable you to fit the most information on the screen while still being able to read the display.

To change the screen resolution, you need to go through from the following steps:

Right-click on empty space of desktop.As you right-click, a list of options will open, select "display setting" among themA new setting window will get open, at the left of the window, among given option, click on the first option i.e "display"The content of the display setting gets open in the right area of the window. scroll down and find the "Scale and Layout"under scale and layout, you can change your screen resolution while selecting the different screen resolution. However, it is good to select the recommended screen resolution based on your screen size.

Which of these parts serves as the rear cross structure of a vehicle?
Rear body panel
Rear bumper cover
Rear rails
Rear core support
ontents

Answers

Answer:

Rear bumper cover

Explanation:

special purpose computer​

Answers

Answer:

Special-purpose computers are designed for one specific task or class of tasks and wouldn't be able to perform general computing tasks. For example, a router is a special-purpose computer designed to move data around a network, while a general-purpose computer can be used for this task, as well as many others.

Help me with this digital Circuit please

Help me with this digital Circuit please
Help me with this digital Circuit please
Help me with this digital Circuit please
Help me with this digital Circuit please

Answers

A subset of electronics called digital circuits or digital electronics uses digital signals to carry out a variety of tasks and satisfy a range of needs.

Thus, These circuits receive input signals in digital form, which are expressed in binary form as 0s and 1s. Logical gates that carry out logical operations, including as AND, OR, NOT, NANAD, NOR, and XOR gates, are used in the construction of these circuits.

This format enables the circuit to change between states for exact output. The fundamental purpose of digital circuit systems is to address the shortcomings of analog systems, which are slower and may produce inaccurate output data.

On a single integrated circuit (IC), a number of logic gates are used to create a digital circuit. Any digital circuit's input consists of "0's" and "1's" in binary form. After processing raw digital data, a precise value is produced.

Thus, A subset of electronics called digital circuits or digital electronics uses digital signals to carry out a variety of tasks and satisfy a range of needs.

Learn more about Digital circuit, refer to the link:

https://brainly.com/question/24628790

#SPJ1

Other Questions
9) Identify the following as a physical property, physical change, chemical property, or chemical change:a) Ethanol has a density of 0.697 g/mL.b) The solution turns blue upon mixing water and food coloring.c) Wood burns in an oven.d) Methyl alcohol is highly flammable.e) Ice melts in a beaker.f) Methyl ethanoate smells like apples.g) A car crashes into a wall.h) Sugar dissolves in water. What is the optimal level of debt in a world with corporate taxes and no financial distress costs? What is another name for a back door that was accidentally left in a product by the manufacturer? Please help!Describe how life in cities at the turn of the century differed for wealthy and working class people. What mass, in milligrams, of carbon tetrachloride is present in a 55 gallon drum of the substance?Density of carbon tetrachloride is 1.492 g/mL. *Remember you have a conversion factor sheet and metric notes as well What are other clues a forensic anthropologist may be able to use to determine age if the bones belong to a person over age 25 prior to the supreme court ruling in tennessee v. garner, the use of deadly force by the police was governed by the ________ rule. how the gains made in women'seducation were related to the campaign for women's suffrage. How did these twomovements inspire each other over time? answer question plesase new concept english unit 17 propaganda Solve for x in the equation x2 + 4x-4-8.O x= -6 or x = 2O x=-2+2V2O x = -2 or x = 6O x=2+25 In what ways were the ideas introduced by European scientists and thinkers between the 1500s and 1700s revolutionary?Should include key people, events, and ideas of political thinkers and scientists in Europe during the 1500s, 1600s, and 1700s.-Cite evidence to support your position.-Organize your essay into an introduction, body, and conclusion.please i am very desperate i need help i will do anything please #7) Identify all pairs of congruent angles please helpHow many grams of barium sulfate are present in 250 of 2.0 M BaS04 solution? please help me on this simplify: 6 5/8 - 2 1/2A. 8 1/4 B. 8 1/8C. 4 1/4D. 4 1/8 What are these as equalivalent equations the nurse is explaining the joint commission's (tjc's) universal protocol for preventing wrong-site, wrong-procedure, and wrong-person surgery to a group of nursing students. the nurse explains that site marking involves which action? Rhombus find the measure of The pilgrim guide requests each pilgrim to tell what kind of stories?