|
The code already exists in most applications, and is commonly executed by the Ctrl+C - Ctrl+V sequence. The first thing you need to decide is what this program of yours is supposed to do: copy, copy and paste, or just paste. Also what language do you plan to write it in?
|
|
|
|
|
I should prepare an Algorithm Exam but some of the Questions sound strange to me... if someone can help me it can be really great...
-It's possible to order an HEAP in time o(n log(n))?
-It's possible to create an HEAP in time o(n log(n))?
-It's possible to order a BST in time o(n log(n))?
-It's possible to create a BST in time o(n log(n))?
Thank you from now and sorry for my bad english
modified 9-Feb-16 11:13am.
|
|
|
|
|
|
Hi,
Given a set of points data, does any one know how to formulate Bezier Spline surface.
Thanks in advance.
SSETH
|
|
|
|
|
Please post questions once only.
|
|
|
|
|
My earlier question is completely different than this one..
Thanks.
|
|
|
|
|
It may be slightly different, but in essence it is the same issue.
|
|
|
|
|
No Richard..The earlier question was for "curve"... And this one is for "surface". which is pretty complex than Curve.
|
|
|
|
|
|
Not really, a surface is composed of two curves, so it is the same question. If you don't understand curves, you won't understand surfaces. Simple as that.
|
|
|
|
|
Can any one suggest how to create C2 continuous piece wise Bezier spline curve with vector method?
Thanks in advance.
~SSETH
|
|
|
|
|
What do you mean by create?
|
|
|
|
|
|
Does it make any sense to test decision tree on dataset generated randomly? example: (the output "true"/"false" is not conditioned on parameters 1-10)
for (int i = 0; i < l; i++)
{
string[] new_ex = new string[11];
new_ex[0] = ThreadSafeRandom.ThisThreadsRandom.Next(60)%5 == 1 ? "true" : "false";
for (int r = 1; r < 5; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(60)%3).ToString();
for (int r = 5; r < 7; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(60)%3).ToString();
for (int r = 7; r < 9; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(20)%5).ToString();
for (int r = 9; r < 11; r++)
new_ex[r] = (ThreadSafeRandom.ThisThreadsRandom.Next(4)).ToString();
dataset.Add(new_ex);
}
|
|
|
|
|
If your goal was obfuscation, you've accomplished that.
(Consider a generic string LIST and .Add method in the main body).
|
|
|
|
|
coding issues are not relevant, its more like theoretical question but thanks for hints
|
|
|
|
|
I've used random number generation to simulate queues / arrival rates; so yes, decision trees based on random data has it's place.
|
|
|
|
|
Let's assume that ‘k’ is an integer that indicate and reveals exactly the length of subset that sum to 0. Thus length of subset to pick is determined by ‘k’. If I would like to pick only ‘k’ distinct set of integers from any given set of integers in polynomial time without having needed to check through every possible length other than the chosen length. What will be the time complexity and the size of subset for every given subset sum problem?
For example:
Given a set of integers {-3, 17, 30, 12, -8 -15, 7, 45, 16, 9} is there a non-empty subset whose sum is zero? Yes, because k = 5. Output {-3, 17, -8, -15, 9 = 0}
Given a set of integers {12, 5, -6, 7, -22} is there a non-empty subset whose sum is zero? No, because k = null. Output none
Given a set of integers {8, 20, 3, 35, -2, 3, 40, 7, 16, -9, 25} is there a non-empty subset whose sum is zero? Yes, because k = 5. Output {8, 3, -2, -9 = 0}
Given a set of integers {-2, 10, 15, 20, 3, 12, 45, -6, 17, 1, 18, 5} is there a non-empty subset whose sum is zero? Yes because k = 9. Output {-2, 15, 3, 12, -45, -6, 17, 1, 5 = 0}
etc..
modified 5-Feb-16 13:17pm.
|
|
|
|
|
|
Thanks for the response but what I’m trying to say is that will I always find solution in polynomial time if ‘k’ is always right for every given subset sum problem?
|
|
|
|
|
See my April 2014 Tip/Trick: Subset - Sum Problem with Numeric Collections [^]
which includes a very efficient way to generate all possible combinations of n items.
Optimizing to make it more efficient for combinations of n choose k should not be too difficult.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
Thanks for the response but what I’m trying to say is that will I always find solution in polynomial time if ‘k’ is always right for every given subset sum?
|
|
|
|
|
Hello,
I have a class Tree
public class Tree{
private int tree_height;
private int tree_width;
private int nodes_count;
private List<Node> tree_nodes;}
and class node
public class Node{
private object state;
private int ordering;
private int height;
private int parent;}
I would like to create a method to add a branch to a tree
here is my code:
public void AddBranch(Tree branch, int node_num)
{
if (nodes_count >= node_num && node_num > 0)
{
int last_el_ordering = nodes_count,
first_parent_height = tree_nodes[node_num - 1].Height,
first_parent_ordering = tree_nodes[node_num - 1].Ordering;
tree_nodes.Add(new Node(branch.Tree_nodes.First().State, last_el_ordering + 1, first_parent_ordering, first_parent_height + 1));
foreach (Node el in branch.Tree_nodes.Skip(1))
tree_nodes.Add(new Node(el.State, el.Ordering + last_el_ordering, el.Parent + last_el_ordering, el.Height + first_parent_height));
tree_nodes = tree_nodes.OrderBy(match => match.Height).ToList();
int i = 1;
foreach (Node el in tree_nodes)
{
List<Node> temp = tree_nodes.ToList().FindAll(match => match.Parent == el.Ordering).ToList();
el.Ordering = i++;
if (temp.Count() > 0)
foreach (Node el2 in temp)
el2.Parent = el.Ordering;
}
}
}
I have a little problem when I add new node after connecting two trees eg: to tree
first
a b c
false false false
i want to add a branch
d
false
to the first node
The label "false" which is child of "d" is getting misplaced and I cannot figure out why. Please help.
the input
Tree testing_tree1 = new Tree(new Node("start"));
List<string> temp = new List<string> { "a", "b", "c" };
foreach(string el in temp)
testing_tree1.AddBranch(new Tree(new Node(el)),1);
for (int i = 0; i < 3; i++)
testing_tree1.AddBranch(new Tree(new Node("false")), i+2);
Tree testing_tree2 = new Tree(new Node("d"));
testing_tree2.AddBranch(new Tree(new Node("false")), 1);
testing_tree1.AddBranch(testing_tree2, 1);
testing_tree1.DisplayTree();
Console.Read();
the output
tree depth: 3 tree width: 4 nodes count: 9
Node number:1, Node parent:-1, Node height:1, Node value:start
Node number:2, Node parent:1, Node height:2, Node value:a
Node number:3, Node parent:1, Node height:2, Node value:b
Node number:4, Node parent:1, Node height:2, Node value:c
Node number:5, Node parent:1, Node height:2, Node value
Node number:6, Node parent:2, Node height:3, Node value:false
Node number:7, Node parent:3, Node height:3, Node value:false
Node number:8, Node parent:4, Node height:3, Node value:false
Node number:9, Node parent:8, Node height:3, Node value:false
|
|
|
|
|
Use the debugger and see what your code is really doing.
The debugger permit you to execute your code line by line and inspect variables during execution.
You should see that somewhere, your code is not doing as expected.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
Good morning sirs,
please I need your help on a project I am working on, I am new to this discussion forum on algorithm(but not to CodeProject) and new to algorithm itself, someone directed me here.
I started a project on algorithm for plotting SkewT-lnP chart, I have written all other algorithms to do all needed calculations including that of the grids but am stock on how to write the main algorithm for plotting the SkewT chart and the type of graphics library to use. am using c# language and vs2010 IDE.
thanks
|
|
|
|
|