We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

www.vustudents.ning.com

 www.bit.ly/vucodes + Link For Assignments, GDBs & Online Quizzes Solution www.bit.ly/papersvu + Link For Past Papers, Solved MCQs, Short Notes & More

# CS401 Assignment No 02 Spring 2019 Solution & Discussion Due Date: 30-05-2019

CS401 Assignment No 02 Spring 2019 Solution & Discussion Due Date: 30-05-2019

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

Views: 4398

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

### Replies to This Discussion

here goes the solution. make sure you change the if to represent your vu id instead of this one found in the file.

id kahan likhni

Bhai jan ye bubble sort h g selection sort nhi h.

Cs401
[org 0x0100]
jmp start

data: dw 1,2,3,4,5,6,7,8,9
swap: db 0

start: mov bx,0 ;intialize array index to zero
mov byte [swap], 0 ;rest swap flag to noswap

loop1: mov ax, [data+bx] ;load in number in ax
cmp ax, [data+bx+2] ;compare with next number

jbe noswap ;no swap if already in order

mov dx, [data+bx+2] ;load second number in first
mov [data+bx+2], ax ;store first number in second
mov [data+bx], dx ;store second number in first
mov byte [swap], 1 ;flag that a swap has been done

cmp bx, 18 ;are we at last index

jne loop1 ;if not compare next two

cmp byte [swap],1 ;check if swap has been done

je start ;if yes make another pass

mov ax, 0x4c00 ;terminate program
int 0x21

; sorting a list of number using selection sort; sorting a list of number using selection sort
[org 0x0100] jmp startdata: dw 6,5,5,0,5,5,3,1,7 yaha apni id likhni haswap: db 0start: mov; 0 ;initialize array index to zeromov byte [swap],0 ;reset swap flag to no swaps
loop1: mov ax, [data+bx] ;load number in axcmp ax, [data+bx+2] ;compare with next numberjbe noswap ;no swap if already in order
mov dx, [data+bx+2] ;load second element in dxmov [data+bx+2], ax ;store first number in secondmov [data+bx], dx ;store second number in firstmov btye [swap], 1 ;flag that a swap has been down
noswap:add bx,2 ;advance bx to next indexcmp bx, 18 ;are we at last indexjne loop1 :if not compare next two
cmp btye[swap],1 ;check if a swap has been doneje start ;if yes make another passmov ax,0x4c00 ;terminate programint 0x21

## Latest Activity

Think totally different updated their profile
9 minutes ago
+ M.Tariq Malik's 4 discussions were featured
20 minutes ago
27 minutes ago
27 minutes ago
27 minutes ago
+ "αяsαℓ " Ќąƶµяɨ •" liked ☑ Steve's discussion When a woman says, "What" ?
27 minutes ago
27 minutes ago
+ "αяsαℓ " Ќąƶµяɨ •" liked 2.O's discussion Admission in Medical College :P :P
28 minutes ago

1

2

3