Questions for algorithm


4694

Reversing a sub-array of an array , in less than O(n) time

how can we reverse a subarray ( say from i-th index to j-th index ) of an array ( or any other data structure , like linked-list ( not doubly )), in less than O(n) time ? the O(n) time consumption is
3161

Programming Challenge: Easiest way to code this grid?

Made It! Look at bottom of the post!!!
913

Efficient algorithm to find all the paths from A to Z?

With a set of random inputs like this (20k lines):
1673

How to design a latest recently used cache?

How to design a latest recently used cache?
5906

Algorithm for determining which words make a phrase popular

Suppose I had a list of slogans (short, multi-word phrases), and people had voted for the ones they liked best, and I wanted to assess which words, if any, made some slogans more popular than other...
4307

How does the Google “Did you mean?” Algorithm work?

I've been developing an internal website for a portfolio management tool. There is a lot of text data, company names etc. I've been really impressed with some search engines ability to very quickly
3507

SQL query to get neighbours from table with two dimensional data

I have a table, that contains partitioning of world map. Partition is done by splitting all area into rectangles, called 'tile'. As usual, rectangle has bottom-left and upper-right corners, both re...
8675

Knapsack problem with all profits equal to 1

There is a variation of knapsack problem when all profits are equal to 1. It seems it can be solved much faster than classical discrete (0-1) knapsack problem, but how? Will just greedy algorithm w...
6056

What is exactly mean log n height?

I came to know the height of Random-BST/Red-Black trees and some other trees are O(log n).
4100

Same result from K-means and sequential K-means?

Do we obtain the same result if we apply K-means and sequential K-means methods to the same dataset with the same initial settings? Explain your reasons.
3304

How does “Find Nearest Locations” work?

Nowadays most of the Restaurants and other businesses have a "Find Locations" functionality on their websites which lists nearest locations for a given address/Zip. How is this implemented? Matchin...
3480

Algorithm to determine the “usual” cash payment amounts for a given price

You walk into a store, select several products, then go to the counter to pay your bill. The total is some amount (A). You reach into your wallet, purse, or pocket and put down some cash (P), where...
4664

How to search common passwords from two given files of size 20GB?

i have two files of size 20GB. i have to remove common passwords from either of one file.
4849

How can i diff two trees to determine parental changes?

I've got a tree structure that I need to rearrange (drag and drop) and then submit the changes.
1512

Balancing a ternary search tree

How does one go about 'balancing' a ternary search tree? Most tst implementations don't address balancing, but suggest inserting in an optimal order (which I can't control.)
386

What algorithm can be used to find the optimal solution for this?

I have accounts with positive and negative balance and a pledge relationship between some. A pledge gives accounts with negative balance the right to retrieve money from the pledging account to cover
1413

Problems with an Algorithm

I have the following 5 lines of string:
1714

Sort numbers by sum algorithm

I have a language-agnostic question about an algorithm.
5734

data structure for Graph in java

i am looking to implement a algorithm for the Travel Salesman Problem. I want to model the solution using the graph , in this a vertex will represent a city and edge will represent the cost from on...
1302

How would rating system be done for users in a web application?

I am implementing a web application that has many users and I would give the users rating based on their activities and based on other users liking their activities. How would I implement such an
8120

What algorithm does Excel use to recalculate formulas?

Are the formulas represented in a syntax tree then recalculated using a design pattern like the Visitor pattern? How would you go about reproducing the recalculation process in code?
1460

Algorithm: array of arrays in Cocoa Touch (perhaps using NSCountedSet)

This one is a bit tedious in as far as explaining, so here goes. I'm essentially populating a tableView on the iPhone with multiple sections, and potentially multiple rows per section. To my
9702

Find max sum of elements in array

Write a program which by given array of integer values (containing negative integers) finds the maximum sum of successive elements in the array.
4939

Algorithm to partition a number

Given a positive integer X, how can one partition it into N parts, each between A and B where A <= B are also positive integers? That is, write
4362

Plain English explanation of Theta notation?

What is a plain English explanation of Theta notation? With as little formal definition as possible and simple mathematics.
4661

Which Data Mining Algorithm is the best?

Long time listener, first time caller.
2653

How to keep a random subset of a stream of data?

