<![CDATA[CodeGuru Forums - Algorithms & Data Structures]]>
http://forums.codeguru.com/
enWed, 01 Apr 2015 00:09:02 GMTvBulletin60http://forums.codeguru.com/images/misc/rss.png<![CDATA[CodeGuru Forums - Algorithms & Data Structures]]>
http://forums.codeguru.com/
given postorder and inorder,output preorder
http://forums.codeguru.com/showthread.php?549893-given-postorder-and-inorder-output-preorder&goto=newpost
Mon, 30 Mar 2015 09:44:53 GMTsolveddddsolvedddd
]]>tonsonsonhttp://forums.codeguru.com/showthread.php?549893-given-postorder-and-inorder-output-preorderHandling and implementing Nested data
http://forums.codeguru.com/showthread.php?549891-Handling-and-implementing-Nested-data&goto=newpost
Mon, 30 Mar 2015 04:52:25 GMTHello..!
I am working with a data structure that has to be handled and implemented in a relational database having nested fields of SHARES with lists of OWNERS related to each leaf node of the shares. See attached Model Image:
Attachment 33455 (http://forums.codeguru.com/attachment.php?attachmentid=33455)
The model represents Two Basic information Share and Owners. Shares are also represented in plain form for calculation purpose. (2592, 24, 40 are the total of shares at respective level)Hello..!
I am working with a data structure that has to be handled and implemented in a relational database having nested fields of SHARES with lists of OWNERS related to each leaf node of the shares. See attached Model Image:
The model represents Two Basic information Share and Owners. Shares are also represented in plain form for calculation purpose. (2592, 24, 40 are the total of shares at respective level)
]]>erncd1http://forums.codeguru.com/showthread.php?549891-Handling-and-implementing-Nested-dataInter-Migration with special rules - Algorithmic
http://forums.codeguru.com/showthread.php?549883-Inter-Migration-with-special-rules-Algorithmic&goto=newpost
Sun, 29 Mar 2015 17:58:57 GMT=0, a set of positive integers (e for entity)
Given L={l1..lm}, m>=0, a set of positive integers (l for location)
Given P:E --> L , a function. (P for position)
Given C:L --> IN*, a function. (C for capacity)
Given U:L --> IN, a function. (U for used) defined by: U(l)=card({e/P(e)=l})
Given A:L --> IN, a function. (A for available) defined by: C(l)=A(l)+U(l) for any l in L.
Let D:E --> L^k, where 0 < k <= m, D(e)=(l1,l2,..li) a function (D for destinations)
(That is, each entity has an ordered non-empty list of locations (destinations) willing to move to).
Let I:E --> IR+, a bijection (I for Importance). (That is, each entity has a unique importance number I(e))
II/Rules of Migration:
The asked task, is to find out the new P' function (Positioning) that affords the following:
1- P'(e) belongs to {l'1,l'2,..,l'i} where (l'1,l'2,..,l'i)=D(e)
2- If we P'(e)=l's and P'(e)=l't are two possible solutions, where D(e) = (l'1,...,l's,...,l't,...,l'i), then we must keep the solution that matches the destinations' order (i.e l's in this case) and exclude the other one)
3-If A(l) = 1 and P(e1)=l and P(e2)=l are two possible solutions, where I(e1)>I(e2) then we must keep the solution that matches the importance's order (i.e in this case P(e1)=l) and exclude the other one.
4- If none of the desired destinations is possible, then P'(e)=P(e)
Which algorithmic problem would match this one, Thanks.]]>I/ Algebraic modeling of the problem
Given E={e1..en}, n>=0, a set of positive integers (e for entity)
Given L={l1..lm}, m>=0, a set of positive integers (l for location)
Given P:E --> L , a function. (P for position)
Given C:L --> IN*, a function. (C for capacity)
Given U:L --> IN, a function. (U for used) defined by: U(l)=card({e/P(e)=l})
Given A:L --> IN, a function. (A for available) defined by: C(l)=A(l)+U(l) for any l in L.
Let D:E --> L^k, where 0 < k <= m, D(e)=(l1,l2,..li) a function (D for destinations)
(That is, each entity has an ordered non-empty list of locations (destinations) willing to move to).
Let I:E --> IR+, a bijection (I for Importance). (That is, each entity has a unique importance number I(e))
II/Rules of Migration:
The asked task, is to find out the new P' function (Positioning) that affords the following:
1- P'(e) belongs to {l'1,l'2,..,l'i} where (l'1,l'2,..,l'i)=D(e)
2- If we P'(e)=l's and P'(e)=l't are two possible solutions, where D(e) = (l'1,...,l's,...,l't,...,l'i), then we must keep the solution that matches the destinations' order (i.e l's in this case) and exclude the other one)
3-If A(l) = 1 and P(e1)=l and P(e2)=l are two possible solutions, where I(e1)>I(e2) then we must keep the solution that matches the importance's order (i.e in this case P(e1)=l) and exclude the other one.
4- If none of the desired destinations is possible, then P'(e)=P(e)
Which algorithmic problem would match this one, Thanks.
]]>MedUNEShttp://forums.codeguru.com/showthread.php?549883-Inter-Migration-with-special-rules-AlgorithmicTriangular Encryption of Data
http://forums.codeguru.com/showthread.php?549845-Triangular-Encryption-of-Data&goto=newpost
Thu, 26 Mar 2015 16:29:57 GMTThis one-way, triangular function is an encryption algorithm which begins by stripping away the left most edge of the input and does a "flip and replace" prior to a quad-xor process. This algorithm is written in Autoit (see commented code in attached zip) and is attached along with a .exe.
]]>kjsiscohttp://forums.codeguru.com/showthread.php?549845-Triangular-Encryption-of-DataWhich Algorithm of Tree component?
http://forums.codeguru.com/showthread.php?549775-Which-Algorithm-of-Tree-component&goto=newpost
Sat, 21 Mar 2015 17:26:53 GMT a, g
a->b,c
b->d,e
c->f
My two problems:
1. find visual position for node
2. find node for visual position
Point 2 will be easy if exists list of this nodes, for example a b d e c f g
If expand, collapse, we must move block, if b collapses then list will a b c f g
Point 1 still difficult
Worst - adding node requires point 1 and move block many times - it is too slow
Second solution: In list is field VisibleCount - semi-expanded size of each branch
add node requires update VisibleCount only parent, parent->parent etc..
But points 1 and 2 still difficult]]>I am trying create Tree component from scratch. Each node can have list of nodes. Any node can be expanded or not.
Is necessary one list across all list,
for example:
Code:
a
b
d
e
c
f
g
this list will be a b d e c f g (visual position a=0,b=1,d=2 etc)
whereas physically elements are stored on lists:
root-> a, g
a->b,c
b->d,e
c->f
My two problems:
1. find visual position for node
2. find node for visual position
Point 2 will be easy if exists list of this nodes, for example a b d e c f g
If expand, collapse, we must move block, if b collapses then list will a b c f g
Point 1 still difficult
Worst - adding node requires point 1 and move block many times - it is too slow
Second solution: In list is field VisibleCount - semi-expanded size of each branch
add node requires update VisibleCount only parent, parent->parent etc..
But points 1 and 2 still difficult
]]>Borneqhttp://forums.codeguru.com/showthread.php?549775-Which-Algorithm-of-Tree-componentHow to write pseudocode for these questions?
http://forums.codeguru.com/showthread.php?549763-How-to-write-pseudocode-for-these-questions&goto=newpost
Sat, 21 Mar 2015 06:44:15 GMTHow do I write pseudocode where input is a table and output is a list for this example:
Please see the table attached.
It's a table where the first column are students in a classroom and they are ranked based on their performance from the exams.
A. I want to write a pseudocode algorithm to determine the rank changes after the exam. Input is the table with n rows, and 5 columns. So far I have this: M[n-1,4]
The output should be a list with the differences in ranks for each student. For example [2,3, -4, 0, -7]
B
How do I write a pseudocode algorithm to determine which student scored at least 90% of the questions they completed. Output should produce a list eg.[0,4]
Thanks for your help.
]]>katetseneohttp://forums.codeguru.com/showthread.php?549763-How-to-write-pseudocode-for-these-questionsOutlier Detection Algorithm
http://forums.codeguru.com/showthread.php?549649-Outlier-Detection-Algorithm&goto=newpost
Fri, 13 Mar 2015 16:20:57 GMTHi,
I want to filter option price data for outliers. Therefore I compute
implied volas for each option and plot vola for a specific date and days to expiration over strike.
This gives the so called vola smile/vola smirk. Now I want to filter those data for outliers
and I'm looking for an efficient algorithm to do this.
I found RANSAC, but it seems to be quite expensive.
Is there anything else that could do the job less expensive?
]]>Stephan_Shttp://forums.codeguru.com/showthread.php?549649-Outlier-Detection-AlgorithmA question regarding stack size
http://forums.codeguru.com/showthread.php?549629-A-question-regarding-stack-size&goto=newpost
Fri, 13 Mar 2015 00:55:41 GMTnext);
printf("%d\n", head->data);
}
}
---------
If there is 10 nodes in the linked list(I assume it is a single linked list), what is the stack size used in calling ReadBack? I think it would be (10+1)*4(each pointer is 4 bytes long). Am I right? How'd I know the system stack size? If there is millions of nodes in the linked list, it might pass the system stack size. In that case, how can I do? Thanks.]]>Suppose we want to read a linked list backward. The implementation using recursion is very simple,
If there is 10 nodes in the linked list(I assume it is a single linked list), what is the stack size used in calling ReadBack? I think it would be (10+1)*4(each pointer is 4 bytes long). Am I right? How'd I know the system stack size? If there is millions of nodes in the linked list, it might pass the system stack size. In that case, how can I do? Thanks.
]]>LarryChenhttp://forums.codeguru.com/showthread.php?549629-A-question-regarding-stack-sizeTrapezoidal Motion Profile Using Discrete Method
http://forums.codeguru.com/showthread.php?549565-Trapezoidal-Motion-Profile-Using-Discrete-Method&goto=newpost
Mon, 09 Mar 2015 15:55:13 GMT'm trying to program an arduino to generate a Trapezoidal Motion Profile to control a DC motor with a quadrature encoder.
Essentially, the user will input the desired Target Position, Max Velocity and Acceleration (decel = -accel) and the code will calculate the target position versus time which will then be compared with the actual position. The result will then be subject to a PID calculation
My initial assumption was that I could use basic Newtonian physics to determine position (i.e. PT = P0 + V0T + 1/2AT2, VT = V0 + AT). However, after reading through documentation for pre-existing motion controllers, I discovered that the prevalent method was to use a discrete time method, which is as follows:
VK = VK-1 + A (A = Acceleration) PK = PK-1 + VK-1 + A/2
I'm having a hard time understanding quite how this equation would generate the target position versus time. In the case of Velocity, it seems to just add the acceleration to the current velocity. But what about everything in between?
Could anybody take a shot at explaining to me how this method is used? I've spent ages searching for answers online but have had no such luck.
]]>martinrandhttp://forums.codeguru.com/showthread.php?549565-Trapezoidal-Motion-Profile-Using-Discrete-Method<![CDATA[What is the optimal solution for the game "Puzzle+"?]]>
http://forums.codeguru.com/showthread.php?549561-What-is-the-optimal-solution-for-the-game-quot-Puzzle-quot&goto=newpost
Mon, 09 Mar 2015 15:41:01 GMTA friend challenged me to find an algorithm to solve the game Puzzle+:
In a nutshell: given a NxM array of random booleans, your objective is turn all values to false.
On each move you specify a coordinate (x,y) to toggle (array[x][y] = not array[x][y]), however that action also affects array[x-1][y], array[x+1][y], array[x][y-1], array[x-1][y+1] (on in short - it's adjacent cells).
For example: given a 3x3 board: |f T f|
|T T T|
|f T f|
I could only come up with a brute-force solution. Can any one advice an efficient approach? O(n)?
]]>MkJoneshttp://forums.codeguru.com/showthread.php?549561-What-is-the-optimal-solution-for-the-game-quot-Puzzle-quotRelationship between number of clusters and relative distance btw cluster centroids
http://forums.codeguru.com/showthread.php?549543-Relationship-between-number-of-clusters-and-relative-distance-btw-cluster-centroids&goto=newpost
Mon, 09 Mar 2015 01:34:20 GMTHi all
I have a fundamental clustering related question, so if you are a clustering specialist you may be able to help here. The question is theoretical (computer science) in nature.
I am using a k-means clustering algorithm to cluster some objects. I have the suspicion (hypothesis) that when I increase the number of clusters (this is a parameter of the algo), then the distance between any two cluster centroids will reduce, on average.
For example, let's say I have a data set with n objects. Then, I cluster these n objects using c = {1, 2, 3, ..., 9, 10} clusters. I.e. I run the algo on the same data, ten times, with different number of clusters each time. Then, after each run, I measure the pair-wise distance between the centroids, and average the distances. So, my hypothesis is that, with increasing number of clusters, this distance will decrease.
Is this a relationship that can be shown/proven on the basis of fundamental clustering concepts? Or is it a relationship that would need to be proven through an experiment?
If my question is not clear, please let me know.
Thanks for helping.
Kind regards
Al
]]>ahlandberghttp://forums.codeguru.com/showthread.php?549543-Relationship-between-number-of-clusters-and-relative-distance-btw-cluster-centroidsarannge numbers in descending order
http://forums.codeguru.com/showthread.php?549473-arannge-numbers-in-descending-order&goto=newpost
Tue, 03 Mar 2015 21:05:33 GMTis there a way to arrange 5 user inputs in descending order using a for or while loop?
I'm using netbeans.
]]>cheveychick09http://forums.codeguru.com/showthread.php?549473-arannge-numbers-in-descending-order