An array is an ordered data structure consisting of a collection of elements (values or variables), each identified by one (single dimensional array, or vector) or multiple indexes.

learn more… | top users | synonyms

0
votes
0answers
11 views

Java: What array is better to use when inserting elements in real-time? [on hold]

currently I'm working on a application on my RPi which will be monitoring a set of GPIOs in real-time where the exact time when the GPIO turns HIGH is crucial for my application. The actual date is ...
4
votes
2answers
99 views

Index into array as if it is circular

The problem: Treat an array as if it is circular; out-of-bounds indices "wrap around" the array to become in-bounds. Current solution: ...
0
votes
0answers
11 views

Best algorithm to find a subarray whose sum is closer or equal to given number. [on hold]

Suppose we have sub array of size n and we have to find subarray of whose sum is equal to k or closest to k. Solution: What would be best algo for this problem.
1
vote
0answers
16 views

Locating a bitmap inside another (larger) bitmap with F#

This is my first go at the completed project that I've been working on with CodeReview assistance, so further advice is appreciated! See here, here and here for the past history of the project. I ...
2
votes
2answers
131 views

Efficient way to iterate over elements of array for matching contents of another array

Using jQuery I'm trying to find an efficient way to iterate through an array excludeMe and check if elements from another array ...
6
votes
4answers
80 views

Use a Java Array like a List

I'm saving string values in an array one at a time so I cannot initialize the array with the values all at once. After I'm done with the array I need to pass it to another class that is expected a ...
5
votes
2answers
76 views

Initiating class objects and arrays

I have a class that always has 14 instances. I'm just wondering if there is a better or more effective way of doing this. In this class I also have an array that is filled by calling 4 functions ...
6
votes
2answers
136 views

How can I quickly find unique list items?

I use the loop-every-single-list-item approach to filter out unique elements in a given list, which tends to be very inefficient way as a list grow in size, or as function call frequency increases. ...
7
votes
1answer
74 views

Program to insert, search for and delete an element from an array

I'd like this code to be improved. ...
3
votes
1answer
44 views

Transforming a byte array into an array of byte arrays with F#

This code is intended to be used with an image manipulation library that I'm working on, and the goal is to take the raw byte[] data from an image, and transform it into a 2D array where each position ...
3
votes
2answers
78 views

Returning nested array with added key=>value

This works, but do I have to make a new array, result, or is there a way to just insert the field I need into each $key of the ...
8
votes
2answers
104 views

Finding the longest Collatz sequence cycle

I wrote a program to calculate Collatz sequences for initial numbers between 1 and a given integer i, then find the one with the largest cycle length. My code is ...
4
votes
1answer
81 views

Converting string array to string (and vice-versa) for storing via XML

I'm using XML to store data and I need to store a string array in it. The best way (that I can think of) to store a string array is by converting it to a single string. In order to do that, I'm using ...
7
votes
2answers
60 views

Program to find the element in an array

I'd like this code to be improved. ...
4
votes
2answers
76 views

Implementing write sphere of values to 3D array

The code below is sort of complicated to explain... It writes a "sphere" of data to a 3D array from the given 3D-Position outwards in a spherical shape based on the given radius and value to write. A ...
7
votes
3answers
265 views

Find two unique integers in sorted array

I have to write the following method: I have sorted array of integers and in this array every integer repeats twice, except two elements. I have to find these two elements. Input: 1, 1, 2, 3, 3, ...
4
votes
5answers
171 views

Search algorithm for specific values in a 3D array/matrix being super slow

I'm trying to create code that reads a text file (containing (double) numbers between 0 and 1) and filling up a 3D array/matrix (calling it matrix from now on) with ...
2
votes
1answer
42 views

Duplication Elimination Project [closed]

I am currently doing a project for school, and I am completely stumped. We are only on Chapter 8 of C# Development 1 and I have a question about the code. The project is: Use a one-dimensional ...
4
votes
1answer
50 views

Product of corresponding elements in 2 arrays

Given two arrays A and B, of length N and length k ...
4
votes
2answers
50 views

Dynamic array of Years

I wanted to make a dynamic select statement from this year to 10 years. This gets the job done, but I feel like it's a little much. ...
10
votes
5answers
567 views

Yahtzee game (using arrays and object classes)

As part of an assignment for my intro Java class (please bear with my beginner skill set), I'm working on a program for which a Die object class is used to play a Yahtzee game. An overview of the ...
4
votes
2answers
133 views

Searching for duplicates without any collection or sorting

I have written code which is easy to understand, but may not be efficient but will solve the purpose. ...
7
votes
3answers
116 views

Compare string with wildcard string

I have the following function to compare a string with a wildcard string (containing ? and *), as C# doesn't seem to have a builtin function to do it. ...
1
vote
1answer
74 views

Declaring arrays knowing their maximum size

I know the maximum array size is 6. So what is the best practice to declare an array? In the following code I used it like this: ...
8
votes
2answers
167 views

Min and Max initialization

Is it a good practice to initialize the max to -100000 and min to 100000? Is there any other way to initialize both min and max to 0? ...
3
votes
0answers
59 views

Python Multiprocessing: Using mutable ctype arrays seems to work, yet I am not seeing significant speed-up. Why?

