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
Tag: algorithm
Delete leaf nodes between a range in BST
I want to delete the leaf nodes, the values of which are outside a given range (say [L R]). I made a solution in which I was simply traversing all the nodes and checking if my current leaf node’s value is in the given range or not. If it is not then I’m removing this node. My approach – But
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
Maximize the amount of money you pick up as you travel through an array [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question Given an array of integers for example, [1 4 3 2 9 8 7 6] Each integer represents an amount of money you can pick
how do i find the values of A,B and C in java
given the following values X,Y,Z, such as (0≤X,Y,Z≤10000) with considering the following three equations : a+b+c = X abc = Y a^2 + b^2+ c^2 = Z i need to find values of a, b and c, I wrote something like this in java: but its a naïve solution because the values of a,b and c can be zero, positive
Boolean setters and getters not updating upon button click?
So I am currently developing a date android application, now what I have done here is created a simple algorithm called similarDatesFunction this function is responsible for retrieveing data and matching it with the user input, for every match a counter will be placed, if this exceeds 6 counters also known as the offPeak variable it will set a false
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])
Give a list of bomb, each mine has 3 numbers, x, y coordinates and explosion range. Find the initial mine that can eventually detonate the most mines
Give a list of mines, each mine contains 3 numbers, x, y coordinates and explosion range . Find the initial mine that can eventually detonate the most mines and maximum number of mine it denotes. the x, y coordinates can be negative numbers and all three numbers can be double. I coded a dfs solution but got incorrect result. Does
How do I write a Drake sort algorithm for sorting an array in Java? [closed]
I’m writing a Drake Sort Algorithm in java that will sort a collection of elements. The algorithm is supposed to work like this: An array for example: { -2, 4, 1, 4 } Get the max value of the array …