[algogeeks] Re: DS Q

2011-11-17 Thread shady
you can't do binary search with linked lists.

On Nov 17, 1:14 pm, Vijay Khandar vijaykhand...@gmail.com wrote:
 Linked lists are not suitable data structures of which one of the
 following problems?
 a) Insertion sort
 b) Binary search
 c) Radix sort
 d) Polynomial manipulation

 Plz explain anyone in detail
 Vijay...

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] DS Q

2011-11-17 Thread Piyush
b) Binary search

Binary search has to be done in O(logn) but in a linked list individual
elements can't be
accessed in O(1) time. and hence its not suitable to have a linked list as
a data structure in
binary search.

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Re-entrant and thread safe

2011-11-17 Thread sumit mahamuni


On Oct 29, 10:44 pm, AMAN AGARWAL mnnit.a...@gmail.com wrote:
 Hi All,

 Please explain the difference between thread safe functions and re-entrant
 functions with example.

Thread safe function is the function if it ensures that it is the only
thread which modifies the shared data structure in thread safe manner
and which ensures the safe execution by multiple threads at the same
time.
And if we talk about the re-entrant code is a piece of code which can
be executed partially by a thread and can be re-executed by the same
thread or simultaneously executed by another thread and still
correctly complete the original execution.

I guess this would help you?



 Regards,
 Aman.

 --
 AMAN AGARWAL
 Success is not final, Failure is not fatal: It is the courage to continue
 that counts!

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: DS Q

2011-11-17 Thread sumit mahamuni
On Thu, Nov 17, 2011 at 4:05 PM, shady sinv...@gmail.com wrote:

 you can't do binary search with linked lists.

Yes you can do the binary search on the linked list.
But the only difference it makes from the array is that array elements can
be accessed in O(1) time and finding the mid in array is O(1) where it is
not possible with (1) on linked list. Yes you can find mid but that will be
expensive than array.



 On Nov 17, 1:14 pm, Vijay Khandar vijaykhand...@gmail.com wrote:
  Linked lists are not suitable data structures of which one of the
  following problems?
  a) Insertion sort
  b) Binary search
  c) Radix sort
  d) Polynomial manipulation
 
  Plz explain anyone in detail
  Vijay...

 --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Thanks and Regards,
Sumit Mahamuni.

-- Slow code that scales better can be faster than fast code that doesn't
scale!
-- Tough times never lasts, but tough people do.
-- I love deadlines. I like the whooshing sound they make as they fly by. -
D. Adams

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: DS Q

2011-11-17 Thread shady
roflmao, that's what i mean, else the whole purpose of binary search is
defeated, instead just linearly traverse the array and find the element

On Thu, Nov 17, 2011 at 4:17 PM, sumit mahamuni
sumit143smail...@gmail.comwrote:



 On Thu, Nov 17, 2011 at 4:05 PM, shady sinv...@gmail.com wrote:

 you can't do binary search with linked lists.

 Yes you can do the binary search on the linked list.
 But the only difference it makes from the array is that array elements can
 be accessed in O(1) time and finding the mid in array is O(1) where it is
 not possible with (1) on linked list. Yes you can find mid but that will be
 expensive than array.



 On Nov 17, 1:14 pm, Vijay Khandar vijaykhand...@gmail.com wrote:
  Linked lists are not suitable data structures of which one of the
  following problems?
  a) Insertion sort
  b) Binary search
  c) Radix sort
  d) Polynomial manipulation
 
  Plz explain anyone in detail
  Vijay...

 --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Thanks and Regards,
 Sumit Mahamuni.

 -- Slow code that scales better can be faster than fast code that doesn't
 scale!
 -- Tough times never lasts, but tough people do.
 -- I love deadlines. I like the whooshing sound they make as they fly by.
 - D. Adams

  --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] DS Q

2011-11-17 Thread Vijay Khandar
Thank u very much

On Thu, Nov 17, 2011 at 4:05 PM, Piyush piyushmadan2...@gmail.com wrote:

 b) Binary search

 Binary search has to be done in O(logn) but in a linked list individual
 elements can't be
 accessed in O(1) time. and hence its not suitable to have a linked list as
 a data structure in
 binary search.

  --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Programming Question

