LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Naive Algorithm for Pattern Searching

Solved!
Go to solution

Is anyone doing this in LabVIEW?


https://www.geeksforgeeks.org/naive-algorithm-for-pattern-searching/

just curious. 

0 Kudos
Message 1 of 11
(406 Views)
Solution
Accepted by topic author _Phobos

Use the "Match Pattern" primitive.

Naive Search.png

Basjong53_0-1742928271910.png

0 Kudos
Message 2 of 11
(379 Views)

Just another possibility....

 

altenbach_0-1742930710519.png

Message 3 of 11
(365 Views)

 

alexderjuengere_0-1742932888245.png

 

i overlooked (n-m) +1 ... 🙈

0 Kudos
Message 4 of 11
(348 Views)

That works! Thank you!

0 Kudos
Message 5 of 11
(305 Views)

I have a couple questions. If LabVIEW is zero indexed, I understand why the last search result is 12. What about 9, the second search result? Shouldn’t the output be 0,8,12 if LabVIEW is zero indexed?

 

The original GeeksForGeeks example output is: 0,9,13. 

0 Kudos
Message 6 of 11
(253 Views)

Maybe there’s a typo in the generated output? The original “calculated” output is 0,9,12.  

0 Kudos
Message 7 of 11
(250 Views)

@_Phobos  ha scritto:

I have a couple questions. If LabVIEW is zero indexed, I understand why the last search result is 12. What about 9, the second search result? Shouldn’t the output be 0,8,12 if LabVIEW is zero indexed?

 

The original GeeksForGeeks example output is: 0,9,13. 


 
 

Basjong53_2-1743174991329.png

Your example is also 0-indexed. With the found indices at 0, 9 and 12. Why do you think the second index should be 8?

 

0 Kudos
Message 8 of 11
(192 Views)

Look further down the page. The Output lists 0, 9, 13. This is not consistent with 0, 9, 12. I think there is a typo in the Output. 

IMG_1637.jpeg

0 Kudos
Message 9 of 11
(183 Views)

The 9th element in a zero-indexed sequence would be 8. The 13th element in a zero-indexed sequence would be 12. 

0 Kudos
Message 10 of 11
(179 Views)