Re: [algogeeks] Find the path in two nodes of a binary search tree

2012-01-02 Thread Abhishek Gupta
we might implement it using recursive calls where once found..the node is
printed and true is returned and if leaf is reached...false is
returnedall the function calls getting true will again print and return
true...and false will just return false without printing...this way we can
print only nodes which are in path from root to target node...i can assume
it to be a simple binary seach tree...




On Mon, Jan 2, 2012 at 10:12 PM, top coder topcode...@gmail.com wrote:

 Suppose you have a tree. A binary tree (for something like
 simplicity :p). You are traversing it (using infix, postfix or prefix)
 to search for a node. You find your required node. You just realized
 that you need to know the path from this node back to the root node
 (and/or vice versa). Given the following description of the structure
 of the tree node that you “cant” change:

 struct node{Data data; node *right,*left;};

 what will you strategy be to tackle this problem.

 To make it more intresting (or maybe just the application of the above
 problem) suppose you find the node A and a node B in consecutive
 searches. Now what will your strategy be to show a path from A to B.
 (not neccesarily from the root of the whole tree, but possibly).

 --
 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  Regards
Abhishek Gupta
BITS, Pilani

-- 
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] without using '-'

2011-09-26 Thread Abhishek Gupta
thats basically taking twos' compliment and converting it to negative one
and then adding it..its the same principle...which is used for dividing two
numbers without using '/' and '-'...right kunal??

On Mon, Sep 26, 2011 at 10:38 PM, Ashima . ashima.b...@gmail.com wrote:

 grt.we never generally use ~ operator. got to knw abt it.
 Ashima
 M.Sc.(Tech)Information Systems
  4th year
 BITS Pilani
 Rajasthan




 On Mon, Sep 26, 2011 at 10:07 AM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote:

 Tricky question with more tricky answers. thank you all.


 On Mon, Sep 26, 2011 at 9:55 PM, Kunal Yadav kunalyada...@gmail.comwrote:

 difference = x+ ~y +1

 On Mon, Sep 26, 2011 at 7:33 PM, ~*~VICKY~*~ venkat.jun...@gmail.comwrote:

 Find the difference of two numbers without using '-' operator !

 plz share ur solutions!

 --
 Cheers,

   Vicky

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




 --
 Regards
 Kunal Yadav
 (http://sourcebit.in)


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




 --
 Cheers,

   Vicky

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




-- 
Thanks  Regards
Abhishek Gupta

-- 
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] ftell problem

2011-09-20 Thread Abhishek Gupta
Guys

what is the difference between ftell(fp)1 and ftell(fp) 0??


...
Abhishek Gupta

-- 
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] URGENT suggestion REGARDING placement...............

2011-09-17 Thread Abhishek Gupta
If you go for delloitte, its pretty tough to switch back to pure coding
companies like yahoo etc. One friends of mine is facing same problems after
working 3 years in delloitte. So be clear and very careful about chosing
your career. Or try going for Goldman Sachs.

On Sat, Sep 17, 2011 at 2:43 PM, vivek goel vivek.thapar2...@gmail.comwrote:

 HELLO  FRIENDS,,,
 PLEASE give me advice THAT   agar  *computer branch(B.E.  or MCA) ka koi
 student hai and agar uski deloite consultancy mein hone ke chances 
 ho*,
 as ye *dream company* hai...to aur *kisi campus
 placement mein  baithna us student ko allowed nhi  hogaafter  getting
 selected in Deloitte...*
 *to use  kya karna *chahiye..agge  aani wali *companies  ki
 taraf dhyan dena chahiye  ya deloitte mein hi  clear karne ki try
 kare...*
 *as abhi aur bhi ** **software companies aani baaki hai college mein.
 . and  wo  bhiachii hai...
 *
 and

 agar wo *deloitte mein* chala bhi jata hai
 to kyaa   baad mein kabhi  later...
 *microsoft,  yahoo, google ya  koi software companies mein ja* payega,
 jo ki *pure coding companies* hai( *agar wo
 baad mein switch krna chahe*).
 as deloitte mein shyd coding ka kaam  kam hoga shyd.

 plss  help.

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




-- 
---
Regards,
Abhishek Gupta
MCA
NIT Calicut
Kerela

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

2011-08-25 Thread Abhishek Gupta
using the preserving the property of X-OR.

