Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Crostal

Pages: [1]
1
C - C++ / Re: Check if a string is inside a string
« on: January 03, 2016, 01:13:33 am »
I read so many comments about reinventing the wheel. In learning especially with the basics there is nothing as reinventing the wheel.
I would say too that for a more efficient way to solve this problem (In your case your algorithm is a O(n2) but KMP is only O(k+n) where k is the length of the main string and n is the length of the desired word you are searching for.
-for more on complexity http://www.dreamincode.net/forums/topic/125427-determining-big-o-notation/.
-KMP https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.
I know the wiki of KMP is a little hard to read and understand, it's a bit complixe approach to solve this problem, but it's very time efficient.

Pages: [1]