I'm working on a project, written in Java, which requires that I build a very large 2-D sparse array. Very sparse, if that makes a difference. Anyway: the most ... |
Have been scatching my head about this - and I reckon it's simple but my geometry/algebra is pretty rubbish, and I can't remember how to do this stuff from my school ... |
It's trivial to write a function to determine the min/max value in an array, such as:
/**
*
* @param chars
* @return the max value in the array of chars
...
|
Given a string s and an array of smaller strings, T, design a method to search s
for each small string in T.
Thanks.
|
I am very stuck with the looping structure for my graph to work out Eulers tour.
This is the graph I am drawing, remember it's undirected, so a journey from N1 to ... |
In binary Search algorithm, the upper-bound element is array.length-1, then how can I find the last element of an array?
If the lower-bound and upper-bound for element of an array of ... |
I have Fortran-based 3D column-major order array flattened into linear memory. What formula/algorithm can I use map it back to a Java 3D row-major order array? For example,
|1, 2, 3| |10, ...
|
|
This is for a genetic algorithm fitness function, so it is important I can do this as efficiently as possible, as it will be repeated over and over.
Lets say there is ... |
I have a two dimensional array that I need to rotate 90 degrees clockwise, however I keep getting arrayindexoutofbounds...
public int[][] rorateArray(int[][] arr){
//first change ...
|
What is wrong here? I want delete an item from an array, but it shows me
error ArrayIndexOutBound exception
public class delete {
public static void main(String[]args) ...
|
If I have a 2D array that is arranged as follows :
String X[][] = new String [][] {{"127.0.0.9", "60", "75000","UDP", "Good"},
...
|
I have two float arrays representing y values in a line chart. Now I want to align these two charts. Are there any existing algorithms for alignment of the two arrays?
A ... |
I have a divide and conquer method to find the i th smallest element from an array. Here is the code:
public class rand_select{
public static int Rand_partition(int a[], ...
|
I've got an assignment I can't figure out, any pointers will be much appreciated, it goes like so:
There's a series of light bulbs represented as an array of true/false, there's a ... |
we know algorithm how reverse array of n integers
for (int i=0;i<n/2;i++){
swap(a[i],a[n-1-i]):
}
is this method better according the speed of algorithm or not because swap ... |
While reading one book named Cracking the coding interview by Gayle Laakmann, i came across this question
Design an algorithm and write code to remove the duplicate characters in a string without ... |
Given this array
int [] myArray = {5,-11,2,3,14,5,-14,2};
I must be able to return 3 because the longest down sequence is 14,5,-14.
What's the fastest way to do this?
PS: Down sequence is a ... |
I just wanted to know what is the best way to un-order the elements in an ordered array in Java,
Thanks
|
I am trying to find the longest sequence of decreasing numbers in an array. I am not sure what I am doing incorrectly in the following code.
public static int getDecSeq(double[] ...
|
This one is making my head spin. Just when I think I got it, I realize something's not right. I have to use recursion for this assignment. Any hints?
/**
* ...
|
This seems like a simple request, but google is not my friend because "partition" scores a bunch of hits in database and filesystem space.
I need to enumerate all partitions of an ... |
assume that i have an array int [] arr={1,2,4,5,7} and also have number 6
so i need the result to be 01100 that means that 2+4=6 in the array so the ... |
I'm working on this bacteria life game thing I have to make.
Basically I have a 2d string array let's say 20 by 20.
What would be the best way to check ... |
I just asked a similar question, but then I realized I actually need something else. Since that question already has two answers, I do not want to edit my question. ... |
I have an 2D-array like this in java
transmission communication tv television
approach memorycode
methodact
I need to get all combinations like:
{transmission,approach,methodact},{transmission,memorycode,methodact},{communication,approach,methodact},...
Can someone provide an example that ... |
I am attempting to translate two separate algorithms into Java code in order to test them; the first algorithm (PrefixAverages1) is:
For i = 0 to n-1
Let s ...
|
I have an array of objects of my custom class and i want to delete a random object(chosen by some criteria). how do i do this and keep the array ordered? ... |
Is this most efficient method to box/unbox multidimensional primitive arrays in Java without using an external library?
private Float[][] toFloatArray(float[][] values)
{
Float[][] objArray = new Float[values.length][values[0].length];
for ...
|
I'm writing a program in java where I need to slide the elements of the array and it should be performing as less as possible number of operations as it's inside ... |
I have an array int x[] and a number. I like to do search on the array such that x[i] + x[i+1] = number.
What is the most efficient and fastest way ... |
Help with how to implement on n-2dimenssional-array. To be more specific:
If I have 6 tables and I am putting these into a 2-dimensional array.I will provide a value say 10 like ... |
I have an array of numbers nums[] and target such that it satisfies the below condition
{{nums[],target}
1> {{8, 2, 2, 1},12} --> returns true ...
|
int firstPosition(int x, int [] a) {
int lower = 0;
int upper = a.length;
while (lower != upper) {
...
|
I have an array to store a set of coordinates for painting a piece of line. So here are some example coordinates
double[][] plotMatrix = {{10,20},{55,80},
...
|
I need to create an array of array with Strings in java...
For example, I read a file that contain for each column a sport and a player name..like:
The goal at the ... |
Im having difficulty understanding how the array is being copied in this algorithm. Im am fine with the code till i get to line 12 shown below. This code was from ... |
I had 2 integer arrays, one original and one modified w.r.t the original array.
Elements can be added or removed from the original to convert it to the modified. My problem ... |
I have implemented a function TraverseStringClockwise which takes a comma separated string of integers, and a width and a height, and returns a new string by walking in a clockwise order ... |
I have a 2-dimensional integer array (say 1000 by 1000), let's call it matrix. Each cell in this matrix has a X- and Y-coordinate (each from 0 to 999 in this ... |
Hi guys I had an interview today which involved this very question and in order to widen my algorithmic knowledge im trying to see if there are any better suggestions.
I was ... |
Please Note: I am not "looking for teh codez" - just ideas for algorithms to solve this problem.
This IS a homework assignment. I thought I was in the home stretch, about ... |
Please write a efficient code/algorithm in java to print a two dimensional array [m][n] in a spiral format ?
For ex. if the array provided by the user is :
1 2 ... |
I am finding it a little bit difficult to get a search algorithm to work properly in Java. Basically, the program has an array initialized. The user is supposed ... |
public class Kadane {
double maxSubarray(double[] a) {
double max_so_far = 0;
double max_ending_here = 0;
for(int i = ...
|
I am writing a program that reads in a potential Latin Square and tells whether or not it is a valid latin square or not. Now I am ... |
Below is an LSD Radix sort implementation in Java from a textbook to sort an array of strings where each string contains exactly W characters.
I want to count the number of ... |
I have an array of objects, and I am trying to pull one element to the top and shift the rest down by one.
Assume I have an array of size 10, ... |
I wrote below code to compare to arrays that have same elements but in diff order.
Integer arr1[] = {1,4,6,7,2};
Integer arr2[] = {1,2,7,4,6};
For example, Above arrays are equal as they ... |
Given an array , in which either the values are only increasing or only decreasing or increasing and then decreasing, How to find the max and min value of such and ... |
Given an unsorted array arr[], find the maximum value of j – i such that arr[j] > arr[i].
Finding this in O(n2) is possible using 2 for loops, but can we do ... |
I'm implementing NxN puzzle in 2D array in Java. I have the following classes:
public class Node {
//private members
private int boardSize;
...
|
I am struggling a little bit when it comes to generating the successors of a node in puzzle.
Let me start with 1D array puzzle int[]={0,1,3,4,2,5,7,8,6} as the start node for the ... |
Design an algorithm , FindElement(a,p), where "a" is two-dimensional square array of positive integers with duplicates and each row of integers is in non - decreasing order:
a[i][0] ? ... |
trying to think of the best way to handle this problem with my 2d game. I want to be able to specify a coordinate pair (x,y) and a radius value. Given ... |
no it is nothing to do with 2d arrays actually. right now I have this long string and I want to divide into an array but not as one word each but like 4-5 groups of words long. so if I do this: String myArray[] = mystring.split(" "); since it splits every gap, it gives me an array full of words, ... |
Originally posted by Victoria Preston: I have been given a snipit of code and I am suppose to find a better algorithm for determining the max vale. My problem would be I do not see anything wrong. Any help would be appricated. It looks fine... You only access the members of the array once and only once. There doesn't seem to ... |
Also, in case you need some help on how euclidean GCD works, here is a bit of a tip: Given two integers, a and b, if r is the remainder of a divided by b, then the common divisor of a and b is also a divisor of r. It is straightforward enough to develop this recursively. |
|
|
Please help me to solve this algorithm. There is an array of length 1000 which has 1000 integers. All integers are in the sequence like 1,2,3, about 999 integers and one more which is duplicate of any one existing. Which is the algorithm to find that duplicate entry. The array is not in the sorted order regards Sandeep |
Put in debugging statements to see where it's going wrong. Either that or use a debugger. Trying to debug your own code by pure visual inspection seldom works, and debugging others' code by visual inspection is even less likely to be successful. Pourquoi est-ce que les noms sont en Francais, mais les commentes sont en Anglais? |
The board contains values from 0 to 3 (corresponding to 4 different colours). For example ( correct winning states of the board looks as follows:) Notice that it's not necessary to have the same number of values for each number (0-3) i.e. you could have five threes, four twos, four ones, 3 zeros etc |