Professional Documents
Culture Documents
20BRS1176 CSE2006 Exp3
20BRS1176 CSE2006 Exp3
Aim:
To sort an array in ascending and descending order and find the max and min elements of
that array
Tool Used:
Algorithm:
• Use the digits of your Aadhar Number and split it into groups of two, for the first 6 hex
numbers
• Use the digits of your reg no and split it to get the next 3 hex numbers
• Create two arrays one for ascending and the other for descending with the same elements
of ARRAY1
• Sort the Asc Array in Ascending order and print the first index of the array for the
minimum element
• Sort the Desc Array in Descending order and print the first index of the array for the
maximum element
Sample Input:
73H,94H,92H,73H,92H,65H,37H,49H,29H,37H,29H,56H,20H,11H,76H
Sample Output:
a. Ascending:
11,20,29,29,37,37,49,56,65,73,73,76 92,92,94
b. Descending:
94,92,92,76,73,73,65,56,49,37,37,29,29,20,11
c. Max Element:
94
d. Min Element:
11
Register No.: 20BRS1176 Name: George Mathew
Program:
DOWN:
INC SI
DEC CL
JNZ UP1
DEC CH
JNZ UP2
MOV CH,0EH
UP4:
MOV CL,0EH
LEA SI,DESC
UP3:
MOV AL,[SI]
MOV BL,[SI+1]
CMP AL,BL
JNC DOW
MOV DL,[SI+1]
XCHG [SI],DL
MOV [SI+1],DL
DOW:
INC SI
Register No.: 20BRS1176 Name: George Mathew
DEC CL
JNZ UP3
DEC CH
JNZ UP4
HLT
CODE ENDS
END START
Arrays:
Minimum Element:
Maximum Element:
Result:
Thus the following outputs and the answers are verified for the given inputs of the array.