As a brief introduction, I am student working on a body of code which forms part of my Masters' research - this is my first question on SO. My background is in physics and mathematics, so I will ...
4
votes
2answers
187 views

Finding the value 'n' in an array that has 'n' or more larger values

Given an unsorted array of integers, you need to return maximum possible \$n\$ such that the array consists at least \$n\$ values greater than or equals to \$n\$. Array can contain duplicate ...
5
votes
2answers
45 views

Finding the best matching block/patch in Python

I wish to locate the closest matching NxN block within a WxW window centred at location (x,y) of a larger 2D array. The code below works fine but is very slow for my needs as I need to run this ...
1
vote
2answers
62 views

Given suffix array and a pattern, search if given pattern exists

Given a suffix array for a word, check if a pattern (consecutive chars) exists. Example: A suffix array constructed for "ameya" should return true for "ame" but false for "foo" or false ...
7
votes
2answers
90 views

Output in one window

Can anyone give me feedback please? I used what I have learnt so far, mainly methods, loops and arrays. I would like you view based on these topics, however, comments on how to improve are welcome. ...
5
votes
3answers
276 views

How to increase performance/speed of code that uses .Count() on Lists?

The Test PublicQuestion_ComplexTest is taking around 1600ms (1.6 seconds) to run, but used to take 92ms. I have a feeling this is because of recent code changes ...
5
votes
1answer
42 views

explode textarea and commas [closed]

Am attempting to recreate a common feature, where a user can type several items in to a textarea, separated by commas and newlines and then submit them, i.e. for multiple record entry. The data does ...
1
vote
1answer
51 views

Find part of string in array, replace entire row with that part of string if found

Following is the string: (I'm getting that from config file so its not constant): ...
5
votes
2answers
234 views

Fastest way to multiply two byte arrays in Java

I have two byte arrays that represent unsigned 256-bit values and I want to multiply them resulting into a new value. What is the fastest ways to do this in Java? And are there other factors I should ...
6
votes
2answers
379 views

Is there a way to optimise my Perlin noise?

I just started using Perlin noise a few days ago, and the results look quite good. But it takes over 3 seconds to calculate and draw a 1024x1024 bitmap of said noise. I use an array of 1024x1024 to ...
2
votes
2answers
64 views

Two-dimensional array allocation in Go

I am creating a two-dimensional array, which I am going to process later in ways similar to image MinFilter, procedural labyrinth generation, etc. -- implying using coordinates and neighbors. Here ...
2
votes
2answers
69 views

Importing tab delimited file into array

I am needing to import a tab delimited text file that has 11 columns and an unknown number of rows (always minimum 3 rows). I would like to import this text file as an array and be able to call data ...
3
votes
2answers
320 views

Check winner in a Tic Tac Toe game

I have the below code to check for a winner in a Tic Tac Toe game. I'm wondering if this is a good approach, and if there is a better way of doing this (maybe by monitoring the state of the board). ...
6
votes
1answer
66 views

Finding the sub-array with maximum sum - my slow approach

I decided to give the maximum sub-array sum problem an interesting go, however I will assure you that it doesn't perform well, and that I would never put this in production. I'd like a review on ...
13
votes
4answers
545 views

Finding the sub-array with the maximum sum - my approach

This is the code I ended up with that implements the approach I described in a recent answer to another question about the same problem The basic idea here is to not loop through more things than ...
1
vote
1answer
40 views

Find-and-replace optimization

I'm looking for some JavaScript code improvement and optimization. Is it possible to optimize this block of code (for example, remove double array loop)? ...
7
votes
4answers
597 views

Find the subarray with the max sum

In an interview I was asked to solve the following problem: find a subarray with max sum I have written a piece of code for the same. I need your help in reviewing this code. ...
3
votes
2answers
155 views

Calculate all possible combinations of an array of arrays or strings

I'm using code adapted from this Stack Overflow question to calculate all possible combinations from an array, which may contains strings. For example: ...
2
votes
2answers
137 views

Two solutions with min max values - which should be slower?

While practicing at codinbat.com on the assignment: Given an array length 1 or more of ints, return the difference between the largest and smallest values in ...
4
votes
1answer
97 views

Making an array editable by user

What I want to do: Let users add data to an array through an input field and add button. HTML: ...
7
votes
2answers
138 views

Optimize a parallelized program to optimize train schedules

This loops through a vector of vector of A and adds a smaller array to a bigger one at a specified position+random shift. Then it is checked if it is a better solution, and if yes, it is stored, else ...
4
votes
2answers
276 views

Shortest possible way of printing a specific board

I am trying to print a board exactly like this with the multidimensional array. char score[10][10] = {' '}; ...
2
votes
2answers
56 views

JavaScript Array Comparison (aka Set Comparison)

I want to compare the values in two arrays. The order of the values doesn't matter. Basically they are two Sets. This function returns true if the values are the same in both arrays, or false ...
4
votes
1answer
49 views

Count array inversions merge sort

How does it look? Comments, code correctness, etc. ...
1
vote
1answer
46 views

Robots files generation - simplifying foreach code

I'm trying to figure out if there's a way I can simplify this code which is used to generate a robots.txt file with numerous rules. Different files/folders are separated in separate arrays because ...