Home /
Expert Answers /
Computer Science /
data-structure-python-nbsp-chapter-3-time-complexity-30-points-write-down-the-time-complexity-pa480
(Solved): data structure python Chapter 3 (Time Complexity) (30 points) Write down the time complexity ( ...
data structure python
Chapter 3 (Time Complexity) (30 points) Write down the time complexity (The big-O) of the following algorithms and show the time for each step like what we done in lecture: Algorithm def Function1(arr,n,x): for i in range(0, n): if (arr[i]-x) return i return-1 def Function2(ar): n-len(arr) for i in range(n): swapped-False for j in range(0, n-i-1) if arri]> anj+1]: am], arri+1]-arr[j+1], arr[j] swapped - True if swapped-False: break def binary search(arr, x): low -0 high-len(arr) - 1 mid-0 while low high mid (high+low) // 2 if arr[mid] x high-mid-1 else: return mid return-1 Chapter (5 and 6) Completity Question 1: (40 points) Implement a function with signature transfer(5, T) that transfers all elements from stack S onto stack T, so that the element that starts at the top of S is the top of stack T as well, and the element at the bottom of 5 ends up at the bottom of too Question 2: (30 points) Implement a function that reverses a list of elements of a stack (Hint: Use a queue)
Hey Please see the answer below and leave a comment if you require any help. ** don't forget to UPVOTE ** NOTE: COMMENT DOWN BELOW FOR ANY ERROR Chapter 3 (Time Complexity) Algorithm 1 def Function1(arr, x, n): for i in range(0, n): n+1 times if(arr[