On Fri, Aug 26, 2011 at 9:35 AM, siddharam suresh
siddharam@gmail.comwrote:

 gives an error as b is undeclared.
 BTW this prog swaps 2 number.

 Thank you,
 Siddharam



 On Fri, Aug 26, 2011 at 9:28 AM, SuDhir mIsHra 
 sudhir08.mis...@gmail.comwrote:

 main()

 {

 int a=10,20;

 a^=b^=a^=b;

 printf(%d\n %d\n,a,b);

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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: Adobe Interview Puzzles Urgent !!

2011-08-19 Thread Abhishek Gupta
(root2-1)R/root2+1??

On Fri, Aug 19, 2011 at 8:03 PM, Greeshma greeshma.0...@gmail.com wrote:

 is it (root 2 - 1) * R ?

 --
 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/-/zwlqxDgQXFgJ.

 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: Any body have idea about samsung india recruitment...

2011-08-18 Thread Abhishek gupta
search the group

-- 
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/-/-uBb8iSPXTQJ.
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] Algorithms for Interviews _scan ocr_.pdf

2011-08-13 Thread Abhishek gupta
@aditi: like..

-- 
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/-/QT0UrDjFSoEJ.
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]

2011-08-12 Thread Abhishek gupta
earlier it has been posted in the group that check the size of pointer 
variable,
if it is 2b then 16 bit
4b then 32 bit
8b then 64 bit

-- 
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/-/EoFyFYjhHT0J.
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: Problems on Linked List

2011-08-12 Thread Abhishek gupta
Q2). i think for second question it will be enough to just swap the data of 
current node to next node,
and delete the next node.
it will be like,
//for swap
int temp=current-data;
current-data=current-next-data;
current-next-data=temp;

//for delete
struct node *temp;
temp=current-next;
current-next=current-next-next;
free(temp);

i think it will be enough even in case of last node.
correct me if i am wrong.

-- 
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/-/N1elA8-W-iUJ.
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] an array question

2011-08-12 Thread Abhishek Gupta
see the second example...if a single digit is there...tht will be at the
very end of the array...and if it is 9 it must come at first place...there
it goes wrong...

On Fri, Aug 12, 2011 at 6:23 PM, Prem Krishna Chettri hprem...@gmail.comwrote:

 Amazing ,

   Kindly Follow me up :-


 1 Given Array of Random Value ...  say int a[]= {20,365,299,50,67,21};
 Apply Any Sorting Algo on it... which Results into somewhat
 like  a={365,299,67,50,21,20,.. blah..}...

 2 Well No U hv to put those values to a string variable.

Please lemme knw if I need more clarification.. This is simple where is
 the messy part??




 On Fri, Aug 12, 2011 at 6:16 PM, Nitin Nizhawan 
 nitin.nizha...@gmail.comwrote:

 radix sort the digits wrong way (left most digit first), and then
 concatenate


 On Fri, Aug 12, 2011 at 6:12 PM, Yasir yasir@gmail.com wrote:

 Kindly  check it with both the examples. It won't work.

 --
 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/-/VlT1DNH-vPkJ.

 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.


  --
 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  Regards
Abhishek Gupta
BITS, Pilani

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

2011-08-11 Thread Abhishek Gupta
 email to
   algogeeks+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
   --
   **Regards
   SAGAR PAREEK
   COMPUTER SCIENCE AND ENGINEERING
   NIT ALLAHABAD
 
--
   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.
 
   --
   With regards
 
   Puneet Chawla
   Computer Engineering Student
   NIT Kurukshetra
 
--
   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.
 
   --
   Aditi Garg
   Undergraduate Student
   Electronics  Communication Divison
   NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
   Sector 3, Dwarka
   New Delhi
 
--
   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.
 
   --
   **Regards
   SAGAR PAREEK
   COMPUTER SCIENCE AND ENGINEERING
   NIT ALLAHABAD
 
--
   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.
 
   --
   With regards
 
   Puneet Chawla
   Computer Engineering Student
   NIT Kurukshetra
 
--
   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.
 
   --
   **Regards
   SAGAR PAREEK
   COMPUTER SCIENCE AND ENGINEERING
   NIT ALLAHABAD
 
--
   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.
 
  --
  Aditi Garg
  Undergraduate Student
  Electronics  Communication Divison
  NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
  Sector 3, Dwarka
  New Delhi

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




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


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




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT ALLAHABAD

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group

