First, the algorithm itself can't get patent protection, but after being processed and packaged by an experienced patent agent, the scheme based on algorithm extraction has a chance to get an invention patent.
Second, in most cases, who advocates who gives evidence. Company A, which has obtained "algorithm patent" (in a broad sense), should prove that the other party (Company B) has infringed the patent right.
That is, Company B does not need to disclose a bad algorithm at all to prove that it has not infringed the patent right of Company A; As the plaintiff, Company A needs to prove that the defendant Company B has infringed the patent right. Therefore, when applying for a patent, we should also consider the difficulty of safeguarding rights in the future.
For example:
If Company A initially provides evidence that Company B has infringed the patent right. Company B thinks that there is no infringement of patent right. At this point, in order to show that there is no infringement, it is indeed possible for Company B to clarify its adopted scheme. In this case, it is indeed possible for company A to know the scheme adopted by company B through malicious litigation.