2011-11-17 Thread Vijay Khandar
In the following Pascal Program segment what is the value of X after
the execution of the program segment?

X:=10; Y:=20;
If XY,then if X0 then X:=abs(X) else X:=2*X;

Plz anyone explain

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: spoj problem

2011-11-17 Thread Anshul AGARWAL
finally got AC,(using bfs)
thanx DON for provide such nice test case

*Anshul Agarwal
Nit Allahabad
Computer Science**
*


On Wed, Nov 16, 2011 at 8:14 PM, SAMMM somnath.nit...@gmail.com wrote:

 U need to check for the case when (s==g) source and destination are
 same  , I got stuck here , after handling this case I got accepted :)

 --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: COA Question

2011-11-17 Thread Dave
d) Formal parameters, because they are in the definition of the macro.
If they were in an invocation of a macro, they would be actual
parameters, as in

ADD a,b

a and b are actual parameters, and the macro expands as

LOAD b
MUL a
STORE b

Where each instance of a formal parameter has been replaced by its
actual parameter.

Dave

On Nov 17, 5:32 am, Vijay Khandar vijaykhand...@gmail.com wrote:
 What are x and y in the following macro definition?

 macro  ADD x,y
            LOAD y
            MUL x
            STORE y
 end macro

 a) Variables
 b)Identifiers
 c)Actual Parameters
 d) Formal Parameters

 plz anyone explain.

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] array searching

2011-11-17 Thread SAMM
Yes we can do so in O(n) .

First find the XOR of all unique elements  using hash table or some other DS.
Secondly XOR  all the elements of the array .which will hav the xor of
elements other thn the element repeated twice.

Now XOR the above two value which will give the answer..

On 11/17/11, himanshu kansal himanshukansal...@gmail.com wrote:
 consider an array having n elements.out of which one number is
 repeated twiceother number are repeated odd number of times(for
 simplicity, assume other numbers are occurring just once)

 can you find the number that is repeated twice in O(n) time???

 PS: numbers are not from a particular range.

 --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Somnath Singh

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Programming Question

