No, they are not using the same algorithm: https://laurmaedje.github.io/posts/layout-models/
If I weren't on mobile I'd link you to the line in the source code. Just search the repo for Knuth-Plass.
Mind you, I loved programming in Typst, and I wrote some plugins before it got its package manager, but I ended up moving back to LaTeX for this difference in quality of the final output. I should do some in depth testing at some point, because I am looking to switch back.