[algogeeks] Re: Linked List question

2013-01-04 Thread Don
I did. I'm just having fun with the sloppy problem statement. If you don't ask for what you want you might get what you ask for rather than what you had in mind. The solver might decide that the OP really meant something different, and solve some other problem, which may or may not be what was inte

[algogeeks] Re: Linked List question

2013-01-03 Thread Dave
@Don: You did, of course, see the OP's revision in https://groups.google.com/d/msg/algogeeks/Be3WBebCDCk/_Mb0HUQ93WoJ, did you not? Dave On Thursday, January 3, 2013 3:08:40 PM UTC-6, Don wrote: > The spec says that the list is infinite, so I don't think that is > possible in finite time. >

[algogeeks] Re: Linked List question

2013-01-03 Thread Don
The spec says that the list is infinite, so I don't think that is possible in finite time. Don On Jan 2, 7:53 pm, Dave wrote: > @Don: HaHa. That's cute, but don't you really think the problem is to > return any node in the list with equal probability? > > Dave > > > > > > > > On Wednesday, Januar

[algogeeks] Re: Linked List question

2013-01-02 Thread Dave
@Don: HaHa. That's cute, but don't you really think the problem is to return any node in the list with equal probability? Dave On Wednesday, January 2, 2013 4:48:15 PM UTC-6, Don wrote: > Why not just return the first node? That is as random as any other > node. > Don > > On Dec 27 2012, 5:

[algogeeks] Re: Linked List question

2013-01-02 Thread Don
Why not just return the first node? That is as random as any other node. Don On Dec 27 2012, 5:01 am, naveen shukla wrote: > Given a linked list of infinite length. Write a function to return a random > node. > > Constraints: > > 1 You can traverse a singly linked list only once. > 2 You can not

[algogeeks] Re: Linked list using void pointer

2012-05-31 Thread Gene
You didn't say C or C++. It makes a difference. A void pointer is just a pointer that can point to any kind of data. You convert it to a specific type by using casts. So just implement an exogenous list the same way you would if data had some type Foo. The replace all the Foo pointers with vo

Re: [algogeeks] Re: linked list reverse

2011-10-02 Thread rahul sharma
got it...thnx a lot buddy,,, On Mon, Oct 3, 2011 at 7:20 AM, rahul sharma wrote: > @ Digo ..i got almost wat u said...can u give me a example with 3-4 > nodes...it will help me a lot..thnx.. > > > On Mon, Oct 3, 2011 at 1:43 AM, Digo wrote: > >> See you are actually passing the address of 'rest'

Re: [algogeeks] Re: linked list reverse

2011-10-02 Thread rahul sharma
@ Digo ..i got almost wat u said...can u give me a example with 3-4 nodes...it will help me a lot..thnx.. On Mon, Oct 3, 2011 at 1:43 AM, Digo wrote: > See you are actually passing the address of 'rest' each time, so the > changes made to *head_ref are actually reflected in the value at the > ad

[algogeeks] Re: linked list reverse

2011-10-02 Thread Digo
See you are actually passing the address of 'rest' each time, so the changes made to *head_ref are actually reflected in the value at the address of 'rest' each time the recursive call returns, so the value of 'rest' is carried backwards to the front once we start popping from the tail of the list.

Re: [algogeeks] Re: linked list doubt

2011-07-12 Thread Aniket Dutta
@anika: according to satistics we need both n/2 and n/2+1 to find the median from an even set ((n/2)+(n/2+1))/2. but here you cannot do this. so i guess n/2+1 or n/2 both are correct because both contribute equally to calculate median. On 7/12/11, bittu wrote: > now try how u will remove the loop

[algogeeks] Re: linked list doubt

2011-07-12 Thread bittu
now try how u will remove the loop from linked list Shashank CSE BIT Mesra -- 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 algog

[algogeeks] Re: linked list

2011-06-29 Thread Nishant
@sunny oh... i cudnt understand.can u plz explain by an example On Jun 29, 7:58 pm, sunny agrawal wrote: > I am not using extra space as i am not allocating new memory for storing > Nodes > i m using just 2 pointers on the same list, i think that will be allowed > > > > On Wed, Jun 29, 2011 a

Re: [algogeeks] Re: linked list

2011-06-29 Thread sunny agrawal
I am not using extra space as i am not allocating new memory for storing Nodes i m using just 2 pointers on the same list, i think that will be allowed On Wed, Jun 29, 2011 at 8:18 PM, Nishant wrote: > @sunny plz tell me the solution without using extra list...i've solved > it using extra list..

[algogeeks] Re: linked list

