What is the big-o run-time of the c++ function

Assignment Help C/C++ Programming
Reference no: EM13833050

1. What is the big-O run-time of the following C++ function. It can be assumed that rand() runs in constant time (Show your work):

template <typename T>

void Foo (T a r r [ ] , int n)

{

for ( int i = n - 1 ; i > 0 ; --i )

{

int j = rand ( ) % i ;

T tmp = a r r [ j ] ;

a r r [ j ] = a r r [ i ] ;

a r r [ i ] = tmp ;

}
}

2. What is the big-O run-time of the following C++ function (Show your work):

template <typename T>

void Baz (T ar r , int n)

{

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

{

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

a r r [ i ] [ j ] = 0 ;

}

}

Reference no: EM13833050

Questions Cloud

Comprehensive functional behavioral assessment report : Develop and outline a comprehensive Functional Behavioral Assessment Report. The specific objective of your Functional Behavioral Assessment Report is to demonstrate synthesis of the course material related to FBA's as they have been presented in ..
Calculated field query and define a new field timespent : Calculated field query with table JOIN: Find the ticket numbers and the users submitted the tickets, for those tickets that take more than 5 days to resolve, define a new field TimeSpent, which is the time resolved minus the time ticket was submit..
Which term is used to describe these characteristics : Rita's mental representation for Halloween includes knowledge, beliefs, and expectations. Which term is used to describe these characteristics
Determine prevalence of clinical needamong adolescents : What is the level of agreement between a normative (clinical) assessment and a self-perception of orthodontic treatment need - The descriptive statistics and one regression model.
What is the big-o run-time of the c++ function : What is the big-O run-time of the following C++ function
What do you think should be required to obtain that license : If a license was required to become a parent, as suggest by David Lykken, what do you think should be required to obtain that license
Sports beverages should ideally contain : Sports beverages should ideally contain
Explain how would you define the term family and why : Explain how would you define the term "family" and why? Be sure to list the key elements necessary for a social group to be defined as a "family
Write a java application that calculates the internet cost : Write a java application that calculates and displays the internet cost and GST (10% Goods & Services Tax) for N customers. N should be declared as a constant and it should be equal to the largest digit of your student ID number.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a c++ program to grade multiple-choice

Write a C++ program to grade multiple-choice, including True/False, questions for an exam given in a class. A class may have one or more sections.

  An arithmetic expression

The statements of that expression language consist of an arithmetic expression followed by a list of assignments. Assignments are separated from the expression and each other by commas. A semicolon terminates the expression. The arithmetic expr..

  Write a function that accepts an int array

Element 0 of the argument arrayshould be copied to element 1 of the new array, element 1 of the argument array should be copied to element 2 of the new array, and so forth. The function shouldreturn a pointer to the new array.

  Demonstrate the construction and output of an array

In fluid mechanics, the Reynolds number (Re) is a dimensionless quantity that is used to help predict similar flow patterns in different fluid flow situations. For example, Reynolds numbers can be computed for different velocities of fluid flow over ..

  Wrie a program that will generate a list of 10000 numbers

Wrie a program that will generate a list of 10000 numbers stored in an array with values 1 and 500.Print out any original 200 numbers to show the results(not one number per line either).Now sort the number using bubble sort

  When constructors and destructors are called

Objects, constructors and destructors are called each time the objects Enter and leave scope and inherit parent class

  Linked list with first node pointer p.

Complete the code for a function that replaces each occurrence of value x by value y in a linked list with first node pointer p.

  Write a set of nested loops that display 10 rows

Write a set of nested loops that display 10 rows of # characters. There should be 15 # characters in each row.

  Display money using proper formatting

Have you ever been low on cash and couldn't go beyond a certain dollar limit when shopping? You sort of need a calculator in your head.

  Create a graphical calculator with buttons that can add

create a graphical calculator with buttons that can add subtract multiply divide - sin cos tan clear and modulus.write

  Write an application that can hold five integers in an array

Write an application that can hold five integers in an array. Display the integers fromfirst to last, and then display the integers from last to first.

  Explain how to convert c program to mips program

Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3 already.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd