Here u r using extra space to store count values..
CHERUVU JAANU REDDY
M.Tech in CSIS
On Tue, May 18, 2010 at 7:01 PM, Jagadish M wrote:
>
> On May 18, 8:29 am, Terence wrote:
> > How do you maintain the heap? Could you explain in detail for the
> >
On May 18, 8:29 am, Terence wrote:
> How do you maintain the heap? Could you explain in detail for the
> following example:
> 1 2 3 3 2 1 1 1 2 3 (n=10, k=3)
Basically, in each node we maintain the key and its count.
Initially, heap has the first element.
1:1
Search for 2 and insert( since its
Heap maintains the word and frequency count
On 5/18/10, Terence wrote:
> How do you maintain the heap? Could you explain in detail for the
> following example:
> 1 2 3 3 2 1 1 1 2 3 (n=10, k=3)
>
> On 2010-5-17 22:38, Jagadish M wrote:
>> The best algorithm I can think of is to maintain a heap of
1)do inorder and reverse inorder traversal
2)They will meet at one point or they will cross each other
3)That point is the median
4)Code for the same.
while(true)
{
//inorder traversal
while(count1<=count2 && flag1)
{
if(root)
{
push(root);
root=root->lptr;
}
else
{
calculate 3digits before decimal for pow(3+sqrt(5),n)
where n value can be upto 20
Please provide suggestions on this.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
How do you maintain the heap? Could you explain in detail for the
following example:
1 2 3 3 2 1 1 1 2 3 (n=10, k=3)
On 2010-5-17 22:38, Jagadish M wrote:
The best algorithm I can think of is to maintain a heap of k elements.
Takes O(n log k) time.
Is anything told about the values of the keys?
@W Karas
Can you please give an example and explain your approach.
Anurag Sharma
On Tue, May 18, 2010 at 12:17 AM, W Karas wrote:
> One (space-intensive) idea:
>
> Re-represent each string as a set of pairs (character, position of
> character). Then sort each set of pairs by character. Then f
1)do inorder and reverse inorder traversal
2)They will meet at one point or they will cross each other
3)That point is the median
4)Code for the same.
while(true)
{
//inorder traversal
while(count1<=count2 && flag1)
{
if(root)
{
push(root);
root=root->lptr;
}
else
{