2011-06-29 Thread Nishant
@sunny plz tell me the solution without using extra list...i've solved it using extra list... On Jun 29, 7:38 pm, sunny agrawal wrote: > maintain two pointers one at the tail of even number list one at tail of odd > Number list > traverse the list and add the number at required list > > On Wed, J

Re: [algogeeks] Re: linked list

2011-03-17 Thread sanjay ahuja
method 1 struct node { void* data; unsigned int size; struct node* next; }; struct node* allocateNode(void* data,unsigned int n) { struct node* temp = (struct node*) malloc(sizeof(struct node)); temp->size = n; temp->next = NULL; temp->data = malloc(n); for(int i=

Re: [algogeeks] Re: linked list

2011-03-16 Thread hary rathor
@DON: pls can U explain with examle ? -- 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+unsubscr...@googlegroups.com. For

[algogeeks] Re: linked list

2011-03-16 Thread Don
Another alternative to a void pointer is a union. Typically you would also want an enumerated type to indicate the actual type stored in the union. On Mar 16, 9:57 am, himanshu kansal wrote: > can nodes of linked list in c/c++ contain different types of > datameans suppose 1st node of the lis

Re: [algogeeks] Re: linked list as tree

2010-08-25 Thread Raj N
@TurksHead: No its linked list to tree On Wed, Aug 25, 2010 at 6:59 AM, TurksHead Education < turksheadeducat...@gmail.com> wrote: > I hope you are not talking about converting a tree into a linked list > http://www.rawkam.com/?p=1139 > > > > On Tue, Aug 24, 2010 at 7:20 AM, Raj N wrote: > >> I

Re: [algogeeks] Re: linked list as tree

2010-08-25 Thread Raj N
@Yan Wang: Thanks a lot !! On Wed, Aug 25, 2010 at 12:19 AM, Yan Wang wrote: > I know what you mean now. > It's not very hard to implement your idea. > > First, construct a usual binary sorting tree based on the original > linked list. Notice that I also use the inner nodes to store the > element

Re: [algogeeks] Re: linked list as tree

2010-08-25 Thread TurksHead Education
I hope you are not talking about converting a tree into a linked list http://www.rawkam.com/?p=1139 On Tue, Aug 24, 2010 at 7:20 AM, Raj N wrote: > I came across this example that the leaves of the tree can be the nodes of > a linked list and the inner nodes of the tree can be the number of l

Re: [algogeeks] Re: linked list as tree

2010-08-24 Thread Yan Wang
I know what you mean now. It's not very hard to implement your idea. First, construct a usual binary sorting tree based on the original linked list. Notice that I also use the inner nodes to store the elements in the linked list rather than only using the leaf nodes. And the quantity feature you m

Re: [algogeeks] Re: linked list as tree

2010-08-24 Thread Raj N
I came across this example that the leaves of the tree can be the nodes of a linked list and the inner nodes of the tree can be the number of left subtrees. This kinda data structure can be used to find the kth element of a linked list very easily. I was not able to implement such an idea.. Can an

[algogeeks] Re: linked list as tree

2010-08-23 Thread Adam
What do you exactly mean? You want to represent a linear structure by using a tree structure? You can imagine a linked list as a tree with all its root and inner nodes only having one descendent/child node. On Aug 23, 10:50 am, Raj N wrote: > What will be the representation. How do you define lef

[algogeeks] Re: Linked List

2010-08-19 Thread vikas kumar
you are right in the way in cpp code it is not required but in C , you can not write like node * start. it only recognise new type when typedef is applied. second one is already explained by vijay On Aug 18, 6:16 pm, Vijay wrote: > 1. typedef is used to rename the data type. Here struct node is a

[algogeeks] Re: Linked List

2010-08-18 Thread Vijay
1. typedef is used to rename the data type. Here struct node is actual data type of linked list node and is renamed to NODE using typedef .Instead of using struct node each time we declares a new node variable we can use simply NODE. 2.**start is required if you pass actual parameter as address,

[algogeeks] Re: linked list questions

2009-10-13 Thread Raghavendra Sharma
For the first question *Q: Check whether given singly linked list is palindrome or not in single pass. Instead of making two passes, can we do it in single pass on a list? One method i can think of is, hashing character to its postion and check for the sum.* I can think of a recursive solution.

[algogeeks] Re: linked list questions

2009-09-08 Thread ankur aggarwal
@bharath apply your logic at "abbaabba" show me your steps On Tue, Sep 8, 2009 at 8:04 PM, Bharath wrote: > > Q: Check whether given singly linked list is palindrome or not in > single pass. > > Instead of making two passes, can we do it in single pass on a list? > > One method i can think of

[algogeeks] Re: linked list questions

2009-09-08 Thread ankur aggarwal
@bharath how will u recognize which "a" to compare to which "a" or apply on "malayalam" --~--~-~--~~~---~--~~ 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

[algogeeks] Re: linked list questions

2009-09-08 Thread manish bhatia
Are we able to store the incoming characters? On Tue, Sep 8, 2009 at 11:51 AM, Bharath wrote: >Slightly modifying first question. > >Check whether a string is palindrome in single pass. > >Meaning an online algorithm is required, i.e. it must be able to read >one character at a time from a stre

[algogeeks] Re: linked list questions

2009-09-08 Thread Bharath Kumar
yeah a[i] == a[n-i] will work if you know the length of the list in advance. What if we dont know the length in advance. One has to to make two passes on a list ,first to find the length or midpoint and another pass for comparison. Can we do it in a single pass? On Tue, Sep 8, 2009 at 9:01 PM,

[algogeeks] Re: linked list questions

2009-09-08 Thread ankur aggarwal
@barath u r using extra space.. wat is new about this sol change to array.. then do as simple using a[i]==a[n-i] ??? On Tue, Sep 8, 2009 at 8:04 PM, Bharath wrote: > > Q: Check whether given singly linked list is palindrome or not in > single pass. > > Instead of making two passes, can we do it

[algogeeks] Re: linked list questions

2009-09-08 Thread ankur aggarwal
1st ques struct Node { datatype DATA struct Node * next; struct Node * random; }; struct Node * cloneList(Node * original) { struct Node *p,*q,*r; for(p = original; p != null; p = p->next->next) { q = p->next; p->next = getNewNode(); p->next->next = q; } for(p = origin

[algogeeks] Re: linked list questions

2009-09-08 Thread Bharath
Q: Check whether given singly linked list is palindrome or not in single pass. Instead of making two passes, can we do it in single pass on a list? One method i can think of is, hashing character to its postion and check for the sum. abccba 123456 a: 1+6=7 b: 2+5=7 c: 3+4=7 On Sep 8, 5:33 pm,

[algogeeks] Re: linked list questions

2009-09-08 Thread ankur aggarwal
for 1st use hare and tortoise algo to find the mid point of the linklist ... and reverse the other end like a->b-->c->d->v->u a->b-->c<-d<-v<-u pointer 1 will point to a and other pointer will point to u then it is done .. u can check.. 2nd for(p = original; p != null; p = p->next->next) p

[algogeeks] Re: linked list questions

2009-09-08 Thread ankur aggarwal
@bharat your statement is not clear.. On Tue, Sep 8, 2009 at 11:51 AM, Bharath wrote: > > Slightly modifying first question. > > Check whether a string is palindrome in single pass. > > Meaning an online algorithm is required, i.e. it must be able to read > one character at a time from a stream

[algogeeks] Re: linked list questions

2009-09-08 Thread Bharath
Slightly modifying first question. Check whether a string is palindrome in single pass. Meaning an online algorithm is required, i.e. it must be able to read one character at a time from a stream and tells whether string read so far is palindrome or not. --~--~-~--~~~---

[algogeeks] Re: linked list questions

2009-08-13 Thread varun bhatia
well the 2nd ques is not clear. can u explain it in simpler manner On Wed, Aug 12, 2009 at 4:37 PM, Aravind Narayanan wrote: > > On Wed, Aug 12, 2009 at 10:38, varun bhatia wrote: > >> 1. Given a single link list with one info part containing single character >> and a

[algogeeks] Re: linked list questions

2009-08-12 Thread Aravind Narayanan
On Wed, Aug 12, 2009 at 10:38, varun bhatia wrote: > 1. Given a single link list with one info part containing single character > and a link. Check whether the link list is a palindrome or not. > The algo should run in Linear time only. You can't use any array or string > to store the string of li

[algogeeks] Re: linked list

2008-06-23 Thread Geoffrey Summerhayes
On Jun 22, 3:01 pm, Tejas Kokje <[EMAIL PROTECTED]> wrote: > On Jun 11, 12:25 am, "zee 99" <[EMAIL PROTECTED]> wrote: > > > is this the best one even if the list is sorted ( or any other constraint > > like this is applied ) ?? > > > On 6/11/08, Mohammad Moghimi <[EMAIL PROTECTED]> wrote: > > >

[algogeeks] Re: linked list

2008-06-23 Thread Geoffrey Summerhayes
On Jun 22, 7:45 pm, "Nat Padmanabhan" <[EMAIL PROTECTED]> wrote: > This is not funny! True, it's actually quite depressing. > Skiplist is essentially an optimized version of Doug's idea that ends up > using a logrithmically scaling vector of pointers. Secondly, linked lists in > real scenarios m

[algogeeks] Re: linked list

2008-06-22 Thread Nat Padmanabhan
This is not funny! Skiplist is essentially an optimized version of Doug's idea that ends up using a logrithmically scaling vector of pointers. Secondly, linked lists in real scenarios make sense only when there is some satellite data associated with the keys. So maintaining just pointers gives you

[algogeeks] Re: linked list

2008-06-22 Thread Tejas Kokje
On Jun 11, 12:25 am, "zee 99" <[EMAIL PROTECTED]> wrote: > is this the best one even if the list is sorted ( or any other constraint > like this is applied ) ?? > > On 6/11/08, Mohammad Moghimi <[EMAIL PROTECTED]> wrote: > > > > > No, I think O(n) is the best method one can use > > On Wed, Jun 1

[algogeeks] Re: linked list

2008-06-13 Thread zee
a skip list is more efficient i think .. but it take O(n) extra space .. can we do better On 6/12/08, Sumedh Sakdeo <[EMAIL PROTECTED]> wrote: > > Well it is possible with a constraint that ur linked list is > maintained sorted. Google more on Skiplist. > It is a randomized probabilistic

[algogeeks] Re: linked list

2008-06-12 Thread Sumedh Sakdeo
Well it is possible with a constraint that ur linked list is maintained sorted. Google more on Skiplist. It is a randomized probabilistic algorithm. Regards, Sumedh On 6/11/08, Douglas Diniz <[EMAIL PROTECTED]> wrote: > Well, if you have a classic linked list, O(n) is the best for you. But you >

[algogeeks] Re: linked list

2008-06-11 Thread Akhil Ravidas
If you have a vector, then why would you use linked list in the first place?? :) On Wed, Jun 11, 2008 at 10:03 PM, Geoffrey Summerhayes <[EMAIL PROTECTED]> wrote: > > > > On Jun 11, 12:09 pm, "Douglas Diniz" <[EMAIL PROTECTED]> wrote: >> Well, if you have a classic linked list, O(n) is the best f

[algogeeks] Re: linked list

2008-06-11 Thread Geoffrey Summerhayes
On Jun 11, 12:09 pm, "Douglas Diniz" <[EMAIL PROTECTED]> wrote: > Well, if you have a classic linked list, O(n) is the best for you. But you > can do better if you have a sorted linked list. In every node keep a vector > of pointers for all other nodes. Then you can simulate a binary search. >

[algogeeks] Re: linked list

2008-06-11 Thread Douglas Diniz
Well, if you have a classic linked list, O(n) is the best for you. But you can do better if you have a sorted linked list. In every node keep a vector of pointers for all other nodes. Then you can simulate a binary search. On Wed, Jun 11, 2008 at 12:11 PM, Geoffrey Summerhayes <[EMAIL PROTECTED]>

[algogeeks] Re: linked list

2008-06-11 Thread Geoffrey Summerhayes
On Jun 11, 3:25 am, "zee 99" <[EMAIL PROTECTED]> wrote: > On 6/11/08, Mohammad Moghimi <[EMAIL PROTECTED]> wrote: >> On Wed, Jun 11, 2008 at 10:03 AM, zee99. 99 <[EMAIL PROTECTED]> wrote: >>> >>> is there any algo that can search a linked list in less than O(n) time >> >> No, I think O(n) is the

[algogeeks] Re: linked list

2008-06-11 Thread Akhil Ravidas
You cannot randomly access elements in the list.. So i guess the list being sorted isn't going to make a difference. On Wed, Jun 11, 2008 at 12:55 PM, zee 99 <[EMAIL PROTECTED]> wrote: > is this the best one even if the list is sorted ( or any other constraint > like this is applied ) ?? > > On 6

[algogeeks] Re: linked list

2008-06-11 Thread zee 99
is this the best one even if the list is sorted ( or any other constraint like this is applied ) ?? On 6/11/08, Mohammad Moghimi <[EMAIL PROTECTED]> wrote: > > No, I think O(n) is the best method one can use > > > -- Mohammad Moghimi > double m[] = { 9580842103863.650391, 133470973390.236450, 270}

[algogeeks] Re: linked list

2008-06-10 Thread Mohammad Moghimi
No, I think O(n) is the best method one can use -- Mohammad Moghimi double m[] = { 9580842103863.650391, 133470973390.236450, 270}; int main(){m[2]--?m[0]*=4,m[1]*=5,main():printf(m);} On Wed, Jun 11, 2008 at 10:03 AM, zee99. 99 <[EMAIL PROTECTED]> wrote: > > is there any algo that can search a