Skip to content
Advertisement

Tag: algorithm

How to implement the medians of medians algorithm in Java

I am trying to implement the median of medians algorithm in Java. The algorithm shall determine the median of a set of numbers. I tried to implement the pseudo code on wikipedia: https://en.wikipedia.org/wiki/Median_of_medians I am getting a buffer overflow and don’t know why. Due to the recursions it’s quite difficult to keep track of the code for me. Confirm n

Random search on an array of size N

I need help fixing my code below. I want to do a random search on an array of size N. Random search randomly picks up an integer from arr to compare. And the process repeats until the integer it is looking for is found (again it is remarked that the membership is guaranteed, otherwise random search obviously can enter an

Down to Zero II

This is the question: You are given Q queries. Each query consists of a single number N . You can perform any of the operations on in each move: If we take 2 integers a and b where N=a*b (a ,b cannot be equal to 1), then we can change N=max(a,b) Decrease the value of N by 1 . Determine

JAVA // How do i make it case-insensitive?

I used the translator. It’s a university algorithm assignment, Merge sort implemented successfully. Now, capital letters come out first, and lowercase letters come out. Can make the code case-insensitive? I want the results to be like this. ex) a A A B b C c c D d … plz help. Answer Instead of comparing using if (array[s] < array[m])

Advertisement