I have a stream of events flowing through my servers. It is not feasible for me to store all of them, but I would like to periodically be able to process some of them in aggregate. So, I want to ...
3536

Recording a maze path solution with a stack

I am to generate a solution to a maze using a linked list implementation of a stack in some way. The maze is read in from a .txt file and consists of 0's for open spaces and 1's for walls.
4441

Chord detection algorithms?

I am developing software that depends on musical chords detection. I know some algorithms for pitch detection, with techniques based on cepstral analysis or autocorrelation, but they are mainly fo...
5421

Point in vertex defined box algorithm?

How would I test if a point is within a 3D box that is defined by its 8 points only or by its 6 quads? (Dont have access to normal vectors)
7044

Find phrase that has a specific length and is composed by certain letters

Suppose I have a list of 1 million words. I have the length of the phrase that I need to find, and I know that this word can be composed of at most 3 other words, for example Queen of England, has 14
4019

Which one is the real Bubble Sort, and which one is better?

I had an argument with a friend about the real bubble sort of the following two algorithms, and about which one is better, no mention which one is mine, I just want to hear your answers on these two
5237

time complexity of function in terms of Big-O notation?

1) Althoug i have studied about the big O notation i couldn't understand how we calculate the the time complexity of this function in terms of Big-O notation. Can you explain in detail.
3352

C++ inserting a line into a file at a specific line number

I want to be able to read from an unsorted source text file (one record in each line), and insert the line/record into a destination text file by specifying the line number where it should be inser...
463

Loops in C challenge: can it be done another way?

Hi all C experts (please don't shoot, I'm no C programmer anymore but from time to time I have a question that pops in my mind)
1428

Graph Paths Abstraction Algorithm Needed

I have a data structure holding a graph like the one in the following picture:
2467

Find all possible subsets that sum up to a given number

I'm learning Python and I have a problem with this seems to be simple task.
7120

How to choose randomly in a certain ratio

I want to choose randomly* between two alternatives with unequal probability.
9874

How can I simplify this code? (Chess game obstruction testing)

I'm making a chess game in Java, and testing to make sure there are no pieces blocking the path of the piece being moved. The piece moves from (srcX,srcY) to (dstX,dstY).
9749

Anomaly Detection Algorithms

I am tasked with detecting anomalies (known or unknown) using machine-learning algorithms from data in various formats - e.g. emails, IMs etc.
6776

Artificial Neural Network Question

Generally speaking what do you get out of extending an artificial neural net by adding more nodes to a hidden layer or more hidden layers?
3856

Algorithmical issue with point inside circle

I have a question [ silly - I admit ] about finding wherether the point is in the circle or not, I have a coordinates of the center of circle, and I know the equation, but I'm having the problem with
7624

Tribonacci series with different initial values

How to find nth tribonacci number with matrix multiplication method if the initial values are some arbitrary numbers say 1, 2 3 i.e T(1) = 1, T(2) =2 and T(3) = 3.
4721

Choosing an attractive linear scale for a graph's Y Axis

I'm writing a bit of code to display a bar (or line) graph in our software. Everything's going fine. The thing that's got me stumped is labeling the Y axis.
8480

Range tree construction

Let us consider the following picture
5339

If radix tries (or say HAT tries) are so good for storing & managing strings, why can't they be used just as well for integers?

I'm assuming they can, just treating a number by it's 32 (or 64) bit binary "string", for example. And in this case, are hash tables (say cache conscious hash tables) still on top of things when it...
8730

Machine learning: Supervised learning to learn & predict next RSA code

I was going through Andrew NG's machine learning course. I am still at the beginning stages.
7018

Avoiding dead-ends in Battleships random placement algorithm

I need some advice about building an algorithm for placing a number of ships on a board according to the rules that ships cannot overlap or touch (even diagonally). In what way could I ensure I still
9336

What implementation of average is the most accurate?

Given those two implementations of the average function:
3774

Determine if two rectangles overlap each other?

I am trying to write a C++ program that takes the following inputs from the user to construct rectangles (between 2 and 5): height, width, x-pos, y-pos. All of these rectangles will exist parallel ...
571

Improving counting of word frequencies with hashmap

For one of my applications, the following function has to be called very often. This function takes up a lot of CPU and hence I am wondering if you know how to improve the performance.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.