Skip to content
Advertisement

Tag: algorithm

Logarithm Algorithm

I need to evaluate a logarithm of any base, it does not matter, to some precision. Is there an algorithm for this? I program in Java, so I’m fine with Java code. How to find a binary logarithm very fast? (O(1) at best) might be able to answer my question, but I don’t understand it. Can it be clarified? Answer

Mergesort in java

I am new to Java and have tried to implement mergesort in Java. However, even after running the program several times, instead of the desired sorted output, I am getting the same user given input as …

Find all numbers in the String [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

Is there a simpler solution for Codingbat fix45?

I am trying to solve this CodingBat problem: (This is a slightly harder version of the fix34 problem.) Return an array that contains exactly the same numbers as the given array, but rearranged so that every 4 is immediately followed by a 5. Do not move the 4’s, but every other number may move. The array contains the same number

First occurrence in a binary search

I’m tinkering with some code and I realized something I never knew. A normal binary search will return a random index in a data set for a key that occurs more than once. How can I modify this code below to return the first occurrence? Is this something people do? Answer Having found a matching value, you basically need to

Advertisement