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

2
votes
2answers
56 views

Inversion count algorithm

I implemented the inversion count algorithm using the merge sort approach for this question. The question begins with a number t = number of test cases and then for each test case you input size of ...
-2
votes
0answers
22 views

C++ Copy Construtor…copies fine but has unexpected core dump [on hold]

I have tried about everything. Increasing the amount of allocated space...copying not the full previous array. Testing has revealed that everything is fine until directly after the code is run. My ...
10
votes
2answers
259 views

Unique value finder

For our first assignment in our algorithm class we are suppose to solve several different questions using information from a 2D array. We are also suppose to optimize our code to get more marks on our ...
-2
votes
1answer
54 views

Finding the modes of an array

I've a working function. But it feels complicated and doesn't look too good, I would like to improve it. ...
0
votes
1answer
37 views

Structuring a JSON array with objects

I have a JSON array or literal (passes through JSON.parse). Requirement: an array of tasks which contains operations which are key/value pairs. Array of tasks > Array of operations (array of ...
2
votes
1answer
70 views

Project Euler 4 The Functional Way

I'm learning Scala (and functional programming). Is there a better way to solve Euler problem 4 than either of these two solutions. Euler 4 I like this array comprehension solution, but it wastes so ...
2
votes
1answer
25 views

Create a Tree Node from JavaScript Array

I'm trying to create a list of subpaths from a flattened array. Here's the starting point: ...
-4
votes
0answers
27 views

how do i inprove upon my recursive binary search in java to prevent any possible user errors [closed]

how do i prevent the random error that i keep running in to. im really unsure. also im trying to increment numcalls as a counter to count how manny times the recursive call... is called. ...
2
votes
2answers
39 views

K&R atoi() variation

I'm currently learning C with The C Programming Language by K&R and this is my current exercise: Rewrite appropriate programs from earlier chapters and exercises with pointers instead of array ...
4
votes
2answers
176 views

“Breaking out” elements from an array

I wrote a method that takes an array T[] array (T is a type parameter) and a second array ...
1
vote
0answers
24 views

Turning a 2D array into a tree

I have the following data structure that's obtained from a third party: ...
1
vote
1answer
35 views

Reorganizing a PHP array structure (arrays within arrays)

I have this array within array which contains a lot of values: ...
7
votes
2answers
127 views

Deca dimensional ascending and descending array sort function

Some folks told that a two-dimensional array can solve almost all the problems, but let me disagree with that. That's why I made this Deca dimensional array sort function. The array must be ...
3
votes
3answers
150 views

Storing and processing large arrays to compute dot products

Problem Statement (from HackerRank) We have two arrays \$a\$ and \$b\$ of length \$N\$, initially all values equals to zero. We have \$Q\$ operations. Let's define three types of operations on ...
4
votes
2answers
95 views

Reading a sequence of characters and dynamically splitting into multiple arrays

I am trying to read a sequence of random characters, integers and symbols from the standard inputstream, split it into 3 separate arrays (uppercase, lowercase and numeric) and print them in that order ...
1
vote
1answer
76 views

Checking to see if all values in an array are equal

I have an array that might be either one-dimensional, two-dimension, or three-dimensional. I'm wanting to check to see if all values in a given direction are constant. Here are 3 functions: ...
6
votes
2answers
66 views

2D array to draw a letter 'F'

This is my code to print letter 'F' with nested loop 2d array. Are there changes that could be made in it to make it look better or more efficient? ...
5
votes
2answers
74 views

Fluent API for creating random integer arrays in Java

Now I have this fluent API for creating random integer arrays. I can say that I want an array of particular length, having a particular minimum/maximum values and using a particular (or default) ...
2
votes
1answer
59 views

Deleting duplicates from a string

I'm pretty new, but I'm always looking for different/better ways to solve these problems as it helps me understand it better and hopefully will make me better programmer. Feel free to point out any ...
0
votes
4answers
193 views

My own method for sorting numbers in array

I've written some method for sorting asc and desc numbers in array. All I want to know is this good logic, and is there a space for improving this code? ...
5
votes
3answers
65 views

Finding unique values in an array with possible nested arrays

I'm writing a function that receives an array and returns an object with the count of unique values, pretty much like other questions here or in StackExchange. Except that in my case, this array may ...
2
votes
2answers
97 views

Sorting dates (DD/MM/YYYY) with insertion sort [closed]

I'm having troubles with a coding problem. Yes, I need to write a C++ program which sorts dates. I've tried several methods. Using 2D arrays and now parallel arrays. The problem I have with my ...
3
votes
2answers
48 views

Nested Skips (UPenn)

Exercise 1: skips :: [a] -> [[a]] The nth list in the output should contain every nth element from the input list. For example, skips "hello!" == ["hello!", "el!", "l!", "l", "o", "!"]. ...
1
vote
4answers
127 views

Find the longest sequential same character array

I am a new guy to Java. I want to find the longest sequential same character array in a input character arrays. For example, this character array: bddfDDDffkl ...
20
votes
4answers
3k views

“ONCE”, “UPON”, “A”, “TIME”

I'm working on a small program to perform various tasks on text content, primarily at the word level. I wrote these methods as ways to help prepare the raw text file into something more malleable, ...
7
votes
1answer
71 views

Stack using an array

I designed a simple drop-out stack a while back. Basically, I just want to get a few opinions on whether or not this is a good implementation and whether I am understanding the concept of a drop-out ...
6
votes
0answers
35 views

Creating a pseudo Pivot Table / Database using a 4-D array

Why am I not just using a Pivot Table / Database? a) I've never ever used either before. And I don't have time to learn how before this project needs to actually be finished. b) The final output ...
5
votes
1answer
42 views

