1. Order the following functions by asymptotic growth rate in ascending order. 4nlogn+2n 2^10 2^log n 3n+1001og n 4n 2^n n^2+10n 3n^2+2n+31ogn+3 n^3 nlog n

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please answer everything

1. Order the following functions by asymptotic growth rate in ascending order.
4nlogn+2n
2^10
2^log n
3n+100log n
4n
2^n
n^2+10n
3n^2+2n+3logn+3
n^3.
nlog n
2. Find the running time in terms of the variable for the following code. Show your answer in
Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!)
int foo(int k) {
int cost;
for
}
(int i = 0; i < k; i++)
cost = cost + (i * k);
return cost;
answ=foo (n);
3. Find the running time in terms of the variable for the following code. Show your answer in
Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!)
public static void fun (int n) {
int count = 0;
for (int i = n / 2; i < n; i++) {
int j = 1;
while (j + n/2 <= n) {
int k = 1;
while (k <= n) {
}
4. Find the running time in terms of the variable for the following code. Show your answer in
Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!)
public static void function (int n) {
int count = 0;
for (int i = n / 2; i<n; i++) {
j = j + 1;
System.out.println (count);
else:
count = count + 1;
k = k * 2;
int j = 1;
while (j + n/2 <= n) {
break;
}
j = j + 2;
System.out.println (count);
5. Find the running time in terms of the variable for the following code. Show your answer in
Big-O notation. Show the individual running time for each loop and the overall running time.
Explain why and show your work (don't just say "because of the rule". Prove it!)
public static void function (int n) {
for (int i = 0; i <n / 3; i++) {
int j = 1;
while (j <= n) {
6. Find the space complexity for the following code. Show your answer in Big-O notation.
Explain why and show your work (don't just say "because of the rule". Prove it!)
def binary_search (arr, x):
low = 0
high len (arr) - 1
while low <= high:
mid (low + high) // 2
if arr [mid] == x:
return mid
elif arr [mid] < x:
low mid + 1
j = j + 4;
System.out.println ("*") ;
def allocate (n):
high mid - 1
return array
return -1
7. Find the space complexity for the following code. Show your answer in Big-O notation.
Explain why and show your work (don't just say "because of the rule". Prove it!)
array [0] * n
for i in range (n) :
array [i] =i + 1
Transcribed Image Text:1. Order the following functions by asymptotic growth rate in ascending order. 4nlogn+2n 2^10 2^log n 3n+100log n 4n 2^n n^2+10n 3n^2+2n+3logn+3 n^3. nlog n 2. Find the running time in terms of the variable for the following code. Show your answer in Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!) int foo(int k) { int cost; for } (int i = 0; i < k; i++) cost = cost + (i * k); return cost; answ=foo (n); 3. Find the running time in terms of the variable for the following code. Show your answer in Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!) public static void fun (int n) { int count = 0; for (int i = n / 2; i < n; i++) { int j = 1; while (j + n/2 <= n) { int k = 1; while (k <= n) { } 4. Find the running time in terms of the variable for the following code. Show your answer in Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!) public static void function (int n) { int count = 0; for (int i = n / 2; i<n; i++) { j = j + 1; System.out.println (count); else: count = count + 1; k = k * 2; int j = 1; while (j + n/2 <= n) { break; } j = j + 2; System.out.println (count); 5. Find the running time in terms of the variable for the following code. Show your answer in Big-O notation. Show the individual running time for each loop and the overall running time. Explain why and show your work (don't just say "because of the rule". Prove it!) public static void function (int n) { for (int i = 0; i <n / 3; i++) { int j = 1; while (j <= n) { 6. Find the space complexity for the following code. Show your answer in Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!) def binary_search (arr, x): low = 0 high len (arr) - 1 while low <= high: mid (low + high) // 2 if arr [mid] == x: return mid elif arr [mid] < x: low mid + 1 j = j + 4; System.out.println ("*") ; def allocate (n): high mid - 1 return array return -1 7. Find the space complexity for the following code. Show your answer in Big-O notation. Explain why and show your work (don't just say "because of the rule". Prove it!) array [0] * n for i in range (n) : array [i] =i + 1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Public key encryption
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education