0 votes 0 votes Should not there be a second condition stating i = j-1 in While loop's conditional statement,if not then it seems to me while loop will be a infinite loop.. Algorithms discrete-mathematics algorithms sorting + – souren asked Jun 12, 2019 • recategorized Jul 6, 2022 by Lakshman Bhaiya souren 1.0k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply ankitgupta.1729 commented Jun 13, 2019 reply Follow Share @souren I am not getting any infinite loop here. Can you please give me any sample input for which given pseudocode is going in infinite loop.. 0 votes 0 votes souren commented Jun 13, 2019 reply Follow Share Let,for j = 7 $^{a_{7}}> ^{a_{1}} ; ^{a_{7}}> ^{a_{2}}; ..... ^{a_{7}}> ^{a_{8}}; ^{a_{7}}> ^{a_{9}}$.... consequently for i=1,2...8,9.. and will continue forever if there is no limiting case of i in while loop's condition and j is the highest element in the whole sequence.. 0 votes 0 votes ankitgupta.1729 commented Jun 13, 2019 reply Follow Share @souren it will be broken when $a_7 > a_7$.. right? Please give any example of randomly arranged elements where it goes into infinite loop.. 1 votes 1 votes souren commented Jun 13, 2019 reply Follow Share Oh..Sorry @ankit,i missed that.. Thank you @ankit for pointing out my faults.. 1 votes 1 votes Please log in or register to add a comment.