Hi, could you please tell me the big O notation of this function? Thanks!

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

Hi, could you please tell me the big O notation of this function? Thanks!

# takes in a stack as an argument
def sort (stack1);
]
]
]
]
stack2 = Stack()
stack3 = Stack()
stack2.push(stack1.pop())
for j in range (stack1.get_size()):
if stack1.peek() >= stack2.peek():
stack2.push(stack1.pop())
elif stack1.peek() <= stack2.peek ():
for k in range (stack2.get_size()):
if stack1.get_size() == 0:
print (stack2)
exit()
stack3.push(stack2.pop())
if stack2.get_size() > 0:
if stack1.peek() >= stack2.peek() and stack1.peek() <= stack3.peek():
else:
stack2.push(stack1.pop())
for r in range (stack3.get_size()):
return stack2
stack2.push(stack3.pop())
stack2.push(stack1.pop())
for r in range (stack3.get_size()):
stack2.push(stack3.pop())
for 1 in range (stack3.get_size()):
stack2.push(stack3.pop())
Transcribed Image Text:# takes in a stack as an argument def sort (stack1); ] ] ] ] stack2 = Stack() stack3 = Stack() stack2.push(stack1.pop()) for j in range (stack1.get_size()): if stack1.peek() >= stack2.peek(): stack2.push(stack1.pop()) elif stack1.peek() <= stack2.peek (): for k in range (stack2.get_size()): if stack1.get_size() == 0: print (stack2) exit() stack3.push(stack2.pop()) if stack2.get_size() > 0: if stack1.peek() >= stack2.peek() and stack1.peek() <= stack3.peek(): else: stack2.push(stack1.pop()) for r in range (stack3.get_size()): return stack2 stack2.push(stack3.pop()) stack2.push(stack1.pop()) for r in range (stack3.get_size()): stack2.push(stack3.pop()) for 1 in range (stack3.get_size()): stack2.push(stack3.pop())
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

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