Question: Find the error in the following python code: def partition ( array , low, high ) : pivot = array [ high ] i =
Find the error in the following python code:
def partitionarray low, high:
pivot arrayhigh
i low
for j in rangelow high:
if arrayj pivot:
i i
arrayi arrayjarrayj arrayi
arrayi arrayhigharrayhigh arrayi
return i
def quickSortarray low, high:
if low high:
pi partitionarray low, high
quickSortarray low, pi
quickSortarray pi high
# load data
data
with openptxtr as fin:
for line in fin:
data.appendintline
printUnsorted Array"
printlendata "items"
size lendata
quickSortdata size
duplicates
for i in range lendata:
if datai datai:
if i not in duplicates:
duplicatesi
else:
duplicatesi
countduplicates
for c in duplicates.values:
countduplicates c
printFound countduplicates, "duplicates"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
