1
QB64 Discussion / Array_Intersection
« on: March 04, 2019, 10:43:03 am »
I am trying to find the best way to write a subroutine of Array Intersection
I tried 3 methods.
- a sequential method (18 seconds)
- a dichotomous search method ( 9 seconds)
-and finally I learn or I try to understand how to use the SMcNeill tools and so I wrote a routine with the use of _MEM. It's difficult for me because I do not understand all the subtleties of the English language and even less those of the language "Basic" (12 seconds)
These tables are already sorted
I thought the 3rd method (with _Mem) would be faster, but no.
I think I have to make mistakes in using these instructions
Thank you in advance for your advice
[ You are not allowed to view this attachment ] [ You are not allowed to view this attachment ] [ You are not allowed to view this attachment ]
I tried 3 methods.
- a sequential method (18 seconds)
- a dichotomous search method ( 9 seconds)
-and finally I learn or I try to understand how to use the SMcNeill tools and so I wrote a routine with the use of _MEM. It's difficult for me because I do not understand all the subtleties of the English language and even less those of the language "Basic" (12 seconds)
These tables are already sorted
I thought the 3rd method (with _Mem) would be faster, but no.
I think I have to make mistakes in using these instructions
Thank you in advance for your advice
Code: QB64: [Select]
- '$INCLUDE:'SET.BI'
- Read_tables
- 'MemSortSome ma, 0, 19
- 'MemSortSome mb, 0, 9
- Intersec_sequentiel:
- REM calcul intersection_Array methode sequentielle
- PRINT "1 - Intersection_array methode sequentielle"
- PRINT "wait about 20 seconds...."
- commun# = 0
- repet = 0
- k = 0: ll% = 0
- i = 0
- j = 0
- j = j + 1
- i = i + 1
- result(ll%) = result(ll%) + 1
- ll% = 0
- k = k + 1
- repet = repet + 1
- PRINT "Press a Key to continue"
- Intersec_dicho:
- PRINT "2 - Calcul Array_Intersection dichotomie "
- PRINT "wait about 20 seconds...."
- commun# = 0
- repet = 0
- k = 0: ll% = 0
- 'MemSortSome mc, 0, 19 (gain 9 seconds)
- i = 0
- inf% = 0: sup% = 19
- RechercheCombi:
- existepas:
- i = i + 1
- result(ll%) = result(ll%) + 1
- ll% = 0
- k = k + 1
- repet = repet + 1
- intersec_mem:
- PRINT "Calcul Array_Intersection with _mem "
- PRINT "wait about 20 seconds...."
- commun# = 0
- repet = 0
- k = 0: ll% = 0
- 'MemSortSome mc, 0, 19 (gain 9 seconds)
- kk% = 0
- index% = BinaryMemSearchSome(b(kk%), mc, 0, 19)
- kk% = kk% + 1
- result(ll%) = result(ll%) + 1
- ll% = 0
- k = k + 1
- repet = repet + 1
- SUB Read_tables
- NEXT j
- NEXT i
- NEXT j
- '$INCLUDE:'SET.BM'
[ You are not allowed to view this attachment ] [ You are not allowed to view this attachment ] [ You are not allowed to view this attachment ]