Hello. I have 2 vector . The first vector save the gradiend of 1 color . For example: from
green to white. I want to color an image via pixel . for example we give the cordinate of an pixel (X ,Y) and dhe color RGB 40 , 60 , 120 and to color this pixel ect..
Is any function in php that can do this ??
...
I have a binary tree of some shape. I want to Convert it to BST search tree of same shape. Is it possible?
I tried methods like -
Do In-order traversal of Binary Tree & put contents into an array. Then map this into a BST keeping in mind the condition (left val <= root <= right val). This works for some cases but faile for others.
...
I have an array with vertices representing a triangular strip.
I need to convert it into polygon.
There are many solution to do the reverse, but I failed to find one for the above problem.
Or it could be too easy and I just cannot see it.
Please help.
OpenGL=compatible, see
http://en.wikipedia.org/wiki/Triangle_strip
Example:
for thi...
Hello,
Given an integer n , i want to toggle all bits in the binary representation of that number in the range say lower to upper.
To do this i do the following [bit_string is a string containing 1's and 0's and is a binary representation of n]
for i in range(lower,upper+1):
n ^= (1 << len(bit_string)-1-i) #Toggle the ith bit
Then...
From what I have read on the web, one of the most efficient algorithms for image stabilization is to use Gray coded bit plane matching. However, I'm having trouble understanding it (Gray codes themselves are not that complex, it's the rest of it). Can anyone point me to a resource on this subject (or another good method of stabalizatio...
Given a set of two or more logical conditions, is it possible to algorithmically determine that exactly ONE of them will evaluate to TRUE? For example:
# this should pass, since for every X, only one condition is taken
cond 1: (X >= 1.0)
cond 2: (X < 1.0)
# this should fail
cond 1: (X < 1.0)
cond 2: (X > 2.0)
# this should also fail,...
I understand pre-order, in-order, and post-order tree traversal algorithms just fine. (Reference). I understand a few uses: in-order for traversing binary search trees in order, pre-order for cloning a tree. But I can't for the life of me come up with a real world task that I'd need post-order traversal to accomplish.
Can you give me ...
My code processes a huge number of values and I'm looking for an efficient structure to keep track of the top (N) values, where N is less than 10, so collecting ALL numbers then sorting the list and taking the first (N) is probably not the most efficient way.
To do that, I'm building a collection of fixed size N, to keep the top (N) va...
std::vector<std::wstring> lines;
typedef std::vector<std::wstring>::iterator iterator_t;
iterator_t eventLine = std::find_if(lines.begin(), lines.end(), !is_str_empty());
how do I define is_str_empty? i don't believe boost supplies it.
...
Does anyone know of a basic beginners tutorial on how to read mark up like this notation when talking about algorithms or what this type of markup is officially referred to as so I know what to google for?
taken from here.
...
At the moment I am working on an on screen display project with black, white and transparent pixels. (This is an open source project: http://code.google.com/p/super-osd; that shows the 256x192 pixel set/clear OSD in development but I'm migrating to a white/black/clear OSD.)
Since each pixel is black, white or transparent I can use a sim...
This question is slightly different from the kind of finding longest sequence or substring from two strings.
Given two string of the same size N, find the longest substrings from each string such that the substrings contains the same bag of chars.
The two substrings may not necessarily have the same sequence. But they must have the sam...
I need to hash a message into a string of 30 chars. What's the best and most secure hash function for this usage?
...
Hi,
I have two byte[] and I want to find the first occurrence of the second byte[] in the first byte[] (or a range in it).
I don't want to use strings for efficiency (translating the first byte[] to a string will be inefficient).
Basically I believe that's what strstr() does in C.
What is the best way to do that (so it be efficient a...
I'm making a simple RTS game. I want it to run very fast because it should work with thousands of units and 8 players.
Everything seems to work flawlessly but it seems the line of sight calculation is a bottleneck. It's simple: if an enemy unit is closer than any of my unit's LOS range it will be visible.
Currently I use a quite naive ...
Hi everyone!
I just saw this question and have no idea how to solve it. can you please provide me with algorithms , C++ codes or ideas?
This is a very simple problem. Given the value of N and K, you need to tell us the value of the binomial coefficient C(N,K). You may rest assured that K <= N and the maximum value of N is 1,000,000,...
I have this algorithm that I found here, just one thing puzzles me about it:
Clear the stencil buffer to 1.
Pick an arbitrary vertex v0, probably somewhere near the polygon to reduce floating-point errors.
For each vertex v[i] of the polygon in clockwise order:
let s be the segment v[i]->v[i+1] (where i+1 will wrap t...
Wikipedia says
Base64 encoding schemes are commonly used when there is a need to encode binary data that needs be stored and transferred over media that are designed to deal with textual data. This is to ensure that the data remains intact without modification during transport.
But is it not that data is always stored/transmitted i...
I'm currently working on a scanner generator.
The generator already works fine. But when using character classes the algorithm gets very slow.
The scanner generator produces a scanner for UTF8 encoded files. The full range of characters (0x000000 to 0x10ffff) should be supported.
If I use large character sets, like the any operator '....
Are there examples of algorithms for determining the edit distance between 2 strings when there are extra primitive operations (the standard being insert, delete, transpose & substitute a single character) which operate on a whole substring. Examples of possible extra primitive operations are:
1) The duplicate function - which copies an...