2011-11-17 Thread icy`
I dont know Pascal too well, but to me it looks like nested if
statements.

If xy   ,  all the rest of it happens

Since x is not greater than y, nothing happens.   So x and y should
remain the same (10,20)

On Nov 17, 6:09 am, Vijay Khandar vijaykhand...@gmail.com wrote:
 In the following Pascal Program segment what is the value of X after
 the execution of the program segment?

 X:=10; Y:=20;
 If XY,then if X0 then X:=abs(X) else X:=2*X;

 Plz anyone explain

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [JOB] Referral program @InMobi

2011-11-17 Thread shady
dont post here, send a mail to the raunak, we don't allow such threads, but
i thought it will benefit some of you, so allowed it.

On Thu, Nov 17, 2011 at 11:05 PM, Raunak Agrawal raunak.ra...@gmail.comwrote:

 Hi All,

 Please find the job description attached and let me know if anyone is
 interested in any openings. And also please mention the post you wanna
 apply for.


 Some brief note about InMobi:

 *This is a mobile ad networking company which bridges the gap between an
 advertiser and the publisher. It has got over 450+ employees across the
 globe and its second to google admob in mobile network advertising.

 We have got a funding of of $200 M which is one of the highest funding in
 any IT company. Moreover we have good food and great ppl to work with :)

 You can find more details on linkedIn, Facebook, www.inmobi.com, twitter
 etc etc.*


 Thanks,

 Raunak

 --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: array searching

2011-11-17 Thread Dave
@SAMM: It sounds like a circular argument. How do you XOR all of the
unique elements without first finding the repeated ones?

Dave

On Nov 17, 11:24 am, SAMM somnath.nit...@gmail.com wrote:
 Yes we can do so in O(n) .

 First find the XOR of all unique elements  using hash table or some other DS.
 Secondly XOR  all the elements of the array .which will hav the xor of
 elements other thn the element repeated twice.

 Now XOR the above two value which will give the answer..

 On 11/17/11, himanshu kansal himanshukansal...@gmail.com wrote:





  consider an array having n elements.out of which one number is
  repeated twiceother number are repeated odd number of times(for
  simplicity, assume other numbers are occurring just once)

  can you find the number that is repeated twice in O(n) time???

  PS: numbers are not from a particular range.

  --
  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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Somnath Singh

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Binary Trees and BSTs

2011-11-17 Thread bugaboo
Given 'n' nodes,
# of possible BTs = (2^n)-n
# of possible BSTs - Catalan number Cn = (2n!)/(n!*(n+1)!)

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/Ek3OPCpAAuUJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: Computer Organisation Q

2011-11-17 Thread ((** VICKY **))
False not necessarily.

On Nov 17, 4:03 pm, Vijay Khandar vijaykhand...@gmail.com wrote:
 Can anyone explain following sentence- True or False and explain

 All instructions affect the flags

 Vijay Khandar...

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: array searching

2011-11-17 Thread SAMM
On 11/18/11, SAMM somnath.nit...@gmail.com wrote:
 For example the array has ..
 1 4 2 6 7 4 8 3..
 xor the elements in the array will give (1^2^6^7^8^3).

 now xor the unique elements using hash table ,It gives (1^4^2^6^7^8^3).
 Now xor these two value which gives 4.

 On 11/18/11, Dave dave_and_da...@juno.com wrote:
 @SAMM: It sounds like a circular argument. How do you XOR all of the
 unique elements without first finding the repeated ones?

 Dave

 On Nov 17, 11:24 am, SAMM somnath.nit...@gmail.com wrote:
 Yes we can do so in O(n) .

 First find the XOR of all unique elements  using hash table or some
 other
 DS.
 Secondly XOR  all the elements of the array .which will hav the xor of
 elements other thn the element repeated twice.

 Now XOR the above two value which will give the answer..

 On 11/17/11, himanshu kansal himanshukansal...@gmail.com wrote:





  consider an array having n elements.out of which one number is
  repeated twiceother number are repeated odd number of times(for
  simplicity, assume other numbers are occurring just once)

  can you find the number that is repeated twice in O(n) time???

  PS: numbers are not from a particular range.

  --
  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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

 --
 Somnath Singh

 --
 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 more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Somnath Singh



-- 
Somnath Singh

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] deep vs shallow copy

2011-11-17 Thread rahul sharma
plz give me xample of these two .as per from book m not able to get
thesw clearly,...i have reda from wiki and got it but cant relate with
these...plz differ b/w these two with xample..thnx in advance


a shallow copy of an object copies all the member field values.this works
well if the fields are values,but may not be what we want for fields that
point to dynamically allocsted value.The pointer will be copied.But memory
it point will not be copied.


a deep cpy copies all fields,and makes copies of dynamically allocated
memory pointed to by the fields..

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Re: deep vs shallow copy

2011-11-17 Thread Gene
The most extreme shallow copy is just copying a pointer to a large
data structure like a graph or tree.  Deep copy is copying the entire
data structure and returning a new pointer.

Here is a more common example:

typedef struct list {
  struct list *next;
  void *data;
} LIST_NODE;

In practice you'd want to code these as loops instead of recursion.
But this gives the idea.

LIST_NODE *shallow_copy(LIST_NODE *lst)
{
  return lst ? new_list_node(shallow_copy(lst-next), data) : NULL;
}

LIST_NODE *deep_copy(LIST_NODE *lst)
{
  return lst ? new_list_node(deep_copy(lst-next), data_copy(data)) :
NULL;
}

Where data_copy is assumed to copy its argument into fresh memory and
return a poionter and new_list_node returns a freshly allocated node
with given fields.


On Nov 18, 6:33 am, rahul sharma rahul23111...@gmail.com wrote:
 plz give me xample of these two .as per from book m not able to get
 thesw clearly,...i have reda from wiki and got it but cant relate with
 these...plz differ b/w these two with xample..thnx in advance

 a shallow copy of an object copies all the member field values.this works
 well if the fields are values,but may not be what we want for fields that
 point to dynamically allocsted value.The pointer will be copied.But memory
 it point will not be copied.

 a deep cpy copies all fields,and makes copies of dynamically allocated
 memory pointed to by the fields..

-- 
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 more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.