Title: CSE 670 Winter 2004 Mid-Term examination
1CSE 670 Winter 2004Mid-Term examination
- Implementation of Bubble sort aglorithm
- By,
- Sumitha Nath .K.N
2Bubble sort algorithm
- for i n to 1
-
- for j 2 to i
-
- if aj-1 gt aj then
- temp aj-1
- aj-1 aj
- aj temp
- J
-
- i - -
3 case current_state is when s0gt
next_state lt s1 when s1 gt if iflag '1'
then next_state lt sdisp else next_state lt
s2 end if when s2 gt if jflag '1'
then next_state lt s9 else next_state lt
s3j end if when s3j gt next_state lt
s3j1 when s3j1 gt if chkflag '1'
then next_state lt s4 else next_state lt s8
end if when s4 gt next_state lt
s5 when s5 gt next_state lt s6 when s6
gt next_state lt s7 when s7 gt next_state lt
s8 when s8 gt next_state lt S2 when s9
gt next_state lt s1 when sdisp gt next_state
lt s0 end case
4- case current_state is
- when s0 gt
- loopclr lt '1'
- when s1 gt
- loopclr lt '0'
- when s2 gt
- null
- when s3j gt
- jload lt'1'
- when s3j1 gt
- addrsel lt '0'
- j1load lt '1'
- when s4 gt
- tload lt '1'
- when s5 gt
- wj1load lt '1'
- addrsel lt '0'
5- C1 process(current_state,dflag,sortdone,BTN4)
- begin
- case current_state is
- when swait gt
- if BTN4 '1' then
- next_state lt swait
- else
- next_state lt s0
- end if
-
- when s0gt
- if BTN4 '1' then
- next_state lt s1
- else
- next_state lt s0
- end if
-
6- C2 process(current_state)
- begin
-
-
- dinc lt '0'
- floaddisp lt '0'
-
-
- case current_state is
-
-
- when swait gt
- null
- when s0 gt
- null
- when s1 gt
- null
-