r/AskComputerScience • • 13h ago

How is word counting done in writing systems with no delimiters?

17 Upvotes

For most languages, the algorithm is simple: count spaces and add 1.

however, let's take this example text in mandarin: "你好。我不说汉语。"

counting it this way will return... 1. the "spaces" after the dots are also included into the dot, so they aren't the "ascii" whitespace.

if you have a lot of time to spare, you can sort the whole dictionary by word length in descending order (so that combined words appear first: 语 is a word itself, but here it's part of 汉语, which is also one word). however, this is O(n*m) (amount of chars in sentence times the amount of words in a language). you could reduce the constant m by using a hashmap to look up the first word (dict[str,list[str]] where the list is sorted by str length in descending order), but it still seems like way, way too much.

is there any way this algorithm can be reduced further, or is it simply impossible?


r/AskComputerScience • • 21h ago

Why do some apps use hundreds of megabytes for user data on Android?

6 Upvotes

Some of them are not used to store local files

edit: not referring to the cache


r/AskComputerScience • • 12h ago

Question about college.

1 Upvotes

I just learned that me cs degree doesn’t extend to cpp though I want to become a gamedev and cpp it’s kinda necessary. My program will focus on Java, JavaScript, python amd I’mkinda disappointed to learn that we won’t touch cpp those 3 years. I’m kinda disappointed cause I guess there was some miscommunication when I specifically asked the admissions about the program they told me cpp it’s in it. Now they say cpp it’s not in the program at all and I’m freaking out. Is it actually that bad idk.


r/AskComputerScience • • 19h ago

Given the academically exciting times we are living in, which programming languages will genuinely help a CS student for their research?

0 Upvotes

Some I have found from the Internet are:

  • Scala, Haskell (the functional programming stuff)
  • Raku (actually a pretty expressive language for theoretical CS, I presume)
  • LISP (the prefix notation and tail-call optimization stuff are pretty cool)
  • Lean (Even the anti-AI researchers cannot fully refute Lean because of its FP background)

If I do not know about any programming language that might be useful for CS research in particular, feel free to comment.