'n' वस्तुओं की दी गयी सूची के सॉर्टिंग के लिए बबल सॉर्ट एल्गोरिथ्म को कितने मार्गों की आवश्यकता होती है?

This question was previously asked in
ESE Electronics 2011 Paper 2: Official Paper
View all UPSC IES Papers >
  1. n2
  2. √n
  3. n + 1
  4. n - 1

Answer (Detailed Solution Below)

Option 4 : n - 1
Free
ST 1: UPSC ESE (IES) Civil - Building Materials
6.2 K Users
20 Questions 40 Marks 24 Mins

Detailed Solution

Download Solution PDF

संकल्पना:

बबल सॉर्ट:

यह सबसे सरल सॉर्टिंग एल्गोरिथ्म है जो निकटवर्ती तत्वों के गलत क्रम में होने पर उन्हें बार-बार बदलकर काम करता है।

निकटवर्ती तत्वों की तुलना करने पर, यदि कोई बड़ा हो तो, परिवर्तित कीजिए।

उदाहरण- माना कि i / p, 70, 20, 35, 90, 15, 11, 24 है।

तत्वों की संख्या (n) = 7

मार्ग – 1: 20, 35, 70, 15, 11, 24, } 90 → 6 तुलना

मार्ग – 2: 20, 35, 15, 11, 24, } 70, 90 → 5 तुलना

मार्ग – 3: 20, 15, 11, 24, } 35, 70, 90 → 4 तुलना

मार्ग – 4: 15, 11, 20, } 24, 35, 70, 90 → 3 तुलना

मार्ग – 5: 11, 15, } 20, 24, 35, 70, 90 → 2 तुलना

मार्ग – 6: 11, 15, 20, 24, 35, 70, 90 → 1 तुलना

मार्गो की संख्या = 6

सूचना: n तत्वों वाले बबल सॉर्ट को n - 1 मार्गो की आवश्यकता है।

कुल तुलना: \(\frac{{\left( {n - 1} \right)n}}{2}\)

Latest UPSC IES Updates

Last updated on May 28, 2025

->  UPSC ESE admit card 2025 for the prelims exam has been released. 

-> The UPSC IES Prelims 2025 will be held on 8th June 2025.

-> The selection process includes a Prelims and a Mains Examination, followed by a Personality Test/Interview.

-> Candidates should attempt the UPSC IES mock tests to increase their efficiency. The UPSC IES previous year papers can be downloaded here.

More Sorting Questions

More Searching, Sorting and Hashing Questions

Get Free Access Now
Hot Links: all teen patti teen patti master golden india teen patti gold new version 2024 teen patti game teen patti bonus