Need help for Data Structure Hw: 1. Which of the list operations shown below is
ID: 3882124 • Letter: N
Question
Need help for Data Structure Hw:
1. Which of the list operations shown below is not O(1)?
-list.pop(0)
- list.pop()
-list.append()
-list(10)
2. Which of the dictionary operations shown below is O(n)?
mydict2 = mydict.copy()
3. Give the Big-O performance of the following code fragment:
if 'alice' in x: # x is a list
print('yes')
On^3)
4.Give the Big-O performance of the following code fragment: x is a list
x.insert(2,'bye')
-O(n^3)
5. Give the Big-O performance of the following code fragment:
x = [1,2,3,4,5,6,7,8,9,10,11]
y = [4,5,6,7,5]
x[:3] = y[:3]
- 'x' in mydictExplanation / Answer
Please find my answer.
Q1 ANs: list(10)
It takes n times
Q2. Ans: del mydict['x']
Q3.
Ans: O(n). search operation takes O(n) in list
Q4.
ANs: O(n)
Q5.
O(n+k)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.