<prompt> Kuandika algorithm ya kupanga idadi katika safu kutoka juu hadi chini.3, 9, 8, 5, 1, 11  <response>: Hapa ni algorithm ambayo itakuwa kuchagua safu ya idadi kutoka juu hadi chini kwa kutumia njia ya kuandaa Bubble: 1. Kuanza kwa kuweka variable n sawa na urefu wa safu ya input. 2. Kujenga kitanzi ambayo itakuwa iterate n-1 mara. Unaweza kutumia kitanzi kwa ajili ya iterate variable i kuanza kutoka 0 na kwenda juu hadi n-1. 3. Ndani ya kitanzi hii, kujenga nyingine kitanzi na variable j kuanzia 0 na kwenda juu hadi n-1. 4. Ndani ya kitanzi ndani, kulinganisha thamani ya j-wa pili wa safu na thamani ya kipengele ijayo j1-th. Kama thamani ya kipengele cha j-wa pili ni ndogo kuliko thamani ya j-1-wa pili, kisha kubadilishana. 5. Kuendelea kubadilisha kitanzi: kuunda variable nnjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj 