Skip to main content

All Questions

Tagged with
1 vote
2 answers
86 views

Initialize a two-dimensional array with the values shown in the table below

Initialize a two-dimensional array with the values shown in the table below 1 0 0 0 1 0 0 0 1 0 0 4 0 0 0 4 0 0 0 4 0 0 9 0 0 0 9 0 0 0 0 0 0 ...
Dennis-The14th-Web's user avatar
0 votes
1 answer
389 views

Algorithm to fill 2D array with the maximum value in the middle

Is there a methodical way to sort the values of a 2D square array with the maximum value in the middle and the minimum values at the edge? Examples: 1 5 3 8 9 6 4 7 2 or: 4 8 1 6 9 5 2 7 3 ...
frosted_donuts9's user avatar
0 votes
1 answer
80 views

Is there an algorithm for filling a 2D matrix with data based only a small number of starting values?

I have a 2D grid, and an array of points within the grid. (To make it easier to discuss, let's think of them as colours in a bitmap.) I have a certain number of real pixels where I know the colour, ...
Nigel Stanford's user avatar
1 vote
2 answers
71 views

Searching for efficient clustering algorithm

In a 2D NxN matrix each point represents a area of a map. There are M numbers of customers in random areas whose service need to be served by K numbers of customer service centers in random areas. ...
Sazzad Hissain Khan's user avatar
1 vote
1 answer
59 views

How to find "Eastern" most point of Regions Located Within Wrapping 2-d Plane

I am attempting to figure a way to determine the furthest square (eastern-most, western-most etc.) of a contiguous region existing on a wrapping 2-d plane. The bottom-left point is [0,0] and the top-...
RIanGillis's user avatar
1 vote
2 answers
134 views

Algorithm not showing right output

The Question was: You are given a binary matrix (i.e. each element of matrix is either 0 or 1) of size n × n. You want to re-arrange 1's in such a way that they form a rectangular region. Note that ...
Osama Inayat's user avatar
1 vote
1 answer
733 views

How to draw a square in a 2d matrix given two opposite points

I am given the coordinates of two opposite points of a square (say the points A and C in a square ABCD) and I need to draw the square as ASCII where each character represents a point in a 2D matrix : '...
Mouradif's user avatar
  • 2,706
1 vote
1 answer
116 views

Find 2D plane in the center of 3D object

I'm building a segmentation algorithm. I'm segmenting pieces of paper in a book that have been slightly crumpled. Imagine taking a piece of paper, crumpling it into a ball, and then trying to ...
Kendall Weihe's user avatar
10 votes
8 answers
17k views

Print 2-D Array in clockwise expanding spiral from center

I have an guaranteed to be a perfect square matrix. I want to start at the center of the matrix in this case it would be matrix[2][2], I know how to figure the center (int)(dimensions / 2). I need to ...
user3328187's user avatar
-1 votes
3 answers
1k views

Find longest sequence of decreasing numbers given a 2D matrix

Given a 2D array, find the longest sequence of decreasing numbers. Constraints are: 1. you cannot compare elements diagonally. For Eg: 56 14 51 58 88 26 94 24 39 41 24 16 8 51 51 76 72 77 43 10 38 ...
0726's user avatar
  • 315
1 vote
1 answer
1k views

Calculating parallax layer world coordinates?

I'm trying to position a sprite in a 2d game at a certain world position on a parallax layer. So if my parallax layer has a scroll factor of 0.5, when the camera moves 2 pixels, that layer moves 1 ...
Bruce's user avatar
  • 235
0 votes
1 answer
848 views

Horizontal and vertical flip on linesegment

I have a set (c++ vector) of points (x,y) that defines a line. How do I implement a function that returns the samle line, flipped horizontal and vertical relative to its own size?
askemottelson's user avatar
2 votes
1 answer
4k views

How to use Transformation Matrix for SpriteBatch correctly?

I'm new to XNA and would like to develop a light-weight 2D engine over it, with the entities organized into parent-child hierarchy. I think of matrix when drawing children, because their position, ...
Luke Vo's user avatar
  • 20k
2 votes
3 answers
221 views

Fitting Lines into a Grid Matrix [Competition , Not HW]

In a recent competition organized by "AmDocs" , I came across the following question : (The basic Idea of the question) You are a given a matrix of fixed size 12x12. You are given six line segments ...
Kyuubi's user avatar
  • 1,228