|
(Apart from question being unclear) Probability is a "chance", it does not guarantee 100% "successful" answer. So even if you could get an algorithm it won't guarantee to be correct.
The accuracy of answer is 100%, only when there is one answer. In two options, there is a probability of 50/50 (50%) and so on.
answer := 1/n
Where n is the number of answers; options. The example of "coin flip" is a good way to demonstrate this. You flip a coin and your friend selects one. That is the probability. It can be correct or it can be false.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
modified 5-Jan-16 6:47am.
|
|
|
|
|
Hello There,
Please keep in mind that I am not the brightest person in the bunch, that is why I am here asking for help. Because of my lack of education in math, I've been kind of creating my own solutions =/
This code is written in Microsoft Visual Basic for Applications (VBA) 7.0 and used in a Microsoft Access 2010 application.
Sometime in the past year, I created a function that converted non-decimal based string values. Like HEX "0123456789ABCDEF" and/or any other numbering definition you can think of.
I have recently come across another application that requires a custom format of numbering. Bringing me to revise the old function with the new, containing a formula that I wrote out.
The Revised function:
Code:
Public Function ConvertStringToDecimal(ByVal str As String, _
ByVal def As String) As Variant
str = Trim(str & vbNullString)
def = Trim(def & vbNullString)
If Len(str) = 0 Then: ConvertStringToDecimal = "No value has been entered.": Exit Function
If Len(def) < 2 Then: ConvertStringToDecimal = "Number definition must have 2 or more characters.": Exit Function
Dim LD As Integer: LD = Len(def)
Dim LV As Integer: LV = Len(str)
Dim N As Variant: N = CDec(0)
Dim I As Integer
Dim P As Integer
str = ReverseString(str)
For I = 1 To LV
P = InStr(1, def, Mid(str, I, 1))
If P > 0 Then: N = N + CDec((P - 1) * (LD ^ (I - 1)))
Next
ConvertStringToDecimal = N
End Function
What I would like to request your help with is the design of a Convert decimal to number definition function. I have a working one, but I can't seem to figure out if it is the most effective way to go about doing it.
This function will retrieves a decimal based number and converts it to a definition string:
number: "12345"
def: (hex) "0123456789ABCDEF"
or (binary) "01"
or (custom) "!@#$%^&*()1234567890ABCDEFGHIJKLMNOP"
I'm not satisfied with the way that I went about figuring out my starting point.
Here she is:
Code:
Public Function ConvertNumberToDefinition(ByVal number As String, _
ByVal def As String) As String
Dim length_of_def As Integer: length_of_def = Len(def)
Dim dec_number As Variant: dec_number = CDec(number)
Dim I As Variant: I = CDec(0)
Dim j As Variant: j = CDec(0)
Dim val As String
Dim temp As Variant: temp = CDec(0)
Dim index_value As Variant: index_value = CDec(0)
For I = 0 To dec_number
If (length_of_def ^ I > dec_number) Then
For j = I - 1 To 0 Step -1
index_value = length_of_def ^ j
temp = dec_number Mod index_value
val = val & Mid(def, ((dec_number - temp) / index_value) + 1, 1)
dec_number = temp
Next
Exit For
End If
Next
ConvertNumberToDefinition = val
End Function
Thanks,
Dan
|
|
|
|
|
Here is a simplified version of the first function.
Public Function ConvertStringToDecimal(ByVal str As String, _
ByVal def As String) As Variant
If Len(str) = 0 Then: ConvertStringToDecimal = "No value has been entered.": Exit Function
If Len(def) < 2 Then: ConvertStringToDecimal = "Number definition must have 2 or more characters.": Exit Function
Dim Base As Integer: Base = Len(def)
Dim LV As Integer: LV = Len(str)
Dim N As Variant: N = CDec(0)
Dim I As Integer
Dim P As Integer
For I = 1 To LV
P = InStr(1, def, Mid(str, I, 1))
if P = 0 then ConvertStringToDecimal = "Unknown digit.": Exit Function
N= N * Base + P - 1
Next
ConvertStringToDecimal = N
End Function
you should not prep the parameters because it prevent the use of space in definition and removing spaces in definition is changing the values of digits.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
BlueIshDan wrote: P will always end up being 0 at some point. Only if you provide an unknown digit.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
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
|
|
|
|