Tag Info

New answers tagged

0

The question does not specify the order of the array elements. There are two possiblities: anArray[i][j] represents the element at row i and column j (row-major) anArray[i][j] represents the element at column i and row j (column-major) The easier task to solve is finding column sums in a column-major array, or---completely equivalently---row sums in a ...


0

Your indices are flipped. Your for loops are written for column-major ordering, but your totalizer is written for row-major order. You need to reverse one or the other.


0

You have a problem in the for loop for(int row = 0; row < anArray[col].length; row++) { totalcol += anArray[row][col]; } If the array is 2X3 then in this for loop when you are using the col = 0 Then anArray[col].length returns value 3. So your row variable can have values 0 - 2 in the for loop. So when the value of row is 2 and the ...


0

I could see this being a recursive function in which you seek the top-left corner of the next possible rectangle. Scan right and down, keeping track of the new rectangle width and height to determine the length to check in your next scan row/column. When you've hit on both left edge and bottom edges, add result to result list, mark those "cells" as used, ...


6

The term "variable-length array" is actually specific to C, but it sounds like you're mostly interested in dynamic stack allocation. To review, VLAs are a feature added in C99 (then made optional in C11) which allow an array to be declared with a size not known until runtime. This means that the language must allocate space at runtime once it knows what the ...


0

Although mathematically you need 2D concept to deal with points in a 2D space, you can use 1D arrays in your Fortran code to accomplish your task. For instance, if you have 100 points in a 2D plane to work with, you can define two 1D arrays x and y as follows: real:: x(100), y(100) and then you can treat x(i) and y(i) as a pair representing the ith point, ...


1

I think this is a not so easy problem, when handling more complex arrays, such as : [0][0][0][0][0][0][1][0][0][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][1][0][0][0][0][0] [0][0][0][0][0][0][0][1][0][0] [0][0][0][0][0][1][0][0][1][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][1][0][0][0] [0][0][0][0][1][0][0][0][0][0] ...


0

This is the first time I heard of this data structure. What sized trees are you aiming for? Unless it's just thousands, it's probably not going to matter much which underlying data structure you start with. From Wikipedia, I understand that index-based access to the structure is important. For that reason, I would go with an implementation based on plain ...



Top 50 recent answers are included