for i in range(n): Fa() for i in range(1+1): ACE CC for k in range(n): Fa() Fb()Intermal ONLY a) Based on the given code fragment above, suppose function Fa() roquires only one unit of time and function Fb() also requires three units of time to be exccuted. Find the time complexity T(n) of the Python code segment above, where n is the size of the input data. Clearly show your steps and show your resalt in polynomial form, [3 marks) b) Given complexity function f(n) - AB.n + B.n + A.n + B'A" where A and B are positive integer constants, use the definition of Big-O to prove f(n)-0(n). Clearly show the steps of your proof arinion, moi properties of Big-0) Private, Intermal ONLYmoras O Copyright HKÜ 3/6 c) Given a Python Queue class implemented with abstract data type below, write a new method engF(), which will "enqueue" (insert) a new element at the Front end of the queue. Operation (Queue) Description init_(): sizeQ():int GIVEN: Create a new cmpty queue of the class Queue GIVEN: retum the size (number of elements) of Queue enqueue(elt): GIVEN: Insert elt into Queue dequeue():elt GIVEN: Remove (and returm) element from Queue engF(elt): • Finish this new Python engF() method, by completing the method body below: def engF( self, elt ): # "Enqueue" at the Front end * body of the method. TO BE COMPLETED by student "Enqueue" (insert) a new element at the -Front" end of the Queue • Use the given methods / operations of the class to complete the task. O Elements in the queue object must be accessed by the queue itself only. Do not use other Python types (including Python's 1ist) to access them. No more than 6 lines of typical python code (without semicolon symbol ;) allowed in the method body. Copy [6 marks)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Learner Portal (LP) - HKU SPACE
Course: Introduction to Data Stru X
idsa_ETA_2021s2_Qc (1).pdf
+
PDF
File | C:/Users/Gurung%20Utshb/Downloads/idsa_ETA_2021s2_Qc%20(1).pdf
+
В2. (15 тarks)
n range(n):right ©
PACE CC
Given Python Code:
for i in range (n):
Fa()
for j in range(i+1):
for k in range(n):
Fa()
a) Based on the given code fragment above, suppose function Fa() requires only one unit of
time and function Fb() also requires three units of time to be executed.
Find the time
complexity T(n) of the Python code segment above, where n is the size of the input data.
Clearly show your steps and show your result in polynomial form.
[3 marks]
b) Given complexity function f (n) = AB.n® + B.n + A.nA+B + BAAB where A and B are
positive integer constants, use the definition of Big-O to prove f (n)=0(nA+B). Clearly
show the steps of your proof. (* Use definition, not properties of Big-O.)
Private, Internal ONLYomures
Copyright
HKUS
[6 marks]
3/6
c) Given a Python Queue class implemented with abstract data type below, write a new
method enqF(), which will "enqueue" (insert) a new element at the Front end of the queue.
Operation (Queue) Description
_init_():
GIVEN: Create a new empty queue of the class Queue
sizeQ():int
GIVEN: return the size (number of elements) of Queue
enqueue(elt):
GIVEN: Insert elt into Queue
dequeue ():elt
GIVEN: Remove (and return) element from Queue
enqF(elt):
"Enqueue" (insert) a new element at the “Front" end of the Queue
Finish this new Python enqF() method, by completing the method body below:
P def enqF( self, elt ):
# "Enqueue" at the Front end
# body of the method. TO BE COMPLETED by student
Use the given methods / operations of the class to complete the task.
Elements in the queue object must be accessed by the queue itself only. Do not use other
Python types (including Python's list)to access them.
No more than 6 lines of typical python code (without semicolon symbol ;) allowed in the
method body.
O Copyright
[6 marks]
2:37 pm
O Type here to search
L
27°C
O G (x ENG
7/5/2022
Transcribed Image Text:Learner Portal (LP) - HKU SPACE Course: Introduction to Data Stru X idsa_ETA_2021s2_Qc (1).pdf + PDF File | C:/Users/Gurung%20Utshb/Downloads/idsa_ETA_2021s2_Qc%20(1).pdf + В2. (15 тarks) n range(n):right © PACE CC Given Python Code: for i in range (n): Fa() for j in range(i+1): for k in range(n): Fa() a) Based on the given code fragment above, suppose function Fa() requires only one unit of time and function Fb() also requires three units of time to be executed. Find the time complexity T(n) of the Python code segment above, where n is the size of the input data. Clearly show your steps and show your result in polynomial form. [3 marks] b) Given complexity function f (n) = AB.n® + B.n + A.nA+B + BAAB where A and B are positive integer constants, use the definition of Big-O to prove f (n)=0(nA+B). Clearly show the steps of your proof. (* Use definition, not properties of Big-O.) Private, Internal ONLYomures Copyright HKUS [6 marks] 3/6 c) Given a Python Queue class implemented with abstract data type below, write a new method enqF(), which will "enqueue" (insert) a new element at the Front end of the queue. Operation (Queue) Description _init_(): GIVEN: Create a new empty queue of the class Queue sizeQ():int GIVEN: return the size (number of elements) of Queue enqueue(elt): GIVEN: Insert elt into Queue dequeue ():elt GIVEN: Remove (and return) element from Queue enqF(elt): "Enqueue" (insert) a new element at the “Front" end of the Queue Finish this new Python enqF() method, by completing the method body below: P def enqF( self, elt ): # "Enqueue" at the Front end # body of the method. TO BE COMPLETED by student Use the given methods / operations of the class to complete the task. Elements in the queue object must be accessed by the queue itself only. Do not use other Python types (including Python's list)to access them. No more than 6 lines of typical python code (without semicolon symbol ;) allowed in the method body. O Copyright [6 marks] 2:37 pm O Type here to search L 27°C O G (x ENG 7/5/2022
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY