The tag has no usage guidance.

learn more… | top users | synonyms

-3
votes
0answers
25 views

Calculator console apps with C Language [on hold]

I want to write a program that perform a set of operation on string and calculates the results. Input: 5+3×(5×6)×8−5−+3+5×7+4÷8+6 Output: 758.5 This is the code that I could write..... #include ...
-1
votes
1answer
44 views

(Multidimensional array in C) How to make my output in a vertical position rather than in horizontal when the size of the array is n[3][4] [closed]

I would like to have some help. I must find a way that the output must be: A B C 90 60 80 50 100 70 100 20 100 10 50 75 Because the previous output is: A 90 50 100 10 B 60 100 ...
-1
votes
0answers
69 views

Can we create variable length arrays in c++ [migrated]

I am trying to create this simple program which displays the data of the array back to the user again.. I want to create a variable length array. In this program the user is first asked the number of ...
5
votes
2answers
114 views

How to store ordered information in a Relational Database

I am trying to understand how to properly store ordered information in a relational database. An example: Say I have a Playlist, consisting of Songs. Inside my Relational Database, I have a table of ...
3
votes
1answer
184 views

Why Array.prototype is designed to be fully functional array?

In the below visualisation, There are two array objects(cars & bikes) that are created with below syntax, var cars = new Array("Saab", "Volvo", "BMW"); var bikes = ["Honda", "Yamaha"]; whose ...
-1
votes
1answer
167 views

eradicating the array = loop mindset [closed]

I have noticed a common issue in code reviews, that takes this form: // "arr" is an array for (i = 0; i < arr.length; ++i) { if (i == 3) { // do something with arr[i] } if (i ...
9
votes
1answer
720 views

PHP: when to use arrays, and when to use objects for mostly-data-storing code constructs?

PHP is a mixed paradigm language, allowing to use and return non-object data types, such as arrays. I pose a question to try to clarify some guidelines for selection of arrays vs objects when deciding ...
-1
votes
2answers
159 views

3D array updating in C# [closed]

I'm curious because I have read that once an array is declared it can not be changed. Maybe if I lay out my thoughts. Say, I have a cube with dimensions 5x5x5 and I have a viewport that can rotate ...
21
votes
5answers
4k views

What's the use of .Any() in a C# List<>?

I've been discussing this with colleagues, and we couldn't figure out what the use is of .Any for any given List<>, in C#. You can check the validity of an element in the array like the ...
2
votes
3answers
260 views

Is it a good idea to modify the array keys in foreach

