Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Java help
1) see picture
2) Which of the following functions has the fastest order of growth in terms of n?
O(n²)
O(n²logn)
O(n(logn)^2)
O(nlogn)
3) Consider the following runtimes in terms of big-O notation:
1. O(nlogn)
II. O(n² + 3n + 1)
III. O(n² + (logn)20)
IV. O(n(logn)2)
Which of these runtimes is the fastest?
O(n/logn)
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Similar questions
- Q1. 5 and 6 subparts only if you do both then only I will provide upvotearrow_forwardWrite a function for given main functionint * return_an_array(int n)which takes an integer n and returns a pointer to an array (allocated off of the heap inthe function) containing the digits of n in the appropriate positions. If n = 0 return 0(which is the “null” pointer). Recall an array name is just a pointer to the first element ofthe array. Please use following main to test your function.int main() {int *a = return_an_array(23542); // array of size 5for(int i=0;i<5;i++)cout<<a[i]<<" "; // print 2 3 5 4 2cout<<endl;delete [] a;int *b = return_an_array(12345678); // array of size 8for(int i=0;i<8;i++)cout<<b[i]<<" "; // print 1 2 3 4 5 6 7 8cout<<endl;delete [] b;return 0;}arrow_forwardImplement a function ingredients in Python that takes a recipe and returns a dictionary of the ingredients needed. Details: accepts one multiline str argument containing a recipe each line of the recipe is either an instruction line or an ingredient line. The ingredient lines contain the character ':' , the instruction lines do not. instruction lines should be ignored ingredient lines will be structured like 'active dry yeast: 10g' . This breaks down as: an ingredient, e.g., 'active dry yeast' (can be multiple words) the character ':' followed by a space the quantity, e.g., '10g' , which will always be an integer (number of digits can vary) followed always by the letter 'g' ( for grams) note- that a particular ingredient may appear on more than one line, see sourdoughStarter below The function ingredients should output a dictionary: keys are ingredients each value is an int specifying the number grams of that ingredient used in the recipe if an ingredient appears on more than…arrow_forward
- q11) Find the time complexity for the program code and represent it in Big O notation. int p=3, q=5, r; for(int i=0;i<n;i++) { r= p * q * i; q++; } cout<<r; a. 1 b. O(log n) c. O( n ) d. O(n2)arrow_forwardbitcount: Given x, set y to the number of bits in x that are 1. Write the code in Java. Provided input(s): x Permitted: 40 operations (may use !, ~, +, -, <<, >>, &, ^, |) Hint: The obvious solution would be something like ans=0; for(int i=0; i<32; i+=1) { a += x&1; x >>=1; } We don’t allow for loops, but even if you replace it with 32 copies that’s still 96 operations, and we only allow 40 for this task. The trick is to do things in parallel, treating a number like a vector of smaller numbers. Suppose I wanted to count the bits of an 8-bit number with bits abcdefgh. With a little shifting and masking I could make three numbers 0b00e00h 0a00d00g 0000c00f and add them to get xx0yy0zz where xx = a+b, yy = c+d+e, and zz = f+g+h. Extending this trick to several rounds on 32 bits will solve this problem.arrow_forwardQuestion 4 a) Explain, with an example, how the use of multithreading enables a program to run faster. Use pseudocode or actual code to illustrate your answer. b) The following is non-concurrent code for working out the cosine of a sequence of integers. Rewrite this in Python so that it is concurrent. Your program must return the results in the order of the input sequence. This code is available with this TCA as Q4.zip. import math values = [12,20,4,100,64,77,200,9,10] def mycosine (n) : woonwww. return math.cos(n) ww wwwwwwww def non concurrent cosines(): wwwww for val in values: wwwww res = mycosine (val) wwwww print('Cosine of %s is %s' % (val,res), '\n') non concurrent cosines () wwwwww c) Use Python's datetime function to time the execution of the concurrent code, and to print out the result. Add the lines of code that support this to your solution to Question 4 (b).arrow_forward
- Write a parallel program for the following code /* PROGRAM Sieve */ #include <stdlib.h> #include <math.h> #define n 100 boolean Prime[n+1]; int i,num,loc; main( ) { for (i = 1; i <= n; i++) Prime[i] = TRUE; for (num = 2; num <= Sqrt(n); num++) if (Prime[num]) { loc = num + num; while (loc <= n) { Prime[loc] = False; } } loc = loc + num; }arrow_forwardFor each of the following function, indicate the class (n) the function belongs (use the simplest g (n) possible in your answer. a) (n² + 5)1⁰ c) 5n+3 + 7+1 b) 4nlog2(n+2)² + (n+2)³log2(n/2) d) 2n + 3n+ n²+ 4narrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education