algorithm

How to speed up transfer of images from client to server

I am solving a problem of transferring images from a camera in a loop from a client (a robot with camera) to a server (PC). I am trying to come up with ideas how to maximize the transfer speed so I can get the best possible FPS (that is because I want to create a live video stream out of the transferred images). Disregarding the physica...

Microsoft Interview Question : Write an efficient string matching program for string matching ?

Write a time efficient C program that takes two strings (string a, string b) and gives the first occurence of string b in string a. ...

Algorithm to find the possible number of selections

I have been asked this question and have given this quite some thought but was not able to solve it. The question is: I am asked to select n colored Pencils. There are pencils of k different color group. From each color group there are also infinitely many pencils. I want to have at least one pencil of each color group, but still there...

Auto correction , auto complete features

Hii , We see suggestions when we type a word in Ms-word , google etc... How do they do that ? I would like to know how the techniqueslike auto correct , auto complete , spell checking etc.. are performed . HOw are the words actually stored... what algorithms are followed ... ??? Any links that suggest a possible way are welcome, ...

Can this if-else statement be made cleaner

I am trying to improve a C++ assignment to make it more efficient. I am a beginner with the language (and programming in general too), so I am only using what I know so far (if, else). I have a function that converts scores into levels, so anything under 30 = 1, 30-49 = 2, 50-79 = 3 and so on... Here is how I am doing it: if (score1 ...

how do you prove that the big theta of a series is its leading term?

if f(x) = (An) x^n + (An-1) x^(n-1) +...+ (A1)x + (A0) how can you prove f(x) is big theta(x^n). I've thought about it and one could do it by proving that f(x) big O(x^n) and x^n big O(f(x)). I've figured out the proof for the former (using triangle inequality) but could not understand how to do the latter. Alternatively one could prov...

A hash function returning a value between -1 and 1

I'm searching for a hash function that takes as input any integer (positive or negative, though it could be constrained to the int range if this makes it easier), and returns a real number between -1 and 1. Is there such a function, or any obvious way to build it from another hash function? The function doesn't have to be secure, as lo...

Scheduling problem

In my project I have two JMS queues one data Queue and one Business queue. multiple threads reads data from those two queues and submit it to grid of multiple engines. Grid is having multiple engines which may execute tasks in parallel both sync and async manner. Problem statement : Events from business queue should take priority ov...

Can someone please explain how this implementation works? Also, can it be made better? How?

public class Main { public static void main(String args []){ long numberOfPrimes = 0; //Initialises variable numberOfPrimes to 0 (same for all other variables) int number = 1; int maxLimit = 10000000; boolean[] sieve = new boolean[maxLimit]; //creates new boolean array called sieve and allocates sp...

Car steering algorithm ?

hi, i've already asked something similar, but now i've the problem to manage and realize a "realistic" steering for a simple 2d (top-down) car racing game. How can i do a "realistic" steering for the car ? (i use c# but another language is welcome;)) Using Sin and Cos ? If yes, how ? Thanks in advance! ...

Algorithm that can turn a linear programming problem to a feasible one.

Hi, I need an algorithm that automatically makes a linear programming problem feasible. Concretely, the algorithm is such that its input is a linear programming problem which potentially does not have feasible solutions, and its output is a similar programming (with parameters modified with minimum) which is bound to have feasible soluti...

List/tree/Stack - Algorithm

Hey guys, I need to do a project at the college, it needs to use list/tree/stack to perform any task. I was thinking on the Google's algorithm to recognize the phrase while the guy is typing. Does anyone has this algorithm? Or any other better idea that use list/tree/stack? Thanks ...

Help In Learning Algorithm Basics

Hi Guys, I am learning algorithms and need you guys to help me. I am a beginner so forgive me if my question is not clear. Whiles am learning i am seeing something like NlogN, N^2 etc.. and something like that. I don't really understand it clearly when it comes to checking the efficiency/performance of different algorithms using these...

Finding all shortest paths and distances using Floyd-Warshall

First, a little background: I'm working on building a simple graph class with basic graph algorithms (Dijkstra, Floyd-Warshall, Bellman-Ford, etc) to use as a reference sheet for an upcoming programing competition. So far I have a functioning version of Floyd-Warshall, but the downside is that so far it's only getting me the shortest di...

Quick sort Worst case

I am working on the program just needed in the following to understand it better. What is the worst case running time for Quicksort and what may cause this worse case performance? How can we modify quicksort program to miggate this problem? I know that it has worst case O(n^2) and i know it occurs when the pivot unique minimum or maxim...

Finding Center of The Tree

I have a question which is part of my program. For a tree T=(V,E) we need to find the node v in the tree that minimize the length of the longest path from v to any other node. so how we find the center of the tree? Is there can be only one center or more? If anyone can give me good algorithm for this so i can get the idea on how i ca...

How to suggest friend lists for facebook user based on mutual friends ?

Hi everyone, I'm building a application to suggest friend lists for facebook user based on his/her mutual friends with each friend. My idea looks like that: http://i219.photobucket.com/albums/cc213/DoSvn/example03.png I can get all mutual friends of A with each his/her friend (b1, b2...). It's the intersection between b1, b2... (c1...

Finding if something is within a range programmatically.

I know this is a simple math problem but for some reason im drawing a blank. If I have two ints which are boundaries for a range: int q = 100; int w = 230; and then another in that is a number that I want to see if it is inside of the range: int e = ?; How can I find if e is in the bounds of q and w? ...

Unit-Length Closed Intervals

I am working on a program that has somewhat focus on the below: unit-length closed interval on the real line is an interval [x, 1+x]. For given input set X={x1,x2,..., Xn}, x1 < x2 <...xn, how can i determine the smallest set of unit-lenght closed intervals that contains all of the given points and how i calculate time complexity. I ...

How can I replace each new line with a auto-incremented number?

I am lookind for a effective way that I can replace newlines with an auto-incrementing number. eg. this is line 1 this is line 2 this is line 3 this is line 4 to 1. this is line 1 2. this is line 2 3. this is line 3 4. this is line 4 Is looping through each line the only way? I guess thats the way I will implement it for now. U...