Some times I need to modify an array key for example something like: $temp = array(); foreach($arrayIWantToModify as $key => $value) { if($value % 2) == 0) { $temp['odd_' . $key] = ...
0
votes
0answers
38 views

Is it better to store integer data or array references in a javascript visualization?

Say I have a tree that I'd like to visualize with d3. Nodes have various attributes produced by the d3 library, attributes like an index and position variables. Now, I could add more attributes to ...
0
votes
0answers
48 views

Microcontroller oLED Display Buffering Optimizations or Alternatives For Speed?

I'm developing a UI/Layout for a 128 x 64 oLED Monochrome Pixel Display. I've got a small netMF microcontroller driving the display via SPI at 40mhz. I'm using some basic methods, like these here, to ...
1
vote
0answers
252 views

Why is deep plucking a bad idea?

Both underscore and lodash refuse to implement deep plucking, despite many requests from users and gists or modules that implement the feature. ...
3
votes
1answer
430 views

sort multidimensional array recursively - is this reasonable

In a nutshell, I needed to traverse any number of dimensions of a multidimensional array (or not) and I wanted the process to be as predictable as possible (in order to proliferate the pattern ...
3
votes
2answers
87 views

Reducing a sequence of array modification operations (insert, sort, replace, remove)

Given a plain array of values, e.g. ["Apple", "Orange", "Banana", "Strawberry"] and a list of operations from the set of [insert, delete, sort and replace], e.g. [ {cmd: "insert", index: 2, ...
13
votes
1answer
418 views

Why using sizeof of type to calculate the number of elements in an array is considered inferior to using sizeof of an element?

I'm reading "King K.N's C programming" and I'm reading the following statement: We discussed using the expression sizeof(a)/sizeof(a[0]) to calculate the number of elements in an array. The ...
2
votes
2answers
98 views

How to create a 2D array at runtime in Ada? [closed]

In Ada programming, What is a best practice way to create a 2D array of a size that is specified by the user? I'm teaching myself Ada for work (after many years of C programming), and I'm having ...
2
votes
2answers
276 views

Find the maximum number of pairs of numbers that are in a range, between two arrays

Lets say I have two arrays A and B A = {1,2,3} B = {12,11,67} and have max sum value S = 10 How many maximum number of unique pairs can be formed between the two arrays who's sum is less than or ...
2
votes
1answer
292 views

Beginners C# question about Array.Reverse

I am sitting through a very well-explained and thorough video tutorial series, using Visual Studio 2012 as my developing environment. Anyway, one thing that is hard to figure out is this. Say you ...
1
vote
2answers
197 views

What is the algorithmic time complexity of this program?

I wrote a simple program in java to create and maintain Dynamic Arrays: public class DynamicArrays { private Integer[] input = new Integer[1]; private Integer length = 0; private Integer ...
3
votes
1answer
400 views

Why is iterating through List<T> more expensive than iterating through Array in .NET?

According to the answers in this post, List<T> is backed by an Array. According to this article, list iteration is considerably slower than array iteration. If Lists are arrays 'under the ...
0
votes
0answers
103 views

GMP Core Dump while using mpz_clear in C

I'm working on a prime factorization program written in C using the GMP library through cygwin. The algorithm that I have now works fine, but has memory leaks from not using the mpz_clear function on ...
1
vote
1answer
278 views

Split multiple overlapping intervals to non overlapping intervals

currently I try to build an algorithm to split an array of overlapping intervals to a new array with non overlapping intervals. For example: Array of overlapping intervals: [ {0,7}, {8,12}, ...
1
vote
1answer
111 views

What is VLA and how it is implemented?

Most languages does support variable length arrays on the heap but I've heard that those can be stored on the stack too. I'm curios what languages support this construct, some examples and how are ...
1
vote
0answers
340 views

How to loop through array bidimensional in diagonal according to a position in degrees

The title could be no self-explanatory enough but I need some conceptual help in order to implement a solution to go through an array: I'm developing a program to calculate the "most shadepath" route ...
1
vote
2answers
253 views

Non-fixed-size Fenwick Tree implementation

I'm planning to implement a non-fixed-size Fenwick tree. That is, a Fenwick tree that allows interleaving range queries with adding/removing elements. All implementations and samples I've seen so far ...
3
votes
2answers
382 views

How to draw rectangles for 2D arrays

I have an 2D boolean array that looks like this: [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][1][1][1][0][0][0][0] ...
1
vote
1answer
92 views

Why use atomic vectors or matrices in R at all?

In reading Hadley Wickham's Advanced R I learned about the difference between atomic vectors and lists; and matrices/arrays and dataframes. This is something I hadn't really appreciated before, and ...
-2
votes
3answers
2k views

How to store integer array in mysql database [closed]

I am making a college attendence system so i need to store attendence of thousands of students. if I go for 1 column for each day then it will take 12*30 almost 360 column for a year. So I want to ...
3
votes
3answers
444 views

How do you iterate through an array and delete an element?

I have an array and I can iterate through it. I know that it is impossible to change the size of an array; however, how do I take out a certain element that I not want in the array anymore? Example: ...
1
vote
2answers
57 views

Function that would output all distinct values in an array

I want to create a function that outputs the distinct values in a given array. For example, in the following sequence 2 2 1 1 5 2 , the distinct digits are 2 1 5. What I've done till now is: void ...
1
vote
3answers
314 views

Addition or deletion of elements of a dynamic array

Is there any consensus among programmers (or a common convention) on the "right way" to deal with the addition or deletion of one or more elements of a dynamic (mutable) array at runtime while ...
1
vote
1answer
43 views

Expectations on input / output of array dimensions and approaches to implement support for variable dimensions input arrays

Preamble As we are vectorising our colour API, we are changing the accepted input types for most of our functions. We would be keen on keeping backward compatibility with the existing code. Let's ...
0
votes
1answer
90 views

Two dimensional matrix-like data type using lists and/or mutable lists

I am trying to think of an implementation of a two dimensional matrix-like data type. Normally I would take an array of arrays but I'm bound to a relatively low language level which only provides ...
1
vote
0answers
161 views

Should I use enums or arrays for a dynamic data source?

I've inherited an iOS project that uses NS_Enum to store the number of rows and sections in a UITableView At the moment, the UITableView is static; no rows are being added to it. However, that is what ...
0
votes
2answers
301 views

Check all “lines” in an array?

I have a 3D array with booleans and I need to check if there are "lines" that all contain true or false. With lines I mean horizontally, vertically and diagonally within the array. However I only need ...
-3
votes
1answer
50 views

How can this allocation of bi-dimensional arrays work? [closed]

I was seeing this post on StackOverflow and saw a new way (at least for me) to define a two dimensional array of 5x5, it works well, but I feel I don't understand what is going on in the background. ...
1
vote
3answers
184 views

Question about multidimensional arrays

I was wondering something about the multidimensional arrays and then I got a doubt about a concept, specifically about their representation on memory. For example, an array can be defined as follows. ...
1
vote
1answer
78 views

Is it possible to quickly change an array declared on the stack to one declared on the heap

I have about 5000 lines of code which manipulates a large array in C++. The problem is that when I try to make the array even larger i.e. A[10000][10000], the gcc compiler throws me a segmentation ...
0
votes
3answers
778 views

Using action array vs Switch Case [closed]

I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons). One thought (and my current implementation) is to use an action array ...
3
votes
1answer
134 views

Conveniently sorting and (binary?) searching an array of pairs of numbers?

So I have an array of distinct pairs of positive integers. That is, my array looks something like this (for instance): { (1,5) , (6,4), (5,3), (2,3), (2,4) } And my task is, for a given pair (a,b) ...
0
votes
1answer
399 views

Big O notation allocate array of N element

In Big O notation, allocate an array of N element is defined by O(1) or O(n) ? For example in C#, if I allocate an array like this : int[] a = new int[10] When I display this array, I have : ...
0
votes
1answer
38 views

String splits to create arrays

Creating an array of strings for configuration or verification purposes can get long and ugly in code. For example: arrayOfStrings = ['one','two','three','four'] Often to reduce the characters and ...
1
vote
3answers
221 views

memory management of multi-dimensional array

Could you please show me an example how to compute the location of an element in a multi-dimensional array. It is illustrated in Robert Sebesta's book Concept of Programming Languages that location ...
0
votes
3answers
173 views

How to do “image shifting” faster?

I have a grayscale matrix (implemented as a simple array) to be shown on a display: line 1: | a | b | c | line 2: | d | e | f | a-f are grayscale values. This pattern has to be shifted by a ...
4
votes
3answers
470 views

@SuppressWarnings in generic array declaration

While doing a coding test, I ran into a problem where I need to initialize an array of generic type in Java. While trying to figure out how to do that, I looked at this Stack Overflow question and it ...
1
vote
2answers
2k views

2D linked list vs. multidimensional array/vector

I hope that programmers is the correct stack exchange for this, as it is quite a concept based question. I'm working on a data structure in C++ that is a represents data in 3D space. The x-y plane is ...
41
votes
2answers
5k views

How do I move away from the “for-loop” school of thought?

This is a rather conceptual question, but I was hoping I could get some good advice on this. A lot of the programming I do is with (NumPy) arrays; I often have to match items in two or more arrays ...
-1
votes
2answers
235 views

Estimation of space is required to store 275305224 of 5x5 MagicSquares? [closed]

Here are some examples of 5x5 Magic Squares found by some good solvers : Magic Square Generator by Marcel Roos this program state using 2.4GHz Intel takes about 95 hours to generate all solutions. ...
0
votes
3answers
419 views

Why is the complexity of fetching a value from an array be O(1)?

How come the complexity of fetching a value from an array by it's index is O(1)? I thought the algorithm has to go through all the indexes, find the correct index, and then know what value to return. ...