Re: [algogeeks] Preprocessor Help !!

2011-08-10 Thread Abhishek Gupta
Answer 2) To prevent use of NULL with any other variable instead of 0(zero), 
it is set at void pointer.
 for ex, you cannot use in C like this, a=b+NULL;
but, i think, in C++ you can do.

-- 
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/-/JEkkEmJOYkkJ.
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: Normalised !!

2011-08-09 Thread Abhishek Gupta
binary values are stored in reverse order of byte by byte.
in your case, bytes will be stored as,
  10101100 0100


-- 
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/-/JT9--4s8NYEJ.
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] Link list problem..

2011-08-08 Thread Abhishek Gupta
In a linkedlist we have lost the head pointer and currently we are in the 
middle(anywhere) of list. 
Is it possible to delete the previous node of the current pointer.

-- 
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/-/0uphUoG8ZLgJ.
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] Link list problem..

2011-08-08 Thread Abhishek Gupta
okay..

-- 
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/-/6Diby2oBmy4J.
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] Link list problem..

2011-08-08 Thread Abhishek Gupta
actually someone has asked me. he is saying that it is possible and the 
funny thing is that he also doesn't know the solution..

-- 
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/-/njvB_e0FIN0J.
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: Link list problem..

2011-08-08 Thread Abhishek Gupta
Errata:
sorry guys..
there is a change in the problem.. actually we have to INSERT a NEW NODE 
before the current pointer.
Now tell is it possible..
or again it is a stupid question..

-- 
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/-/JTEcmoixuksJ.
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] Max subarray of no 2 adjacent elements

2011-08-01 Thread Abhishek Gupta
let the array be A={ 3,5,7,10} then it should give output as 13 (3+10)

In short, we need to find the possible maximum sum such that no 2 elements
in the subarray has 2 elements adjacent. there is no bound on the size of
subarray.
-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Odd one out

2011-08-01 Thread Abhishek Gupta
@gopi
inserting n elements, and then again checking each element?
nlogn??

On Sun, Jul 31, 2011 at 9:04 PM, Anika Jain anika.jai...@gmail.com wrote:

 @gopi: in 2nd of urs we after tree creation we will need to search each
 element in array that will take o(nlogn) time.. is there any appraoch tht
 reduces this?


 On Sun, Jul 31, 2011 at 6:39 PM, *$* gopi.komand...@gmail.com wrote:



 Q1-Construct a binary tree , in such a way that if element occured for
 the first time , insert into tree , if occurs at second time , remove from
 the list.
 As all elements except the one need to find are even , at the end of the
 list , all the tree will contain only one element.

 Q2- Construct a binary tree. similar to the above.
 Now again start from first element and check which element is missing in
 the tree. That is the required one.


 Thx,
 --Gopi


 On Sun, Jul 31, 2011 at 2:07 PM, Abhishek Gupta 
 gupta.abh...@gmail.comwrote:

 Q1- A large size array is given. All except one element are repeated
 even no. of times and one element is repeated odd no. of times. Find that
 element. Don't use X-OR

 Ans - Is there any efficient way of finding it without using sorting or
 removing duplicates or using hash tables??



 Q2- Same qn is like all except one are repeated off no. of times and one
 element repeated even no. of times. find that element. (no specification for
 X-OR use given)

 Ans- Again, I tried it using hash table.


 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




 --
 Thx,
 --Gopi

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Max subarray of no 2 adjacent elements

2011-08-01 Thread Abhishek Gupta
@Kartik

we cant choose adjacent elements. for ex A={5,2,1,7,9,11} then we will have
5+7+11
can any one give any algo for this
thank you

On Mon, Aug 1, 2011 at 1:25 PM, kartik sachan kartik.sac...@gmail.comwrote:

 oh..got it i didn't read that statement:(

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Max subarray of no 2 adjacent elements

2011-08-01 Thread Abhishek Gupta
@Prakash
can you post your solution please

On Mon, Aug 1, 2011 at 1:39 PM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 @Kartik

 we cant choose adjacent elements. for ex A={5,2,1,7,9,11} then we will have
 5+7+11
 can any one give any algo for this
 thank you


 On Mon, Aug 1, 2011 at 1:25 PM, kartik sachan kartik.sac...@gmail.comwrote:

 oh..got it i didn't read that statement:(

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Google Interview Question

