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

6
votes
2answers
254 views
7
votes
3answers
351 views

Ticket management system

I am building a ticket management system for a state server we use at work. Back end is node.js with multiple front ends. I am rewriting my back end to be more maintainable as the scope grows. For ...
6
votes
5answers
372 views

Checking if an array is sorted

I've come up with two ways to check to see if array is sorted and return true if it is. ...
0
votes
0answers
12 views

Using ArrayList instead of an array to avoid using a normal for loop [migrated]

I'm reviewing a piece of code that looks like this: ...
-1
votes
0answers
20 views

Sorting rows of matrix based on entries in first column [closed]

I found a satisfactory sort algorithm (1D array) on the Internet, but I tried to retro fit it to bring the second column entry along with the first but the end result after compiling seems to sort the ...
5
votes
2answers
62 views

Array 2D pairwise function

I found myself in the need of a function to pairwise an array 2D so I created one: ...
3
votes
4answers
105 views

Returns values for a specific array and key

This code is intended to take an array and a key as inputs, and return an array of the values paired with that key. ...
7
votes
3answers
226 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: ...
3
votes
1answer
74 views

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

This is my firstish (heavily rewritten) 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 ...
2
votes
2answers
146 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 ...
7
votes
4answers
88 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
82 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
150 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
84 views

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

I'd like this code to be improved. ...
3
votes
1answer
48 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
80 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
111 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
86 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
61 views

Program to find the element in an array

I'd like this code to be improved. ...
4
votes
2answers
78 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
268 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
175 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
54 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
573 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
134 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
125 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
75 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
173 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
61 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
190 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
47 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
92 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
281 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
44 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
54 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
242 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
383 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
70 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
325 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
552 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
41 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
629 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
179 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
139 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
98 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: ...