the LL has to be a DLL as deletion would be a prob otherwise.
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Sat, Oct 1, 2011 at 9:42 AM, SAMM wrote:
> Linked List + Hash table will serve the purpose in O(1).
>
> On 9/30/11, Adi Srikanth wrote
index = 0 1 2 3 4 5 6
ar = 0 1 2 -4 -3 6 -3
sumar = 0 1 3 -1 -4 2 -1
first index where we get the number which has already appeared in sumar will
be the last index of sub array whose sum will be zero and (index of first
apperance of this number + 1) in sumar will be the start index.
- Take another sum array which contains sums of original array at each
index, here sum[0] = a[0]; sum[1] = a[0] + a[1]
;...sum[i]=a[0]+a[1]+...a[i];
- Traverse the sum array and search for duplicates.
ex: a[] = {1,2,-4,-3, 6 ,-3};
s[] = { 1,3,-1,-4,2,-1 };
In the sum array we have dupl
{You are given an unsorted array of integers. You have to find out the first
sub array whose elements when added sum up to zero.
eg:- int Array[] = {1,2,-4,-3, 6 ,-3.}Here sub array is -3,6,-3 bcos
adding all these sum to zero. A sub array can be of size 2 to whole length
of the array. You can
Find out the smallest segment in a document containing all the given words.
Desired Complexity is O nlogK ..n is the total no of words in the document
and k is the number of input words
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post
@adi..
he gave a hint that space used should not b of order of range of numbers but
should depend on how many numbers are inserted...
eg..if range is say 1000...bt u entered only 5 nos ->8,100,202,600,989.
u can use space of order 5..and not 1000
--
You received this message because you are subs
@somnath...can u pls elaborate...
he was looking for an elaborate ans...
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks
Linked List + Hash table will serve the purpose in O(1).
On 9/30/11, Adi Srikanth wrote:
> if space complexity is not a constraint..u can use any kind of hashing and
> its function.depends on the kind of data we store..if its numbers go for
> square or simple linear function
>
>
> Regards
if space complexity is not a constraint..u can use any kind of hashing and
its function.depends on the kind of data we store..if its numbers go for
square or simple linear function
Regards,
Adi Srikanth.
Mob No 9887233349
Personal Pages: adisrikanth.co.nr
On Fri, Sep 30, 2011 at 9:43 PM
Fibonacci Heaps
On Fri, Sep 30, 2011 at 9:14 PM, manish kapur wrote:
> u have to perform following tasks in O(1) time
> 1.)insertion
> 2.)deletion
> 3.)searching
> no range of input numbers is given
> wat data structure will you use?
> if u use hashing wat will be the key and value pairs?
>
> --
u have to perform following tasks in O(1) time
1.)insertion
2.)deletion
3.)searching
no range of input numbers is given
wat data structure will you use?
if u use hashing wat will be the key and value pairs?
--
You received this message because you are subscribed to the Google Groups
"Algorithm G
reversing the linked list
static void reverse(struct node** head_ref)
{
struct node* p=NULL;
struct node* curr=*head_ref;
struct node* q;
while(curr!=NULL)
{
q=curr->next;
curr->next=p;
p=curr;
curr=q;
}
*head_ref=p;
}
--
You received this message because you are subscribed to the Google Groups
call function recursively when it is the last node, return the function
calls and print it
On Wed, Sep 28, 2011 at 8:20 AM, rahul sharma wrote:
> make sure that u ryt the syntax correct
>
>
> On Wed, Sep 28, 2011 at 8:18 AM, rahul sharma wrote:
>
>> reverse(head)
>> {
>> if(head==NUll)
>> {
>> pr
@rahul
if(head == null) return;
u cant print head->info when head is null
On Wed, Sep 28, 2011 at 8:20 AM, rahul sharma wrote:
> make sure that u ryt the syntax correct
>
>
> On Wed, Sep 28, 2011 at 8:18 AM, rahul sharma wrote:
>
>> reverse(head)
>> {
>> if(head==NUll)
>> {
>> printf("head->info
make sure that u ryt the syntax correct
On Wed, Sep 28, 2011 at 8:18 AM, rahul sharma wrote:
> reverse(head)
> {
> if(head==NUll)
> {
> printf("head->info");
> return;
> }
> reverse(head->link)
> printf("head->info);
> }
>
> On Wed, Sep 28, 2011 at 4:39 AM, anand karthik > wrote:
>
>> Reverse it
reverse(head)
{
if(head==NUll)
{
printf("head->info");
return;
}
reverse(head->link)
printf("head->info);
}
On Wed, Sep 28, 2011 at 4:39 AM, anand karthik
wrote:
> Reverse it , print it and reverse it again. :-)
>
> On Wed, Sep 28, 2011 at 3:28 AM, Ankur Garg wrote:
> > Print Reverse of linked l
Reverse it , print it and reverse it again. :-)
On Wed, Sep 28, 2011 at 3:28 AM, Ankur Garg wrote:
> Print Reverse of linked list (dont reverse it) with only constant space.
>
> Recursion uses stack spaceO(n) ..so post some other solution ..
>
>
> --
> You received this message because you are su
Print Reverse of linked list (dont reverse it) with only constant space.
Recursion uses stack spaceO(n) ..so post some other solution ..
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegr
given an array of size N containing only 0s and 1s return the length of the
maximum sub array containing equal number of 0s and 1s
Give a O(n) solution
It has been asked before in this forum but no one has given a proper
solution so m asking again
May be we need DP here..But what will be the rec
You are given n no. of lines in form of Ax + By = C, basically you are given
A[i], b[i] and C[i] for line "i".
Lines are given in a way such that 0 <= x[i] <= 1 and y[i] < y[i+1] for same
X.
Also, one point (x,y) is given too. Find out the two closest lines to the
point such that the point is betwe
Pop each element and en-queue it twice and de-queue it once. When stack is
empty the front of the queue will be middle element.
On Mon, Aug 22, 2011 at 4:01 PM, Ankur Garg wrote:
> Find the middle of the stack..(Time complexity should be minimum)
>
>
> Stack is not implemented as Linked List ...
Find the middle of the stack..(Time complexity should be minimum)
Stack is not implemented as Linked List ...u have normal stack with push,pop
and top
How to do this ??
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group,
1.Given an array of size n. It contains numbers in the range 1 to n.
Each number is present at least once except for 2 numbers. Find the
missing numbers.
2.Given an array of size n. It contains numbers in the range 1 to n.
Find the numbers which aren’t present.
--
You received this message beca
23 matches
Mail list logo