2011-08-01 Thread Abhishek Gupta
A is an array of size 2n such that first n elements are integers in any
order and last n elements are characters.
i.e. A={i1 i2 i3 in c1 c2 c3... cn}
then we have to rearrange the elements such that final array is
A ={ i1 c1 i2 c2 .. in cn}


Example :
input : A ={ 5,1,4,d,r,a};
output : A= {5,d,1,r,4,a};

-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Max subarray of no 2 adjacent elements

2011-08-01 Thread Abhishek Gupta
Ya got it.
thanks a lot.
I was looking for dynamic solution only but unable to solve one.

On Mon, Aug 1, 2011 at 2:04 PM, Prakash D cegprak...@gmail.com wrote:

 I just thought of an O(n) dp solution

 let a[]=5,2,1,7,9,11

 traverse from i=0 to n-1

 we define arr[i]= a[i]+max(arr[i-2],arr[i-3));


 first arr[0]= 5 + max( a[-2], a[-3]) = 5

 arr[1]= 2

 arr[2]=1 + 5

 arr[3]= 7 + max(5,2) = 7+ 5 = 12

 then arr[4]= 9 + max(2,6) = 15

 then arr[5]= 11 + max(6,12) = 11+12 = 23


 now soln= max( arr[n-1], arr[n-2]) = 23


 hope i'm correct ..


 regards,

 D.Prakash,
 IT, IIIrd year, CEG.






 On Mon, Aug 1, 2011 at 1:39 PM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 @Prakash
 can you post your solution please


 On Mon, Aug 1, 2011 at 1:39 PM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 @Kartik

 we cant choose adjacent elements. for ex A={5,2,1,7,9,11} then we will
 have 5+7+11
 can any one give any algo for this
 thank you


 On Mon, Aug 1, 2011 at 1:25 PM, kartik sachan 
 kartik.sac...@gmail.comwrote:

 oh..got it i didn't read that statement:(

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Front/end operations

2011-08-01 Thread Abhishek Gupta
Q- Design a data structure that can have operations like addition deletion
working at any end but not in middle.

Ans- I was thinking of a circular doubly linked list and using head and
tail for operation on both sides.
or a two way stack, i.e. maintaining two counters for working on stack one
from top to bottom and another through bottom to top..
ex : top1=0, top2=n-1 where n is size of stack.
and use top1 to insert elements to index 0..1..2...
and top2 to insert elements to index n-1..n-2..n-3



-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] [offtopic] Something to share for those preparing for Amazon Campus Interviews!

2011-08-01 Thread Abhishek Gupta
@rahul thanks a lot.
can you tell some more questions they asked you.
I will surely try to read and code those questions.
also can you tell something about oracle written tests?

On Fri, Jul 29, 2011 at 1:58 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=alg_index


 On Fri, Jul 29, 2011 at 1:31 PM, Rahul Menon menonrahul1...@gmail.comwrote:

 @RAHUL SINGHAL
 Sorry to bother you!
 Unfortunately I cant find any such links in topcoder. Can you just share a
 link here!

 --
 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/-/kgVw78gONbIJ.

 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.




 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee


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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Max subarray of no 2 adjacent elements

2011-08-01 Thread Abhishek Gupta
@samba
i think you didnt get the question.
On Mon, Aug 1, 2011 at 5:56 PM, Samba Ganapavarapu sambasiv...@gmail.comwrote:

 Step 1
 Find the max element position in the array. ( save position maxElement
 variable ).
 This takes O (n)

 Step 2
 Find the max element position again ( this time exclude maxElement,
 (maxElement+1) and (maxElement-1) in the comparision ) save this position to
 secondElementRequired variable
 This takes O ( n )

 return array[ maxElement ] + array [secondElementRequired ]

 Thank you,
 Samba


 On Mon, Aug 1, 2011 at 5:31 AM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 Ya got it.
 thanks a lot.
 I was looking for dynamic solution only but unable to solve one.


 On Mon, Aug 1, 2011 at 2:04 PM, Prakash D cegprak...@gmail.com wrote:

 I just thought of an O(n) dp solution

 let a[]=5,2,1,7,9,11

 traverse from i=0 to n-1

 we define arr[i]= a[i]+max(arr[i-2],arr[i-3));


 first arr[0]= 5 + max( a[-2], a[-3]) = 5

 arr[1]= 2

 arr[2]=1 + 5

 arr[3]= 7 + max(5,2) = 7+ 5 = 12

 then arr[4]= 9 + max(2,6) = 15

 then arr[5]= 11 + max(6,12) = 11+12 = 23


 now soln= max( arr[n-1], arr[n-2]) = 23


 hope i'm correct ..


 regards,

 D.Prakash,
 IT, IIIrd year, CEG.






 On Mon, Aug 1, 2011 at 1:39 PM, Abhishek Gupta 
 gupta.abh...@gmail.comwrote:

 @Prakash
 can you post your solution please


 On Mon, Aug 1, 2011 at 1:39 PM, Abhishek Gupta 
 gupta.abh...@gmail.comwrote:

 @Kartik

 we cant choose adjacent elements. for ex A={5,2,1,7,9,11} then we will
 have 5+7+11
 can any one give any algo for this
 thank you


 On Mon, Aug 1, 2011 at 1:25 PM, kartik sachan kartik.sac...@gmail.com
  wrote:

 oh..got it i didn't read that statement:(

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Max subarray of no 2 adjacent elements

