Skip to content

Commit bdd5432

Browse files
committed
bubble sort
1 parent 36ef9dd commit bdd5432

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

src/z_lc_bubble_sort.prog.abap

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
*&---------------------------------------------------------------------*
2+
*& Report Z_LC_BUBBLE_SORT
3+
*&---------------------------------------------------------------------*
4+
*&
5+
*&---------------------------------------------------------------------*
6+
REPORT z_lc_bubble_sort.
7+
8+
9+
TYPES: tt_input TYPE STANDARD TABLE OF i WITH EMPTY KEY .
10+
11+
DATA: lt_input TYPE tt_input.
12+
13+
lt_input = VALUE #( ( 2 ) ( 6 ) ( 4 ) ( 1 ) ( 7 ) ) .
14+
15+
16+
DATA(lines) = lines( lt_input ).
17+
18+
19+
DO lines TIMES.
20+
DO lines - 1 TIMES.
21+
22+
IF lt_input[ sy-index ] > lt_input[ sy-index + 1 ] .
23+
24+
DATA(temp) = lt_input[ sy-index ].
25+
lt_input[ sy-index ] = lt_input[ sy-index + 1 ].
26+
lt_input[ sy-index + 1 ] = temp.
27+
28+
ENDIF.
29+
30+
ENDDO.
31+
ENDDO.
32+
33+
34+
LOOP AT lt_input ASSIGNING FIELD-SYMBOL(<lfs_input>).
35+
WRITE: / <lfs_input>.
36+
ENDLOOP.

src/z_lc_bubble_sort.prog.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<PROGDIR>
6+
<NAME>Z_LC_BUBBLE_SORT</NAME>
7+
<SUBC>1</SUBC>
8+
<RLOAD>E</RLOAD>
9+
<FIXPT>X</FIXPT>
10+
<UCCHECK>X</UCCHECK>
11+
</PROGDIR>
12+
<TPOOL>
13+
<item>
14+
<ID>R</ID>
15+
<ENTRY>Program Z_LC_BUBBLE_SORT</ENTRY>
16+
<LENGTH>24</LENGTH>
17+
</item>
18+
</TPOOL>
19+
</asx:values>
20+
</asx:abap>
21+
</abapGit>

src/z_lc_merge_sort.prog.abap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ FORM mergesort TABLES lt_array TYPE STANDARD TABLE .
4848
CHECK len_array > 1.
4949

5050
DATA(mid_array) = len_array DIV 2.
51-
* mid_array = mid_array + 1.
5251

5352
IF lt_array[] IS NOT INITIAL.
5453

0 commit comments

Comments
 (0)