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"
Contents of ptxt:
