The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
20 views

mysql: check if values of an array exist in a DB table [migrated]

I have an PHP array of numbers (0,1,2,3,4,5) and I want to check which of them are not in my DB table. How can I do something like: SELECT num FROM (0,1,2,3,4,5) AS num WHERE num NOT IN (SELECT id ...
0
votes
0answers
34 views

Generate Same Sequence of Random Numbers in IDL and C [closed]

I am in the process of developing a C version of a program originally written in IDL. The programs generate arrays with random number generators. I use gsl_rng_uniform and gsl_ran_poisson in the C ...
24
votes
11answers
7k views

How does the “Fourth Dimension” work with arrays?

Abstract: So, as I understand it (although I have a very limited understanding), there are three dimensions that we (usually) work with physically: The 1st could be represented by a line. The 2nd ...
0
votes
0answers
16 views

Replacing a string in C [migrated]

The following only works with numbers, but it won't replace words with spaces. Any suggestions? // Program to find one string in another, delete the found string, and replace it with another ...
1
vote
2answers
159 views

Why a hashtable? Why not just a non-hashed associative array?

I've been learning about using a hashtable to efficiently check for items in a list without looping through the whole thing, but there's one thing that I don't get: Why hashed keys? It seems like: ...
0
votes
0answers
31 views

How to load a dynamic array from file? [closed]

I'll walk through my program. In C, I created my own array structure. /* dynamic array of type int */ typedef struct _ARRAY_I { int *p_array; int size; } ARRAY_I; In C++, I'm used to ...
0
votes
0answers
8 views

VBA Array cell value duplication problem [migrated]

I'm struggling with the same kind of problem for weeks. I thought now is the time to as professionals on the web: Dim txt, show As String Dim NameList(1 to 50) as Varriant Dim i, j, t As Integer t = ...
0
votes
1answer
134 views

Why is first column of list called 0th in so many languages? [duplicate]

If you want first element of list or array you reference it as 0 in many languages (like C or Clojure). Is there are some really good reasons why the programming languages was design this way? In ...
1
vote
1answer
50 views

What is the best approach to storing a multi-dimensional array with unknown bounds?

I'm trying to store content scraped from several lyric and chord websites into separate variables into either a multi-dimensional array, or into separate string arrays, but I've been stuck trying some ...
0
votes
1answer
50 views

Design Pattern : Static Array/List in Class Object

I'm a CS alumni, but we didn't learn much by the way of OOP, or Design Patterns. I've heard the phrase C with iostreams and thought it fitting. Anyway that's besides the point. I am just curious about ...
4
votes
4answers
391 views

Why can't C arrays have 0 length?

The C11 standard says the arrays, both sized and variable length "shall have a value greater than zero." What is the justification for not allowing a length of 0? Especially for variable length ...
1
vote
2answers
72 views

A vector of pointers to different derived classes of the same base class

I am writing a game in C++ which has different enemy types. I have defined a base Enemy class and I also have derived classes enemy1, enemy2 etc. Now for updating these enemies in each iteration of ...
1
vote
5answers
147 views

What defines the dimensionality of an array?

I know that when we speak about an array having 1, 2, or 4 dimensions, we mean arrays like this: 1: [0] 2: [0,0] 3: [0,0,0] 4: [0,0,0,0] ... Is the first 'axis' of an array the only thing that ...
5
votes
4answers
533 views

Why do arrays in Java not override equals()?

I was working with a HashSet the other day, which has this written in the spec: [add()] adds the specified element e to this set if this set contains no element e2 such that (e==null ? e2==null : ...
2
votes
1answer
101 views

Improving the running time of Breadth First Search and Adjacency List creation

We are given an array of integers where all elements are between 0-9. have to start from the 1st position and reach end in minimum no of moves such that we can from an index i move 1 position back and ...
3
votes
2answers
189 views

Data structure for grid with negative indeces

Sorry if this is an insultingly obvious concept, but it's something I haven't done before and I've been unable to find any material discussing the best way to approach it. I'm wondering what's the ...
1
vote
1answer
112 views

How to construct a cubie representation of a rubik's cube, given an array

Just to get this out of the way, I have seen this, and it is not what I'm looking for. So, let's say you are programming a Rubik's Cube. (I know, very unoriginal, but bored programmers have to do ...
2
votes
1answer
227 views

Why does Java support brackets behind variables and even behind method signatures? [closed]

Java allows this: class X{ int i,j[]; // j is an array, i is not } and even worse, it allows this: class X{ int foo(String bar)[][][] // foo actually returns int[][][] { return null; } ...
0
votes
0answers
36 views

Search substring using suffix array (and LCP)

I'm searching for a best way to improve suffix array run time using LCP. My text (about 2 500 000 chars) seems like: 0ricco0eric0america0polo0.... My thoughs: SA=suffixArray char=firstChar(input) s ...
1
vote
3answers
291 views

Choice between 1-dimensional and 2-dimensional array

I'm implementing the Chessboard class to represent the chessboard. I've to implement the transformations (reflections and rotations) on the chess board possible. The possible transformations includes ...
5
votes
1answer
161 views

At ping, why do we have to do array copying instead of passing on the source array that the client sent to us?

So I have been googling about this OpenSSL heart-bleed thing and somehow sees that it is caused by the heartbeat extension which requires client to ping the server to show its aliveness and it all ...
2
votes
1answer
101 views

Accessing a private array when I have an extension method

I'm trying to make a number of data classes for my C#/XNA game, which would essentially be a wrapper around T[,]: public interface IGrid<T> where T : struct { Point Size { get; } T ...
7
votes
8answers
10k views

What is the difference between an Array and a Stack?

According to Wikipedia, a stack: is a last in, first out (LIFO) abstract data type and linear data structure. While an array: is a data structure consisting of a collection of elements ...
0
votes
1answer
436 views

Is a PHP array an example of a dynamic data structure?

I did my homework, and it says that dynamic data structures are "data structures that change in size as a program needs it to by allocating and de-allocating memory from the heap". So I was ...
1
vote
1answer
93 views

If a variable containing a function gave the function's return instead of a reference to the function, what would an array of functions return? [closed]

I'm creating a prototype scripting language similar to something like Javascript. In my language, every single reference to a variable is actually a function call (a getter function), whether it has ...
0
votes
3answers
149 views

Sorting an array when values are decreased by each swap [closed]

Recently in an interview I come across a question: We have an unsorted array, we need to sort it with minimum number of swap. We have in sort a 'tax' of 1 is deducted from the number we are ...
-1
votes
1answer
96 views

Fortran 90 - How to create a coordinate system

So I need to code a simple program, and I need to define 2D coordinates? Is there any coordinate system I can use in Fortran? I was told it might have to be all in arrays? And if so, can anybody ...
1
vote
4answers
167 views

Efficient way of evaluating an array of strings then add to an array in Ruby

I am looking for an efficient way of evaluating an array of strings against a series of rules and then adding them to another array. For example I have an array of strings: something a 1234 #gohere ...
0
votes
1answer
292 views

Sort rectangles in a grid based on a comparison of the center point of each

If I have a grid of rectangles and I move one of the rectangles, say above and to the left of another rectangle, how would I resort the rectangles? Note the rectangles are in an array, so each ...
0
votes
2answers
279 views

Quick algorithm to find matches between two arrays

I'm faced with the following problem: I have an array which is produced by the parsing of a yaml file which contains patterns in the following structure. "Programming books" Title: a ...
6
votes
2answers
757 views

How to remove the boundary effects arising due to zero padding in scipy/numpy fft?

I have made a python code to smoothen a given signal using the Weierstrass transform, which is basically the convolution of a normalised gaussian with a signal. The code is as follows: #Importing ...
2
votes
3answers
458 views

How do you read this line of code?

Forgive me for my poor English, me and my friend were doing school homework, suddenly he asked me to read this line of code ptr = &array[1][1][1] (ptr is a pointer to an integer). He said ...
0
votes
1answer
77 views

What is a cross-platform way to expose an Array[][] over a webservice? Any JSON nuances to be aware of?

I need to expose an Array[][] to many different clients (iPhone, Android, PC, Unix, etc), and need to make it available over HTTP/s This brings me to JSON, and makes me wonder how do all the other ...
4
votes
2answers
4k views

Should I use a list or an array?

I'm working on a windows form to calculate UPC for item numbers. I successfully create one that will handle one item number/UPC at a time, now I want to expand and do it for multiple item ...
0
votes
4answers
14k views

2 Dimensional Arrays in C++

I started learning arrays in C++ and came over a little side note in the book talking about 2D arrays in breif. I tested it out and i was amazed that it could give the programmer the ability to store ...
1
vote
2answers
580 views

Should I create specific classes for JSON Objects or only use the container(Array/Dictionary) for accessing Data?

I'm using Foursquare to get a List of Restaurants nearby inside an iOS app. The Result is stored in an Array which consists of Dictionaries and regarding how deep the Data is, each Dictionary contains ...
0
votes
2answers
303 views

PHP SplFixedArray How To Deal With billions of indexes?

I've built a flatfile db system that will work like mini-noSQL system and it split db to smaller files, and I did a SplFixedArray wrapper for it with a method for searching usage built on preg_grep. ...
1
vote
3answers
572 views

Arrays vs Objects in view template

I am wondering, in view templates, what would contribute to me choosing between using arrays or objects for getting things printed out in arrays {{$user->zip_code}} vs {{$user['zip_code']}} I'm ...
1
vote
4answers
233 views

Is it considered bad practice to access a returned array by a key straight away?

I couldn't think of a good way to word the title, sorry. But what I mean is, is it considered bad practice to do: print get_array()[2] over: output=get_array() print output[2] (where get_array() ...
2
votes
3answers
516 views

Best way to choose random element from weighted list

I want to create a simple game. Every so often, a power up should appear. Right now the different kinds of power ups are stored in an array. However, not every power up should appear equally often: ...
-1
votes
3answers
554 views

Find all lines segments intersections

I have a collection of lines segments, represented by an array. Ex: [3,7,13,6,9] is 4 line segments: [(3,7)(7,13)] , [(7,13)(13,6)] , [(13,6)(6,9)] , ([6,9)(9,3)] I want to find all the lines ...
-1
votes
5answers
1k views

Reverse subarray of an array with O(1)

I have an idea how to implement sub array reverse with O(1), not including precalculation such as reading the input. I will have many reverse operations, and I can't use the trivial solution of O(N). ...
0
votes
2answers
805 views

Question regarding LinkedList in Java

When I was reading a book for SCJP, I came across the following paragraph. A LinkedList is ordered by index position, like ArrayList, except that the elements are doubly-linked to one another. ...
3
votes
2answers
735 views

Should the 12-String be in its own class and why?

This question is regarding a homework project in my first Java programming class (online program). The assignment is to create a "stringed instrument" class using (among other things) an array of ...
3
votes
2answers
168 views

What would be the optimal way to solve a problem like this?

I have a problem where I have to change all the Xs in a 2D array into 0s, and I have to calculate the minimum steps (where a single step consists of changing an entire row or column) required to do ...
2
votes
3answers
241 views

What language has integrated “list insertion” as part of code *syntax*?

Many programming languages permit natural manipulation of strings, and some languages permit the manipulations of lists too. More often then not (always?), these operations are done as procedure ...
2
votes
1answer
111 views

Handling Dynamic amount of Strings for persistent and runtime storage in an IOS App

Background I am dynamically building an FQL query statement and because of the nature of the app, I exclude FB family members, this is the base portion of the query and remains fairly static. The ...
2
votes
6answers
368 views

Settle an Argument: String vs. Array?

True or False: A string is the same thing as an array. I had an interview the other day and the above question was asked. I said false, but the interviewer said it was actually true. I explained to ...
0
votes
1answer
385 views

Use ruby's array sort() method, or add items in correct place with a binary lookup?

If I am loading a whole load of items (un-ordered words from a file or something) would it be more efficient to load them all to a Ruby array, and then use the built in sort! method or to do a binary ...
3
votes
2answers
609 views

CA1819: Properties should not return arrays. Does this happen only with arrays? If yes, why?

I have a question about CA1819 msdn performance warning. The rule is: Arrays returned by properties are not write-protected, even if the property is read-only. To keep the array tamper-proof, the ...