2011-08-01 Thread Abhishek Gupta
@samba
its not finding sum of 2 elements. its finding sum of subarray of any size
such that no 2 elements are adjacent

On Mon, Aug 1, 2011 at 6:38 PM, Samba Ganapavarapu sambasiv...@gmail.comwrote:

 @ Abhishek oh yea sorry.. I read it again, understood what I missed!
 I thought we need to find max possible sum of 2 elements excluding adjacent
 ones..  sorry guys.

 On Mon, Aug 1, 2011 at 8:54 AM, Abhishek Gupta gupta.abh...@gmail.comwrote:


 @samba
 i think you didnt get the question.

 On Mon, Aug 1, 2011 at 5:56 PM, Samba Ganapavarapu sambasiv...@gmail.com
  wrote:

 Step 1
 Find the max element position in the array. ( save position maxElement
 variable ).
 This takes O (n)

 Step 2
 Find the max element position again ( this time exclude maxElement,
 (maxElement+1) and (maxElement-1) in the comparision ) save this position to
 secondElementRequired variable
 This takes O ( n )

 return array[ maxElement ] + array [secondElementRequired ]

 Thank you,
 Samba


 On Mon, Aug 1, 2011 at 5:31 AM, Abhishek Gupta 
 gupta.abh...@gmail.comwrote:

 Ya got it.
 thanks a lot.
 I was looking for dynamic solution only but unable to solve one.


 On Mon, Aug 1, 2011 at 2:04 PM, Prakash D cegprak...@gmail.com wrote:

 I just thought of an O(n) dp solution

 let a[]=5,2,1,7,9,11

 traverse from i=0 to n-1

 we define arr[i]= a[i]+max(arr[i-2],arr[i-3));


 first arr[0]= 5 + max( a[-2], a[-3]) = 5

 arr[1]= 2

 arr[2]=1 + 5

 arr[3]= 7 + max(5,2) = 7+ 5 = 12

 then arr[4]= 9 + max(2,6) = 15

 then arr[5]= 11 + max(6,12) = 11+12 = 23


 now soln= max( arr[n-1], arr[n-2]) = 23


 hope i'm correct ..


 regards,

 D.Prakash,
 IT, IIIrd year, CEG.






 On Mon, Aug 1, 2011 at 1:39 PM, Abhishek Gupta gupta.abh...@gmail.com
  wrote:

 @Prakash
 can you post your solution please


 On Mon, Aug 1, 2011 at 1:39 PM, Abhishek Gupta 
 gupta.abh...@gmail.com wrote:

 @Kartik

 we cant choose adjacent elements. for ex A={5,2,1,7,9,11} then we
 will have 5+7+11
 can any one give any algo for this
 thank you


 On Mon, Aug 1, 2011 at 1:25 PM, kartik sachan 
 kartik.sac...@gmail.com wrote:

 oh..got it i didn't read that statement:(

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

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

[algogeeks] Odd one out

2011-07-31 Thread Abhishek Gupta
Q1- A large size array is given. All except one element are repeated even
no. of times and one element is repeated odd no. of times. Find that
element. Don't use X-OR

Ans - Is there any efficient way of finding it without using sorting or
removing duplicates or using hash tables??



Q2- Same qn is like all except one are repeated off no. of times and one
element repeated even no. of times. find that element. (no specification for
X-OR use given)