Defining array contents using multiple statements on one line

I'm writing a sub which is going to determine which type of business is being detailed on a particular line of data. It's going to use column positions to check if the data exists, and then output the ...
3
votes
1answer
138 views

Duplicate integers in an array

Code shows duplicate values of integers in an array with indexes and the number of occurrences. Can you please critique my code and provide your thoughts on where I should improve my code? ...
10
votes
1answer
120 views

Calculating and displaying score statistics using C# 6.0 features

I'm studying C# and trying to work on efficiency and making the best use of C# 6.0 features. I have created the following program based on an exercise challenge in a book, and have used Resharper to ...
3
votes
1answer
44 views

Looping through nested arrays with creating new array from nested items

I have written this function but I am not so proud on it. I could use some help refactoring it. Would recursion improve my code? Data sample. ...
2
votes
1answer
34 views

Menu driven program to represent polynomials as a data structure using arrays

Write a menu-driven program to represent Polynomials as a data structure using arrays and write functions to add, subtract and multiply two polynomials; multiply a polynomial with a constant, ...
5
votes
2answers
319 views

C++ Array with iterators

I wrote an Array class with iterators: ...
2
votes
1answer
24 views

Create an array of categories from comma-seperated text input

This code works just fine, but could obviously be more elegantly written. The basic idea is to create an array of categories from a text input. The code splits up the text input by commas to create ...
3
votes
1answer
43 views

Transforming an array of arrays into an array with joins

I'm transforming this: ...
5
votes
3answers
234 views

String to Array formatting

I'm tying to convert from this formatted string: $filtersStr = "id:1||name:alex"; to: ['id' => 1,'name' => 'alex'] ...
4
votes
2answers
87 views

Palin Pairs (Pallindrome Counting) Code

In an array of strings 'a' having 'n' strings i have to select the Palin Pairs from the given strings .for ex for input 3 bba abb abb Output=2 I am getting correct output but want to reduce time ...
7
votes
1answer
68 views

Print array of sentences vertically

Suppose I have an array of sentences: [ "How To Format", "put returns between paragraphs", "for linebreak add 2 spaces at end" ] I want to print it like this: ...
1
vote
2answers
90 views

Finding number of number pairs with given difference [closed]

pairs() is a function which returns the total number of combinations whose difference is k. ...
8
votes
1answer
81 views

Multithreading readied Median Filtering

So I've been confronted with a rather simple problem in the Java chat on Stack Overflow. It's about doing a median filter with a sliding reference window. For the purpose of the task we can assume ...
1
vote
3answers
112 views

Count specific array values

I want to count specific strings from array values $array = array("report=D","report=D","report=D","report=I","report=I"); I am going to count the number of ...
2
votes
2answers
163 views

Load text file into an array in Swift

I'm drowning in Swift optionals and error handling syntax. I'm just converting a text file into an array of Strings. One would think that this could be a simple two or three liner but by the time I ...
3
votes
1answer
41 views

Implement selection from array by 'random' or 'if/elif conditionals'

I'm working on some code examples in 'Automate the boring stuff in python...' to prepare for my first year of CS. I want to know if its better to use an array with random selection below or rather ...
2
votes
2answers
89 views

IntArray implementation [closed]

I need to write an IntArray implementation for college. I'm wondering if my code could be better and if it is efficient. In the header file are the methods listed ...
6
votes
1answer
114 views

Finding the count of negative sub-arrays for a given array

I want to improve my implementation for the following problem: You are given an array of n integers. A sub-array is "Negative" if sum of all the integers in ...
4
votes
3answers
37 views

Max contiguous slice in Ruby

I need to compute the max contiguous slice in an array. I wrote this function, but I am not sure if it is correct or I am missing edge cases. I ran several cases. ...
1
vote
2answers
46 views

Comparing two almost exact arrays

I have two arrays: $row $rowTwo The only difference between these two arrays are the first two keys have slightly different ...
5
votes
3answers
630 views

Function that adds two integer strings

I wrote this method that adds two integers in the form of strings together. This way I can add large integers without overflowing. How efficient is the code that I wrote? I am by no means a great ...
1
vote
2answers
60 views

Library class Project

I am creating a class project which involves two classes: Library and Book. I would like a general review on the code. ...
2
votes
1answer
38 views

Kadane's Algorithm Variant (Start Index and End Index with Sub Array returned even for all negative numbers)

Here is an attempt to extend the Kadane's Algorithm to return the sub array itself instead of the sum of maximum sub array. This must work irrespective of the original array having all positive or ...