Question 1 Consider the following segment of an algorithm: i = 1 Loop while (i < n) print("Hello World!") i - i * 3 Which one of the following options about the runtime R(n) is true? A. R(n) = 0(n³) B. R(n) = 0(log³n) C. R(n)= 0(3") D. R(n)= 0(log3 n) E. R(n) = 0(³√n) Question 2 Which of the following is NOT true? A. n2 € 0(n3) E B. log(n!) € O(n) C. log(n!) E (logn) D. 4¹ € 0(2) E. n² € (nlgn) Question 3 Suppose T is a binary search tree storing n entries. Which one of the following statements is true? A. Inserting into T is 0(1) in the best case and 0(log n) in the worst case. B. Inserting into T is 0(1) in the best case and 0(n) in the worst case. C. Inserting into T is 0(log n) in the best case and 0(log n) in the worst case. D. Inserting into T is 0(log n) in the best case and 0(n) in the worst case. E. Inserting into T is O(n) in the best case and 0(n) in the worst case.

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
Question 1
Consider the following segment of an algorithm:
i = 1
Loop while (i <n)
print("Hello World!")
i - i * 3
Which one of the following options about the runtime R(n) is true?
A. R(n) = 0(n³)
B. R(n)=
C. R(n) =
D. R(n) =
E. R(n) = (n)
(log³n)
☺ (3")
0(log3 n)
Question 2
Which of the following is NOT true?
A. n² € 0(³)
B. log(n!) € O(n)
C. log(n!) E (logn)
D. 4¹ € 0(2¹)
E. n² € (nlgn)
Question 3
Suppose T is a binary search tree storing n entries. Which one of the following statements
is true?
A. Inserting into T is 0(1) in the best case and 0(log n) in the worst case.
B. Inserting into T is 0(1) in the best case and 0(n) in the worst case.
C. Inserting into T is O(log n) in the best case and O(log n) in the worst case.
D. Inserting into T is 0(log n) in the best case and 0(n) in the worst case.
E. Inserting into T is O(n) in the best case and 0(n) in the worst case.
Transcribed Image Text:Question 1 Consider the following segment of an algorithm: i = 1 Loop while (i <n) print("Hello World!") i - i * 3 Which one of the following options about the runtime R(n) is true? A. R(n) = 0(n³) B. R(n)= C. R(n) = D. R(n) = E. R(n) = (n) (log³n) ☺ (3") 0(log3 n) Question 2 Which of the following is NOT true? A. n² € 0(³) B. log(n!) € O(n) C. log(n!) E (logn) D. 4¹ € 0(2¹) E. n² € (nlgn) Question 3 Suppose T is a binary search tree storing n entries. Which one of the following statements is true? A. Inserting into T is 0(1) in the best case and 0(log n) in the worst case. B. Inserting into T is 0(1) in the best case and 0(n) in the worst case. C. Inserting into T is O(log n) in the best case and O(log n) in the worst case. D. Inserting into T is 0(log n) in the best case and 0(n) in the worst case. E. Inserting into T is O(n) in the best case and 0(n) in the worst case.
Question 4
Given the recurrence relations T(n) = ₁
complexity in big-theta?
A. 0(√n log10 √n)
B. 0(n² log₂ n)
C. 0(√n log₂n)
D. (n¹og₂n)
E. (n log₂ √n)
Question 5
Consider a Queue ADT with the following standard operations: create Queue () and
enqueue (Queue Q, int x), and a Stack ADT with the similar standard operations: createStack(),
pushStack (Stack s, int n), and popStack (Stack S, int x) have been created. With the following
algorithm and data file:
) = √2T (²) + √ñ and T(1)=1, what is the run-time
Algorithm: DoSomething (String filename)
Q1 = createQueue ()
S1 = createStack()
Open filename
loop (not end of file)
read number
if (number not 0)
else
pushStack (S1, number)
popStack (S1, x)
popStack (S1, x)
loop (not empty S1)
popStack (S1, x)
enqueu (Q1, x)
end loop
end if
end loop
The data are 8, 30, 53, 14, 0, 66, 38, 19, 45, 29, 39, 7, 0, 29, 29, 8, 39, 18, 0
What would be the contents of queue Q1 after the above-describe code is executed
with the associated data file input to the algorithm?
A. 53, 30, 8, 39, 29, 45, 19, 38, 66, 39, 8, 29, 29
B. 30, 8, 29, 45, 19, 38, 66, 8, 29, 29
C. 53, 14, 19, 45, 29, 39, 7, 8, 39, 18
D. 8, 30, 33, 38, 19, 45, 29, 29, 8
E. 8, 30, 66, 38, 19, 45, 29, 29, 29,8
Transcribed Image Text:Question 4 Given the recurrence relations T(n) = ₁ complexity in big-theta? A. 0(√n log10 √n) B. 0(n² log₂ n) C. 0(√n log₂n) D. (n¹og₂n) E. (n log₂ √n) Question 5 Consider a Queue ADT with the following standard operations: create Queue () and enqueue (Queue Q, int x), and a Stack ADT with the similar standard operations: createStack(), pushStack (Stack s, int n), and popStack (Stack S, int x) have been created. With the following algorithm and data file: ) = √2T (²) + √ñ and T(1)=1, what is the run-time Algorithm: DoSomething (String filename) Q1 = createQueue () S1 = createStack() Open filename loop (not end of file) read number if (number not 0) else pushStack (S1, number) popStack (S1, x) popStack (S1, x) loop (not empty S1) popStack (S1, x) enqueu (Q1, x) end loop end if end loop The data are 8, 30, 53, 14, 0, 66, 38, 19, 45, 29, 39, 7, 0, 29, 29, 8, 39, 18, 0 What would be the contents of queue Q1 after the above-describe code is executed with the associated data file input to the algorithm? A. 53, 30, 8, 39, 29, 45, 19, 38, 66, 39, 8, 29, 29 B. 30, 8, 29, 45, 19, 38, 66, 8, 29, 29 C. 53, 14, 19, 45, 29, 39, 7, 8, 39, 18 D. 8, 30, 33, 38, 19, 45, 29, 29, 8 E. 8, 30, 66, 38, 19, 45, 29, 29, 29,8
Expert Solution
Step 1

As per Bartleby Experts guidelines, the first three questions are answered for you. To get the answers to the rest of the questions, please post those questions separately.

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Counting Sort
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
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