Quick Sort Problem 122

Back to General discussions forum

avr_dude     2016-06-01 06:04:28

I am getting correct result for the example but i am not getting the correct result for test cases can someeone explain to me>

avr_dude     2016-06-01 06:13:06

0-123 0-108 0-90 0-45 0-22 0-3 0-2 1-2 5-22 5-15 5-14 5-11 7-11 8-11 9-11 9-10 13-14 17-22 19-22 19-21 19-20 24-45 24-32 24-30 24-25 27-30 29-30 34-45 34-35 37-45 37-40 39-40 42-45 44-45 47-90 47-84 47-70 47-55 47-51 49-51 49-50 53-55 57-70 57-61 59-61 63-70 63-69 63-65 64-65 67-69 68-69 72-84 72-80 72-76 73-76 73-75 74-75 78-80 82-84 86-90 86-88 92-108 92-100 93-100 93-98 94-98 95-98 95-97 95-96 102-108 102-105 102-103 107-108 110-123 112-123 112-116 114-116 115-116 118-123 118-121 120-121

0-123 0-108 0-90 0-58 0-24 0-3 2-3 5-24 5-12 5-11 5-10 6-10 6-9 6-7 14-24 16-24 17-24 17-22 17-20 18-20 19-20 26-58 26-54 27-54 27-28 30-54 30-32 34-54 34-52 34-48 34-42 34-41 35-41 35-37 36-37 39-41 39-40 44-48 44-47 44-46 45-46 50-52 50-51 56-58 60-90 60-68 60-64 62-64 63-64 66-68 70-90 70-85 70-72 71-72 74-85 74-78 76-78 76-77 80-85 81-85 83-85 87-90 87-88 92-108 92-107 92-99 92-98 94-98 96-98 96-97 101-107 101-105 101-104 103-104 110-123 112-123 112-121 114-121 114-116 114-115 118-121 120-121

avr_dude     2016-06-01 06:28:19

0-122 0-104 0-1 3-104 3-51 3-47 3-12 3-6 4-6 5-6 8-12 8-11 8-9 14-47 14-16 14-15 18-47 18-32 18-22 18-20 18-19 24-32 24-31 24-30 24-28 24-25 27-28 34-47 34-45 34-35 37-45 38-45 40-45 40-44 40-41 43-44 49-51 50-51 53-104 53-93 53-80 53-65 53-60 53-58 55-58 55-56 62-65 62-63 67-80 69-80 69-72 69-70 74-80 74-76 74-75 78-80 78-79 82-93 84-93 84-88 84-87 84-85 90-93 92-93 95-104 95-103 97-103 99-103 99-101 99-100 106-122 106-115 106-111 106-108 107-108 110-111 113-115 114-115 117-122 118-122 118-120

avr_dude     2016-06-01 06:28:31

0-122 0-104 0-1 3-104 3-17 3-14 3-4 6-14 6-9 6-7 11-14 13-14 16-17 19-104 19-60 19-20 22-60 22-40 22-36 22-29 24-29 25-29 25-28 26-28 27-28 31-36 31-32 34-36 38-40 39-40 42-60 42-57 43-57 43-52 43-45 43-44 47-52 47-50 47-48 54-57 56-57 59-60 62-104 62-99 62-80 62-70 62-63 65-70 65-69 65-67 66-67 72-80 73-80 73-75 74-75 77-80 78-80 82-99 82-94 84-94 84-90 84-86 84-85 88-90 88-89 92-94 96-99 96-98 97-98 101-104 101-103 106-122 106-113 106-107 109-113 109-112 109-110 115-122 117-122 119-122 120-122 120-121

avr_dude     2016-06-01 07:42:10

Someone pls help me i am frustrated of trying the result comes correect for 10 38 23 9 19 113 5 42 85 71 112 but not for the test cases..

pocketok     2018-01-30 08:52:13

Lomuto partition (from Cormen book) does not work, even if to pick leftmost element as pivot. It looks like sort of Hoare partition. Unfortunately, array is correctly sorted with quicksort, but task is not passed.

Quandray     2018-01-31 17:43:42
User avatar

You need to follow the algorithm and pseudocode given in the problem description (exactly). I may be wrong, but I don't think your code does that.

anneenna     2020-05-04 15:37:10

I'm stuck too. How to pick the left and right element during each first pass into the quicksort()?

Please login and solve 5 problems to be able to post at forum