@all just a small bug found after discussing with one of the friend , i
forgot to put the for loop , in 2nd if condition .
Thanks
Shashank
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
@Samm, Don't you think quadratic approach will be naive ? we can use
comparator while checking .thining how we can do it more better ?
Thanks
Shashank
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
@atul approach sounds good but we have to check for each time counts
updated isn't it , though even can sort the hash table return top k
number .
also as i know we have splay tree , even google uses it , to get most
frequent item .
Thanks
Shashank.
--
You received this message because
A better representation for a n-ary tree would be
struct node{
int data;
node* left;
node* sibling;
}
Like in a binary tree the second ptr points to its right child . Here it
points to its sibling.This one saves space and also We know in each level
we have how many nodes
@Shashank,
I
How abt representing the tree as a graph. If you represent it in
adjacency mattix or as a map of edges e.g. Edge{from}{to}=edge weight,
which could be a constant in this case. all you need to is to reverse
the pairs.
Order of complexity is o(e) and you can reach to leaf nodes and push
them in a
@Ankur : didnt understand , how you want to represent n-ary using this
structure.
struct node{
int data;
node* left;
node* sibling;
}
if root has 5 children then how will root point to its children using 2
pointers( left ,sibiling)
On Wed, Dec 21, 2011 at 3:13 PM, Ankur Garg
@shashank:
yeah here is the algo , please me know if you find any bug:-
node *Reverse(node *root,node *pre)
{
flag=0;
for i=0 to n
if (root-children[i]!=NULL)
{
flag=1;
}
end for
if( ! flag)
{
i guess there is one more if i am not wrong;
if(n==null)
{
n=n.children[++j];
return null;
}
here when n==NULLyou are doing n.children[++j].will give
segmentation fault.
On Wed, Dec 21, 2011 at 7:05 PM, WgpShashank
Find the distance between each of the points and the origin(0,0) and sort
the points based on this distance.
Also, divide the points based on which quadrant they belong. If the
difference between their distance(from origin) between 2 points is less and
they belong to the same quadrant, then they
@Shashank:
well i guess there is one more issue with my algo. if counter is updated
for say number 3.
and heap has already node with value 3 and count 2.
now root could be node with value 5 and count 1.
if i remove root from the heap, then heap will be havingi will be having 2
node with value 3
Yes Quadratic approach will be naive . I thought initially to take the
input from the Liveware , and do the below :-
And we will computer for the number of unique number possible for 1
digit , Let the number of possible distinct permutation be X . And if
X = K , then we can generate the single
@Algoose, in worst case, this is still O(n^2), ain't it?
On Wed, Dec 21, 2011 at 12:50 PM, Algoose chase harishp...@gmail.comwrote:
Find the distance between each of the points and the origin(0,0) and sort
the points based on this distance.
Also, divide the points based on which quadrant they
Yup, it could be O(n^2) in the worst case.
On Wed, Dec 21, 2011 at 1:59 PM, Carol Smith carol.interv...@gmail.comwrote:
@Algoose, in worst case, this is still O(n^2), ain't it?
On Wed, Dec 21, 2011 at 12:50 PM, Algoose chase harishp...@gmail.comwrote:
Find the distance between each of the
@harish What if all the points are in the same quadrant and and are equidistant
from 0,0.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/NjysUthIqgYJ.
To
or google This : cs170
On 12/17/11, Abhishek Goswami zeal.gosw...@gmail.com wrote:
ya Sure Thx bro
On Sat, Dec 17, 2011 at 3:15 PM, Rahul raikra...@gmail.com wrote:
If you have time then Do a Google this
www.algo-class.org
On Sat, Dec 17, 2011 at 3:13 PM, Abhishek Goswami
to find all points which lies on the same quadrant for a specific node(say
1) , we have to check all nodes...rite??
we have to find difference b/w 2 node(frome origin ) is less or greater
than distance b/w 2 nodes...rite??
so if i am not getting it wrong it wil be O(n^2) anyhow.
On Thu, Dec 22,
adding one more check :- this one is updated
node *Reverse(node *root,node *pre)
{
flag=0;
for i=0 to n
if (root-children[i]!=NULL)
{
flag=1;
break;
}
end for
if( ! flag)
{
add
use k-d tree
On Thu, Dec 22, 2011 at 9:25 AM, atul anand atul.87fri...@gmail.com wrote:
to find all points which lies on the same quadrant for a specific node(say
1) , we have to check all nodes...rite??
we have to find difference b/w 2 node(frome origin ) is less or greater
than distance
i guess there is no need of stack , we can take a variable say top;
increment top when open bracket occur ( and decrement when close bracket
) occurs.
keep track of first close bracket mismatch i.e when top is zero and current
bracket is ).
if top!=0
report min(index,top);
On Tue, Dec
adding break to first loop...just to avoid unnecessary iterations.
if (root-children[i]!=NULL)
{
flag=1;
break;
}
end for
On Wed, Dec 21, 2011 at 10:59 PM, atul anand atul.87fri...@gmail.comwrote:
@shashank:
yeah here is the
20 matches
Mail list logo