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 partition(array, low, high):
pivot = array[high]
i = low -1
for j in range(low, high):
if array[j]<= pivot:
i = i +1
(array[i], array[j])=(array[j], array[i])
(array[i +1], array[high])=(array[high], array[i +1])
return i +1
def quickSort(array, low, high):
if low < high:
pi = partition(array, low, high)
quickSort(array, low, pi -1)
quickSort(array, pi +1, high)
# load data
data =[]
with open("p2.txt",'r') as fin:
for line in fin:
data.append(int(line))
print("Unsorted Array")
print(len(data), "items")
size = len(data)
quickSort(data,0, size -1)
duplicates ={}
for i in range(0, len(data)):
if data[i]== data[i+1]:
if i not in duplicates:
duplicates[i]=1
else:
duplicates[i]+=1
count_duplicates =0
for c in duplicates.values():
count_duplicates += c
print("Found", count_duplicates, "duplicates")
Contents of p2.txt:
19820
49808
74309
82989
26476
14091
12214
62806
80587
49769
75816
74319
95833
75118
76196
69354
61973
46903
63422
36932
22232
74085
91536
18263
51412
82131
32530
59328
18596
78231
49539
4670
21953
99122
65913
6516
41773
32747
21004
25220
96067
13284
45605
98932
62543
92506
72792
33932
72112
78483
4271
12297
46572
1179
86068
82600
81346
54332
16727
21063
15867
96013
78582
52375
70731
91390
22364
35743
86908
40926
37749
2389
20460
89738
93252
29202
12779
27079
56117
22269
10757
86610
73409
85830
71135
44048
66978
51987
16500
55403
24630
94272
57914
10715
17374
68514
17227
23191
92146
30327
94282
90982
51951
28327
41175
47910
3155
20792
26204
5228
34486
30591
76982
75504
71415
8650
47776
4423
31891
64544
85713
50070
14689
53588
19727
79113
84261
92018
93745
90181
19227
54326
28873
56988
55377
39256
24112
99986
11881
14991
3627
32945
87926
4307
38058
81709
20670
32004
88446
18822
70789
49852
98217
5499
66418
11385
87116
31717
41437
76611
35994
59280
35967
26044
51695
5196
38440
25552
90448
65915
44436
77284
80997
17200
63773
34156
45563
65261
93532
82550
67033
96986
70316
50044
55440
40683
97663
81167
21504
56651
47791
96738
53170
12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!