Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 2 : [4, 2, 1, 5, 7] / [4, 2, 1, 5, 7]
Advertisement
Detailed Solution
सही उत्तर [4, 2, 1, 5, 7] / [4, 2, 1, 5, 7] है।
Key Points
Helpful?
Question:
Using Lomuto partition with the last element as pivot, the array [4, 2, 7, 1, 5] after the first partition call is: / अंतिम तत्व को पिवट मानकर लोमुटो विभाजन से, पहले विभाजन कॉल के बाद ऐरे [4, 2, 7, 1, 5] है:
1.
[1, 2, 4, 5, 7] / [1, 2, 4, 5, 7]
2.
[4, 2, 1, 5, 7] / [4, 2, 1, 5, 7]
3.
[4, 2, 7, 1, 5] / [4, 2, 7, 1, 5]
4.
[2, 1, 4, 5, 7] / [2, 1, 4, 5, 7]
Correct Answer: [4, 2, 1, 5, 7] / [4, 2, 1, 5, 7]
Pivot = 5. Scanning left to right: 4 and 2 stay left of the boundary; 7 is skipped; 1 swaps with 7 → [4,2,1,7,5]; finally the pivot swaps into index 3 → [4,2,1,5,7]. / पिवट = 5। बाएँ से दाएँ स्कैन: 4 और 2 सीमा के बाएँ रहते हैं; 7 छूटता है; 1 की 7 से अदला-बदली → [4,2,1,7,5]; अंत में पिवट इंडेक्स 3 पर आता है → [4,2,1,5,7]।
Downloaded from PrepSnap (prepsnap.in)