| how to count no of occurrence ... | |||||||
|
30 Day Risk-Free Guarantee:
100% money back if you're unsatisfied. Book (308 Pages):
![]() Video (One Hour):
![]() Resume Review (24 - 48hr)
All Products / Services
|
|||||||
how to count no of occurrence of a particular word in a given file of text. [c/c++] And if file is very large hw will u go about it.
6
you can use the data structure called Tries. It becomes trivial after that.
But IT will take alot of space..and it would be suitable if you would have to count all different words..
option A) InPlace Quick Sort on the words, then search using Binary Search.
Option B) Trie
If the numbers are words are too many then Trie will outdo QuickSort model. However Tire need lot more space than In-Place Quick Sort model.
use KMP or Boyer Moore string searching algo's to search the word and count.
Complexity O(n+m), n = size of text, m = size of pattern
inverted file index
Hashing (key = word, value = count); Could do it in a distributed way if hash table too large for memory.