A friend of mine was asked the following question today at interview for the position of software developer:
Given two string s1 and s2 how will you check if s1 is a rotated version of s2 ?
Example:
If s1 = "stackoverflow" then the following are some of its rotated versions:
"tackoverflows"
"ackoverflowst"
"overflowstack"
where as...
Devise a simple algorithm which creates a file which contains nothing but its own checksum.
Let's say it is CRC-32, so this file must be 4 bytes long.
...
All i have something i have been trying to do for a while and have yet to find a good strategy to do it, i am not sure C# can even support what i am trying to do.
Example imagine a template like this, repeated in manager code overarching cocept function Returns a result consisting of a success flag and error list.
public Result<...
Hi guys! I have another question on how to make most elegant solution to this problem, since I cannot afford to go to computer school right so my actual "pure programming" CS knowledge is not perfect or great. This is basically an algorhythm problem (someone please correct me if I am using that wrong, since I don't want to keep saying th...
I was used to the traditional way of doing database searching with the following
using wildcards for term searches
using where clause for specific data like addresses and names
but at other times, I found these common methods to produce code that is so bloated, especially when it comes to complex searches.
Are there algorithms out ...
I was asked by somebody in an interview for web front end job, to write a function that generates all permutations of a string, such as "abc" (or consider it ['a', 'b', 'c']).
so the expected result from the function, when given ['a', 'b', 'c'], is
abc
acb
bac
bca
cab
cba
Actually in my past 20 years of career, I have never needed to...
I was once asked of this in an interview:
How to write a recursive function that
returns a linked list of nodes, when
given a binary tree of nodes?
(flattening the data) (Update: how about, don't just traverse the tree and add the nodes to a global structure. Make the function totally recursive, and modifying the binary tree...
Hi..
i have a problem, that i don't know how to solve it.
i have a binary string and i want to generate all possible binary substrings.
Example :
input : 10111
output: 10000, 10100,00111,00001,10110 ...
How can i do this , fast AND Smart ?
...
I like to stop the execution when Batch SOM becomes converged.
What error function can I use to determine the convergence?
...
I'm on a personal quest to learn how the rsync algorithm works. After some reading and thinking, I've come up with a situation where I think the algorithm fails. I'm trying to figure out how this is resolved in an actual implementation.
Consider this example, where A is the receiver and B is the sender.
A = abcde1234512345fghij
B = abc...
Given a string s, what is the fastest method to generate a set of all its unique substrings?
Example: for str = "aba" we would get substrs={"a", "b", "ab", "ba", "aba"}.
The naive algorithm would be to traverse the entire string generating substrings in length 1..n in each iteration, yielding an O(n^2) upper bound.
Is a better bound p...
There are many naive approaches to this problem, but I'm looking for a good solution. Here is the problem (will be implemented in Java):
You have a function foo(int a, int b) that returns true if 'a' is "adjacent" to 'b' and false if 'a' is not adjacent to 'b'. You have an array such as this [1,4,5,9,3,2,6,15,89,11,24], but in reality h...
I need to study about load-balancers, such as Network Load Balancing, Linux Virtual Server, HAProxy,...There're somethings under-the-hood I need to know:
What algorithms/technologies are used in these load-balancers? Which is the most popular? most effective?
I expect that these algorithms/technologies will not be too complicated. A...
This is for a genetic algorithm fitness function, so it is important I can do this as efficiently as possible, as it will be repeated over and over.
Lets say there is a function foo(int[] array) that returns true if the array is a "good" array and false if the array is a "bad" array. What makes it good or bad does not matter here. This ...
Hello:
I wish to determine the intersection point between a ray and a box. The box is defined by its min 3D coordinate and max 3D coordinate and the ray is defined by its origin and the direction to which it points.
Currently, I am forming a plane for each face of the box and I'm intersecting the ray with the plane. If the ray intersec...
So I have N (for example, 1000) JPEG frames and 10*N ( for example, 100) seconds of MP3 sound. I need some container for joining them into one video file (at 10 frames/second) (popular containers like FLV or AVI or MOV are better). So what I need is an algorithm or code example of combining my data into some popular format. The code exa...
Hello All,
I am writing a game which when given a partially filled word, searches a dictionary and returns all the matching words. To that effect, I am trying to find an algorithm that can be used for the said purpose. For example, given - - a -, the algorithm will search a dictionary for all the words which have length 4 and have 'a' a...
Can someone please explain algorithm for itertools.permutations routine in Python standard lib 2.6? I see its code in the documentation but don't undestand why it work?
Thanks
Code is:
def permutations(iterable, r=None):
# permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
# permutations(range(3)) --> 012 021 10...
Hello,
Which algorithm do you recommend to find out the nearest node which can be reached from the specific one by all the paths coming out the node. The graph is directed unweight.
I'm trying to analyze control flow diagram and when there is a 'IF' block I want to find the block which "closes" the 'IF'.
...
I want to align certain graph nodes into several 'lanes' like this
Any suitable algorithms (like force-based algorithms in general graph drawing)?
...