|
Crap I tried to fix my message, I read the code too fast to notice that you changed a bit more than I'd first thought.
Thank you again for your suggestions on the first function.
|
|
|
|
|
I'm blown away by N= N * Base + P - 1. Its going to take me a bit of figuring out to learn this!
|
|
|
|
|
Run it on debugger and track how variables evolves.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
And the simplified second function:
Public Function ConvertNumberToDefinition(ByVal number As Variant, _
ByVal def As String) As String
Dim Base As Integer: Base = Len(def)
Dim val As String: val = ""
Dim temp As Variant
While number > 0
temp = number Mod base
val= Mid(def, temp + 1, 1) & val
number= ( number - temp ) / base
End While
ConvertNumberToDefinition = val
End Function
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Patrice,
Thank you very much for your guidance! Rest can be assured that I am studying from these and learning.
Kindest Regards
Daniel
|
|
|
|
|
have fun with the code
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
what kind of algorithms we use to find minimum spanning tree
?
a) greedy algorithm
b) topological order
c) kosoraju sharir algorithm
d) prim algorithm
|
|
|
|
|
what did Google tell you ?
|
|
|
|
|
"greedy algorithm" - that's not even an algorithm, that's a whole class of algorithms, actually containing Prim's because it constructs the MST by growing it one edge at the time where that edge is the smallest edge that can be added. Having one option contain the other is, well, bad.
Topological order is just some order with some constraints on it, neither an algorithm nor a class of algorithms. Of course, there are algorithms that find a topological order, but they wouldn't be one. This shouldn't even be in the list.
Kosoraju is spelled Kosaraju.
4/10 bad question, you can tell your teacher I said so.
|
|
|
|
|
|
I have a very annoying problem ever since I started using Chrome. When I click on a link to open a new tab the screen flashes white or blinks in an annoying way slightly upsetting my eyes.
My ASP.NET project when run in Chrome browser shows this problem but using another browser such as Firefox or IE there is no problem.
How do you fix this problem?
|
|
|
|
|
ahasan nahid wrote: How do you fix this problem? You start by going to the correct forum[^] and posting there. You will also need to provide more information than this, to identify where the problem occurs in your code.
|
|
|
|
|
Hello I would like to ask a question about the following expressions, which I have to tell, whether they are true or false and why:
(1) n-2logn = Ω(n)
(2) n^2logn = Θ(n^2)
(3) 2n^2 + 4n - 17 = O(n^3)
(4) n^3 + 7n - 21 = Θ(n^2)
I would be really thankful is somebody could help. Thanks in advance.
|
|
|
|
|
Looks like just the sort of question for research.
|
|
|
|
|
I would say
True, False, False, False
But 3 and 4 are True if you swap the answers.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
modified 4-Dec-15 18:59pm.
|
|
|
|
|
These are not algorithms, they are just expressions and have nothing to do with Algorithm running time.
|
|
|
|
|
Requirement: using recursion, size of array is an even number.
For example:
0 1 2 3 4 5 (order of index)
a b c d e f (array before arrange)
a c e b d f (array after arrange)
0.......1.......2......3.......4......5.......6......7 (order of index)
a1....b1....a2....b2....a3....b3....a4....b4 (array before arrange)
a1....a2....a3....a4....b1....b2....b3....b4 (array after arrange)
The problem looks easy to solve if we dont care about optimization, we can use temp array or use recursion combine with a loop to shift items ... I think this way is not best solution ....I try to use recursion combine with swap operation, without using loop ... but I fail.
Hope someone suggests me an idea to resolve the problem, thanks any help
modified 1-Dec-15 4:30am.
|
|
|
|
|
It is a fairly straghtforward matter of taking all the even numbered items (0, 2, 4 etc) first, followed by the odds.
|
|
|
|
|
can you show what you have done so far ?
Your request look like HomeWork !
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
modified 1-Dec-15 16:51pm.
|
|
|
|
|
I have been developer for 5 years, I am not a student, so it's not homework ...
|
|
|
|
|
Hồng Chấn Phát wrote: I have been developer for 5 years, I am not a student, so it's not homework ... Can you show what you have done ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
I don't know if there is a general solution, but using swaps I have come up with:
N = 2 requires 0 swaps (obviously)
N = 4 requires 1 swap
N = 6 requires 3 swaps
N = 4 requires 4 swaps
N = 10 requires 6 swaps
...
Basically, moving the N/2 first elements of the pairs to the beginning requires N/2-1 swaps. The N/2 second elements are "nearly" in order, requiring only a few additional swaps.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
using System.Linq;
private int[] ints = new int[]{0,1,2,3,4,5,6,7,8,9,10};
int[] sints = ints.Where(val => (val%2 == 0)).Concat(ints.Where(val => (val%2 == 1))).ToArray(); I'm not claiming that is optimal in terms of speed of code execution; but it's faster in terms of my valuable time writing code !
If I could not use Linq:
private string[] strs = new string[]{"a1","b1","a2","b2","a3","b3","a4","b4"};
private string firstOddValue = strs[1];
List<string> strList = new List<string>{strs[0]};
for (int i = 1; i < strs.Length; i++)
{
if (i%2 == 1)
{
strList.Add(strs[i]);
}
else
{
strList.Insert(strList.IndexOf(firstOddValue), strs[i]);
}
}
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
Hi
I have a dataset and I want to perform Association Rules on it.
In other for it to predict accurately, the algorithm should have the ability to look at each attribute and decipher their association which mostly is a result of activities between each attribute in the form of multiplication, addition, subtraction, re-appearance of common patterns etc
Common association algorithms follow a basic pattern deciphering method...'comparing the re-occurrence of item sets'....
The association algorithm I have in mind should have a dynamic god capability....it should be able to determine the relationship between the attributes by going deeper such as finding out if the multiplication of the data 'value' of an instance in one attribute with another data value of an instance in another attribute has a higher rate of predictive accuracy....my workflow is in WEKA and so a compatible algorithm is needed.
I will love to interact with any coder who believes such a task can be accomplished.
cheers
|
|
|
|
|
Have you done something or it is just an idea ?
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|