[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

[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 dave_and_da...@juno.com 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

[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-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 naveenshuklasweetdrea...@gmail.com wrote: Given a linked list of infinite length. Write a function to return a random node. Constraints: 1 You can traverse a singly linked

[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:01

[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

[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

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 dipitgro...@gmail.com wrote: See you are actually passing the address of 'rest' each time, so the changes made to *head_ref are actually reflected in

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 rahul23111...@gmail.comwrote: @ 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 dipitgro...@gmail.com wrote: See you are

[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

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 shashank7andr...@gmail.com wrote: now try

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 mittal.nishan...@gmail.com wrote: @sunny plz tell me the solution without using extra list...i've

[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 sunny816.i...@gmail.com 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

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

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 rajn...@gmail.com 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

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 wangyanadam1...@gmail.comwrote: 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

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 rajn...@gmail.com

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

[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 rajn...@gmail.com wrote: What will be the representation. How

[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 kvija...@gmail.com wrote: 1. typedef is used to rename the data type.

[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

[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

[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)

[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 bharath1...@gmail.com wrote: Q: Check whether given singly linked list is palindrome or not in single pass. Instead of making two

[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

[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 bharath1...@gmail.com 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

[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] 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 a.cyber...@gmail.comwrote: On Wed, Aug 12, 2009 at 10:38, varun bhatia varunbhatia@gmail.comwrote: 1. Given a single link list with one info

[algogeeks] Re: linked list questions

2009-08-12 Thread Aravind Narayanan
On Wed, Aug 12, 2009 at 10:38, varun bhatia varunbhatia@gmail.comwrote: 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

[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: No, I think O(n)

[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 11, 2008 at 10:03

[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

[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 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

[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

[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 best method one can

[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, 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. LOL ...

[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 for you. But