Skip to main content

All Questions

Tagged with
0 votes
1 answer
124 views

how to store the data for function f(time,length)

I have a function which has discrete time step ,discrete length from origin . These two give height of the function. For example at time 1.2sec , and length 5.5cm from origin height is 10cm. The step ...
Mokka Naresh's user avatar
-1 votes
1 answer
101 views

Algorithm that maps consecutive whole numbers to sets of numbers

Where would I begin if I wanted to develop an algorithm that maps consecutive whole numbers to a long list of unique sets of whole numbers. For example: 0 = {0, 0, 0} 1 = {0, 0, 1} 2 = {0, 0, 2} ...
comp1201's user avatar
  • 111
3 votes
1 answer
149 views

Array rotation algorithm

I'm developing an application which sends quotes to clients via email. Since quotes are obtained from various resources (per each client) they end up in a single array which is then used as a source ...
Jan Richter's user avatar
4 votes
2 answers
6k views

How exactly indexing works in arrays?

I only know that index is faster but don't know why is it faster. Suppose I have an array int[] a = {2,3,6,7}. Then I will try to find the element at a[3] and the speed of this will be O(1). Why? How ...
Asif Mushtaq's user avatar
3 votes
4 answers
119 views

Store csv data as rows or columns in view of the needed processing?

Assume I have some data a csv-Files like ObjectName, PropertyA, PropertyB, PropertyC "Name1", 3, 1, 4 "Name2", 1, 5, 9 "Name3", 2, 6, 5 ... and a typical question I want to answer would be For ...
Elvorfirilmathredia's user avatar
1 vote
1 answer
1k views

Merging algorithm for overlapping intervals

I have been searching for an efficient algorithm to merge overlapping intervals on a dynamic array of intervals. For example, (start time, end time) wise, [(1, 2), (4, 8), (3, 10)] becomes [(1, 2)...
Sazzad Hissain Khan's user avatar
0 votes
1 answer
1k views

Lower bound for finding a value in sorted array

Suppose we have a sorted array of unique elements, A[n]. I am trying to find the lower bound for finding a specific element x in the array. I suspect the lower bound to be log_2(n+1). I tried to use ...
Ivan Ivanov's user avatar
3 votes
4 answers
2k views

Fastest algorithm of dividing array into positive and negative numbers

Given array of integers I am trying to design the fastest algorithm that swaps the elements such that at the end : all negative elements are on the left and then the positive elements, for example, ...
user271261's user avatar
1 vote
3 answers
762 views

Find if any pair exists in an unsorted array?

I have come across a programming question in which I have to determine : Does there exists at least one pair in a given unsorted array such that |i - j| <= K and |A[i] - A[j]| <= x ? ...
Tushar Gupta's user avatar
-1 votes
1 answer
70 views

How to fit k-length arrays to number of bigger arrays?

I have n number of one-dimensional arrays similar to: [0,0,0,0,0,1,1,1,0,0,1,1,...] 0's and 1's indicating occupation. And k number of smaller arrays similar to: [2,2,2], [2,2], [2], [2,2,2,2] ...
ag0702's user avatar
  • 109
1 vote
4 answers
1k views

Chunking an array into letter groups that are generally equal length

Given a list of items, I want to break it up into four groups with as equal length as possible. The items need to stay grouped by the first letter in each item as well. 26 letters / 4 groups would ...
Matt's user avatar
  • 185
0 votes
1 answer
606 views

Algorithm to find the highest Tetromino in a Tetris board?

Lets say that our Tetris board is represented as a 2D array of zeros and ones, where a 0 means empty and 1 means occupied, and you where asked to find the highest row in which a tetromino exists. ...
Raed Tabani's user avatar
2 votes
2 answers
5k views

Merge sort and O(n log n) mystery

I read every explanation here but still not convinced. I think mergesort is n * n and I know I am wrong but not sure where. Here is what I think: Suppose we are sorting 8 elements and this is the ...
Asif's user avatar
  • 129
2 votes
2 answers
3k 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 ...
WeirdAl's user avatar
  • 79
2 votes
2 answers
795 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 ...
fps's user avatar
  • 139

15 30 50 per page