Ans- Again, I tried it using hash table.


-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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: Direct - i ques

2011-07-31 Thread Abhishek Gupta
@shubham maheshawari

deletion can't be performed in O(1).
after extracting the min element, we need to find the next minimum element,
and worst case will take O(n) time.

On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari
shubham@gmail.comwrote:

 hw cn u ensure that the elements are inserted in sorted order ...
 wat if the elements are coming randmly ...

 On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote:






 Use a circular linked list with elements being inserted in sorted order.

 Inserting minimum element :

 struct node *p;
 p is a pointer to last node in the circular singly linked list.
 newmin-next=p-next;
 p-next=newmin;


 Deleting minimum element:

 struct node *temp;
 temp=p-next;
 p-next=p-next-next;
 free(temp);


 Retrieving minimum element :

 return (p-next-ele);








 *Muthuraj R
 IV th Year , ISE
 PESIT , Bangalore*




 On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.com wrote:

 @shubham...i have a doubt.can't the same be done with singly linked
 list??

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


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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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: C doubt

2011-07-31 Thread Abhishek Gupta
@Nikhil
yes.


On Sun, Jul 31, 2011 at 3:02 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 If the function takes in an int argument, then is it modified to

 int (*func[N]) (int);   ?


 On Sun, Jul 31, 2011 at 2:56 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 yup its correct...

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




 --
 Nikhil Gupta
 Senior Co-ordinator, Publicity
 CSI, NSIT Students' Branch
 NSIT, New Delhi, India

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Termination

2011-07-31 Thread Abhishek Gupta
compiler : gcc, OS : Fedora 15

I use ctrl + d to put EOF in files.

you can verify it through this code

#includestdio.h
int main(int argc,char *argv[])
{int c;
while((c=getchar())!=EOF)
{
 putchar(c);
 }
 if(c==EOF)
 printf(EOF Break);
 return 0;
 }



On Sun, Jul 31, 2011 at 3:05 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:

 Is it possible to terminate this code(except break) while it is
 executing..? For what eof will this terminate..?


 #includestdio.h
 main(int argc,char *argv[])
 {int c;
 while((c=getchar())!=EOF)
 {
  putchar(c);
  }
  }

 Reply fast...

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Termination

2011-07-31 Thread Abhishek Gupta
I am only using linux. google it. it must be some ctrl + any key sequence

On Sun, Jul 31, 2011 at 3:12 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:

 ctrl+D doesnt work on dev , os windows 7...

 On 7/31/11, Puneet Gautam puneet.nsi...@gmail.com wrote:
  Is the eof different for different OS's..?
 
  On 7/31/11, Abhishek Gupta gupta.abh...@gmail.com wrote:
  compiler : gcc, OS : Fedora 15
 
  I use ctrl + d to put EOF in files.
 
  you can verify it through this code
 
  #includestdio.h
  int main(int argc,char *argv[])
  {int c;
  while((c=getchar())!=EOF)
  {
   putchar(c);
   }
   if(c==EOF)
   printf(EOF Break);
   return 0;
   }
 
 
 
  On Sun, Jul 31, 2011 at 3:05 PM, Puneet Gautam
  puneet.nsi...@gmail.comwrote:
 
  Is it possible to terminate this code(except break) while it is
  executing..? For what eof will this terminate..?
 
 
  #includestdio.h
  main(int argc,char *argv[])
  {int c;
  while((c=getchar())!=EOF)
  {
   putchar(c);
   }
   }
 
  Reply fast...
 
  --
  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.
 
 
 
 
  --
  Abhishek Gupta
  MCA
  NIT Calicut
  Kerela
 
  --
  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.




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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: Direct - i ques

2011-07-31 Thread Abhishek Gupta
Qn is : Create a data structure where inserting, deleting and finding the
minimum element all have O(1) time.

so after deleting the minimum element, where will you point min pointer?

Sorry if i m wrong

