This preview shows pages 1–2. Sign up to view the full content.
Appendix B
Explanation :
•
Consider that a block of N words is present. Now we have to arrange these N words in
ascending order, Let N = 4 for example. We will use SI as pointer to point the block of N
words.
•
Initially in the first iteration we compare first number with the second number. If first
number < second number, don’t interchange the contents, otherwise if first number >
second number swap the contents.
•
In the next iteration we go on comparing the first number with third number. If first
number < third number, don’t interchange the contents. If first number > third number
then swaping will be done.
•
Since the first two numbers are in ascending order the third number will go to first place,
first number in second place and second number will come in third place in the second
iteration only if first number > third number.
•
In the next iteration first number is compared with fourth number. So on comparisions are
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
 Spring '11
 Lucky

Click to edit the document details