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
@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.
>
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
@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:
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
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
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'
@ 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
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.
@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
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
@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
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..
@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
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=
@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
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
@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
@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
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
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
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
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
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
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,
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.
@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
@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
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
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,
@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
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
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,
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
@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
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.
--~--~-~--~~~---
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
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
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:
>
> >
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
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
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
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
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
>
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
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.
>
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]>
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
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
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}
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
51 matches
Mail list logo