On Sun, Jul 31, 2011 at 3:11 PM, Shubham Maheshwari
shubham@gmail.comwrote:

 the operation is nt extract min ... its *find* min ...



 On Sun, Jul 31, 2011 at 3:02 PM, Abhishek Gupta gupta.abh...@gmail.comwrote:

 @shubham maheshawari

 deletion can't be performed in O(1).
 after extracting the min element, we need to find the next minimum
 element, and worst case will take O(n) time.

 On Sun, Jul 31, 2011 at 3:00 PM, Shubham Maheshwari 
 shubham@gmail.com wrote:

 hw cn u ensure that the elements are inserted in sorted order ...
 wat if the elements are coming randmly ...

 On Sun, Jul 31, 2011 at 2:49 PM, muthu raj muthura...@gmail.com wrote:






 Use a circular linked list with elements being inserted in sorted order.

 Inserting minimum element :

 struct node *p;
 p is a pointer to last node in the circular singly linked list.
 newmin-next=p-next;
 p-next=newmin;


 Deleting minimum element:

 struct node *temp;
 temp=p-next;
 p-next=p-next-next;
 free(temp);


 Retrieving minimum element :

 return (p-next-ele);








 *Muthuraj R
 IV th Year , ISE
 PESIT , Bangalore*




 On Sun, Jul 31, 2011 at 2:08 AM, naveen ms naveenms...@gmail.comwrote:

 @shubham...i have a doubt.can't the same be done with singly linked
 list??

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


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




 --
 Abhishek Gupta
 MCA
 NIT Calicut
 Kerela

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] Any help on bits?

2011-07-31 Thread Abhishek Gupta
int BitSwap(int A,int B)
{
   int num=A^B;
   int count=0;
   while(num!=0)
   {
num=num(num-1);
count++;
}
return count;
}


this will run in O(m) where m is no. of ON bits (1's).
is there any other optimal solution for finding no. of 1's in a number?


On Sun, Jul 31, 2011 at 5:57 PM, prateek gupta prateek00...@gmail.comwrote:

 C= A^B then count number of bits set in C.


 On Sun, Jul 31, 2011 at 5:52 PM, Nikhil Gupta 
 nikhilgupta2...@gmail.comwrote:

 Given two integers A  B. Determine how many bits required to convert A to
 B. Write a function int BitSwapReqd(int A, int B);

 --
 Nikhil Gupta

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




 --
 Prateek Gupta
 7th sem, Information Technology,
 Netaji Subhas Institute Of Technology
 Delhi.

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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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: Amazon

2011-07-30 Thread Abhishek Gupta
Can you please post those 2 questions here in detail which they asked for
compilation and output.

On Sat, Jul 30, 2011 at 1:18 PM, Rajeev Jayaswal justjayas...@gmail.comwrote:

 q1
 #define sqr(x) x*x
 wat vl be d value of 64/sqr(4);

 q2
 and 1 quest was from probability...
 i dont remember the exact question .!!
 and yeah, one question was from lex and yacc one grammar  was given
  (aab)*bba  ( dont remember exact pattern ) and 4 option was given out of
 which one language (example) had to be chosen which does not fall on that
 grammar.


 On Sat, Jul 30, 2011 at 1:06 PM, arvind kumar arvindk...@gmail.comwrote:

 Can u please a few questions here..It will be helpful to others.

 On 7/30/11, Rajeev Jayaswal justjayas...@gmail.com wrote:
  hii ...
Yeah i m from NIT warangal , and i took the amazon test day b4
  yesterday , and total there were 20 question out of which two question
 was
  to write d progm and compile it and get the correct output for  addition
 of
  number storing element in link list and rest 18 question were MCQ type
 and
  was pretty easy .
  MCQ were from maths , c++ and DS .
 
  --
  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/-/RkaYhh8LSCYJ.
  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.




 --
 Rajeev Jayaswal
 CSE, NIT Warangal.
 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.




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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: adobe written round que

2011-07-30 Thread Abhishek Gupta
 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.




 --
 Aditi Garg
 Undergraduate Student
 Electronics  Communication Divison
 NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
 Sector 3, Dwarka
 New Delhi


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




 --
 The more you sweat in the field, the less you bleed in war.

 Ankit Minglani



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




-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

-- 
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] printing integer of more than 4 bytes

2011-07-30 Thread Abhishek Gupta
#includestdio.h
int main()
{
factorial(20);
return 0;
}

int factorial(int n)
{
if(n==1)
 return 1;
   else
printf(%d,n*factorial(n-1));
}


its printing the result. i think it should not as sizeof(int) on linux
fedora 15 compile:gcc is 4bytes.
can anyone explain why?

-- 
Abhishek Gupta
MCA
NIT Calicut
Kerela

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