Re: [algogeeks] How will you implement a stack using a priority queue. Push and pop should be in O(1)

2013-05-25 Thread Ankur Khurana
but in this approach , How is Push having O(1)  complexity ?


On 25 May 2013 17:52, rohit jangid rohit.nsi...@gmail.com wrote:

 you are doing it correct.


 On Sat, May 25, 2013 at 5:37 PM, Nishant Pandey 
 nishant.bits.me...@gmail.com wrote:

 I am not getting the y priority Q is getting used for this question, as
 in case of P Queue, things are arranged as per the priority so when we will
 insert the data we can simply increament the priority.

 Algo would be like this :

 Enque(q, data) {
   push(q, data, increrase the prioroty);
 }

 int Deque() {
 return pop();
 }

 here higher priority  one shuld be poped first.

 PLEASE SUGGEST if any good approach some one is having other than this ?


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to algogeeks+unsubscr...@googlegroups.com.






 --
 Rohit Jangid
 http://rohitjangid.com
 Graduate
 Deptt. of Computer Engineering
 NSIT, Delhi University, India

  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to algogeeks+unsubscr...@googlegroups.com.






-- 
Regards,
Ankur Khurana
Software Developer Engineer,
Microsoft India Development Center,
Hyderabad.

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.




Re: [algogeeks] Re: royal bank of scotland

2011-09-17 Thread Ankur Khurana
For internship it was , Percentage , then GD followed by two PI. For
placements it is e-litmus followed by percentage ( may be gd as well ) then
interview.

On Sat, Sep 17, 2011 at 7:56 AM, gaurav bansal gbgaur...@gmail.com wrote:

 is GD a part of a selection process or only personal interviews are
 taken after shortlisting

 On Sep 16, 10:30 pm, rahul sharma rahul23111...@gmail.com wrote:
  i was teellling about placement procedure
 
  On Fri, Sep 16, 2011 at 9:12 PM, Rahul Verma rahulverma@gmail.com
 wrote:
 
 
 
 
 
 
 
   Opportunities for the experienced candidates.
 
   --
   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/-/y6n4Hd9fqTQJ.
 
   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.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Remove all Duplicates Words

2011-08-24 Thread Ankur Khurana
Dave: are you not too much rude here ? yes it is one's responsibility to
read the question but it is equally important to be humble . Same things can
be answered and asked in different tones.  Just try to maintain yours.

Yours truly,
A fellow brainstorm-er .

On Thu, Aug 25, 2011 at 8:21 AM, Dave dave_and_da...@juno.com wrote:

 @Sagar: And how do you use hashing without extra memory? Please,
 please, please read the question, and don't bother to reply if you
 can't answer it?

 Dave

 On Aug 24, 11:10 am, sagar pareek sagarpar...@gmail.com wrote:
  use hashing
 
  On Wed, Aug 24, 2011 at 8:43 PM, UMESH KUMAR kumar.umesh...@gmail.com
 wrote:
 
   Qn. Remove all duplicates words from given a line without using extra
   memory ?
 
   Ex:-Hello word hello hi
   Out put:- Hello word hi
 
--
   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.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Doubt

2011-08-21 Thread Ankur Khurana
can somebody please explain this ?

On Sun, Aug 21, 2011 at 8:08 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote:

 http://www.ideone.com/kRaMj

 I found this in the algogeeks forum only. Can anyone explain how value of i
 is still 0, but *p shows 2 although their addresses are the same.

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] C Output

2011-08-14 Thread Ankur Khurana
5 will represent address of 5 in heap. so adding 3 to 5 increment tht
address by 3 and print it on the screen

On Sun, Aug 14, 2011 at 11:44 AM, Brijesh Upadhyay 
brijeshupadhyay...@gmail.com wrote:

 int main ()
 {
   printf(%d,1+2+5);
   getch();
   return 0;
 }


 what should it return and how..??

 --
 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/-/2H3Gg6hLEQ0J.
 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.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] os

2011-08-14 Thread Ankur Khurana
@roy : yes , kind of , i didnt know the exact technical term for it. Not
exactly PCB but process can maintain a lookup table for all the shared
variable and there corresposing threads . or for every thread the shared
variable. or ,may be in the thread itself, you can have a linked list
pointer which points to all the shared variable list. Before terminating ,
get that address. I mean it is imagination, i suggested some ways but i
exactly dont know what Windows or Unix employs to do the task.

On Sun, Aug 14, 2011 at 3:03 PM, aalam roy aalamr...@gmail.com wrote:

 @ankur i think you are talking about cleanup handlers. these are the
 functions which are executed when a thread terminates. but can you give any
 hint how it can be accomplished using process control block.


 On Sun, Aug 14, 2011 at 2:15 PM, Kamakshii Aggarwal kamakshi...@gmail.com
  wrote:

 @ankur::nahi samajh aaya..:(


 On Sun, Aug 14, 2011 at 9:46 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 My 2 cents,
 When the termination signal is sent to the thread either synchronously or
 asynchronously , you just have a mechanism in place that if that thread is
 in critical section , it exits from there and and unlocks the mutex at point
 of exit. This can be  done by  associating a tokken with the thread that it
 is executing in critical section and what mutex it locked. O we can do this
 by making some table in Process control block.

 On Sat, Aug 13, 2011 at 7:56 PM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:


 How do you make sure to unlock a mutex which was locked in a thread that
 dies/terminates?
 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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




 --
 Ankur Khurana
 Computer Science
 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.




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks]

2011-08-14 Thread Ankur Khurana
Kamz: Maafi :P , did a silly mistake.

On Sun, Aug 14, 2011 at 2:12 PM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:

 @ankur:tere code se wrong answer ayegafor n=4 there are 5 solutions...
 therefore arr[2]should be 2,par teer code me its 1...
 arr[1]=1
 arr[2]=2;
 now start from arr[3];

 On Sun, Aug 14, 2011 at 9:57 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 it's a simple dp , ned not be knapsack one.

 int arr[n];
 arr[0]=0
 arr[1]=1;

 for(int i=2;i=n;i++)
 {
 arr[i]=arr[i-1]+arr[i-2];
 }

 do you get the code ? i mean , pseudo code was almost similar.


 On Sun, Aug 14, 2011 at 1:34 AM, sagar pareek sagarpar...@gmail.comwrote:

 Sorry 4 above post i thought it a diff ques


 On Sun, Aug 14, 2011 at 1:33 AM, sagar pareek sagarpar...@gmail.comwrote:

 its n/2+1


 On Sat, Aug 13, 2011 at 8:45 PM, Puneet Goyal 
 puneetgoya...@gmail.comwrote:

 I think it's fibonacci series...
 T(n)= T(n-1) + T(n-2)

 Explanation:
 T(n): no. of ways for n stairs

 T(n-1): when it took the first step as 1 stair

 t(n-2): when it took the first step as 2 stairs

 the series can be started as
 T(1)=1
 T(2)=2
 and calculate the rest from above

 On Sat, Aug 13, 2011 at 8:37 PM, Gaurav Menghani 
 gaurav.mengh...@gmail.com wrote:

 Knapsack DP

 On Sat, Aug 13, 2011 at 8:35 PM, Kamakshii Aggarwal
 kamakshi...@gmail.com wrote:
  yes
 
  On Sat, Aug 13, 2011 at 8:30 PM, Puneet Goyal 
 puneetgoya...@gmail.com
  wrote:
 
  1 or 2 stairs?
 
  On Sat, Aug 13, 2011 at 8:24 PM, Kamakshii Aggarwal
  kamakshi...@gmail.com wrote:
 
  Given n stairs, how many number of ways can you climb if u use
 either 1
  or 2 at a time?
  --
  Regards,
  Kamakshi
  kamakshi...@gmail.com
 
  --
  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.
 
 
 
  --
 
 ---
  Puneet Goyal
  Student of B. Tech. III Year (Software Engineering)
  Delhi Technological University, 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,
  Kamakshi
  kamakshi...@gmail.com
 
  --
  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.
 



 --
 Gaurav Menghani

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




 --
 ---
 Puneet Goyal
 Student of B. Tech. III Year (Software Engineering)
 Delhi Technological University, 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




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




 --
 Ankur Khurana
 Computer Science
 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

Re: [algogeeks] Re: an array question

2011-08-14 Thread Ankur Khurana
 digits,
 copy
   it into the second array. If the ith number has less than m
 digits,
   concatenate duplicates of the last digit of the integer to the
 right
   end to expand it to m digits. Examples: m = 3, 7 goes to 777; 82
 goes
   to 822; 29 goes to 299; 0 goes to 000.
 
   Sort the second array into descending order and carry the first
 array
   along (apply the same permutations to the first array as you do
 to the
   second).
 
   Concatenate the integers in the first array to get the result.
 
   Dave
 
   On Aug 12, 7:34 am, Yasir Imteyaz yasir@gmail.com wrote:
An array of integers is given and you have to find the largest
 possible
integer by concatenating all elements:
 
example:
array:  87  36  52
answer:  875236
 
array: 87 9 52
answer: 98752
 
   --
   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.


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


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


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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: an array question

2011-08-14 Thread Ankur Khurana
why will 678 come after 583 ?
okay ., sort from least to most significant digit. append imaginary 0's at
the end of the numbers with varying length to make them of same length

On Sun, Aug 14, 2011 at 5:54 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:

 @ankur: No its not radix sort...radix sort would give wrong answer
 when the input contains heterogeneous numbered digits in the
 array(even when going 4m msd to lsd)...
 eg:
 32,583,678,1,45,9

 Radix sort would give:
 9,583,678,45,32,1

 whereas the answer has to be:

 9,678,543,45,32,1
 and hence largest no created is 967854345321

 I think thats the way radix sort will work...

 Correct me if i m wrong...!


 On 8/14/11, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  isn't it a simple question of applying radix sort from most significant
 to
  least signigicant digit and concatenating all the sorted numbers to get
 the
  largest number..
 
  On Sat, Aug 13, 2011 at 11:13 PM, Kunal Patil kp101...@gmail.com
 wrote:
 
  Let me clarify.
 
  Lets take example
  53
  147
  1471470
 
  As per algo:
  sort 5353535 , 1471471 and 1471470 lexicographically to get
 answer.
  But You are not going to compare all these simultaneously.
  Might be you will first compare 53 and 147 for lexicographical order. In
  this case you are not required  to calculate till max length.
  In fact while comparing two strings you will require only till
 (max(len1,
  len2)).
  (verify it !!)
  Comparing 53 and 1471470 doesn't even require till max length.
  Comparing 147 and 1471470 (co-incidentally) requires till max length.
  (worst case !)
 
 
  Consider you have only 2 strings.
  Then above code gives lexicographically largest of these two
  (This comparison is considering circular appending).
  You can now use this comparator function as parameter for sort()
 function
  in c++.
  So given set of strings as the input and this comparator function it
 will
  sort as per given criteria.
 
  I mentioned you have to append circularly till largest of all string
  length only for illustration purpose and to make understanding easier.
  Had I mentioned go on comparing each of 2 strings till max(len1,len2),
 It
  might not be grasped quickly.
  As you can see you will not always require string upto largest length to
  determine lexicographical order of 2 strings.
 
  I am bad at explaining things. So let me know whether this solved your
  doubt.
 
 
 
  On Sat, Aug 13, 2011 at 10:35 PM, aditi garg
  aditi.garg.6...@gmail.comwrote:
 
  @ kunal : arent we supposed to construct the string fr each number
 equal
  to the max length of any number...
  whr r v doing dat chking in dis algo?
 
 
  On Sat, Aug 13, 2011 at 10:25 PM, Kunal Patil kp101...@gmail.com
 wrote:
 
  I dont know whether this is best approach to do step 2 or not. But
 it's
  certainly good.
 
 
  //I will show for two strings s1 and s2
 
  len1 = s1.length();
  len2 = s2.length();
  ind1 = 0; //Index in the first string
  ind2 = 0; //Index in the second string
 
  while( ind1len1 ||  ind2  len2 ) //Match until both strings exhaust
 or
  function returns
  {
  if(ind1 == len1)  // String s1 has exhausted, so start over it
  ind1 = 0;
 
  if(ind2 == len2)  // String s2 has exhausted, so start over it
  ind2 = 0;
 
  for(; ind1  len1  ind2 len2; ind1++,ind2++ )
  // Go on comparing until any of the string exhausts or function
 returns
  {
  if( s1[ind1] == s2[ind2] ) //Same current char in both string so we
 need
  to match more char
  continue;
  else // mismatch
  return (s1[ind1]  s2 [ind2] );
  }
  }
 
  if (ind1==len1  ind2==len2) // same strings
  return true;
 
  //If I missed anything in the code, let me know
 
 
  On Sat, Aug 13, 2011 at 9:29 PM, aditi garg
  aditi.garg.6...@gmail.comwrote:
 
  @kunal: what is the best way to implement step 2?
 
 
  On Sat, Aug 13, 2011 at 7:33 PM, Ashish Sachdeva 
  ashish.asachd...@gmail.com wrote:
 
  @kunal: seems fine.. tried it on some cases...
 
 
  On Sat, Aug 13, 2011 at 5:17 PM, Kunal Patil
  kp101...@gmail.comwrote:
 
  Following approach should work:
 
  1)  Count max number of digit in any integer of input. Let it be m.
  (Thanks to dave..)
 
  2) For each int having less than m digits:
Convert it to string of length m where you append circularly.
For e.g. if m=5
 53 -- 53535
 100 -- 10010
 34343 -- 34343
 8 -- 8
 
  3) Now lexicographically sort all those strings. Apply same
  permutations to first array of integers. (again, thanx to Dave)
 
  4) Concatenate integers of first array.
 
  For e.g.
  8   53   147  159  1471470   71
  m=7
  corresponding string array becomes:
  888
  5353535
  1471471
  1591591
  1471470
  7171717
 
  Apply step 3. This gives int array as 8  71  53  15  147  1471470
 
  Thus, solution is 87153151471471470.
 
  Let me know about any counter-examples...
 
  You can apply tricks in programming language that will allow you to
  save actually calculating these strings.
  For e.g

Re: [algogeeks] Re: an array question

2011-08-14 Thread Ankur Khurana
as they havve different number of digits, we append 0 at the end after 1. so
the two numbers are 90,10 . after appending you get 901. Basically , i think
it is lexographic sorting 

On Mon, Aug 15, 2011 at 12:05 AM, Kunal Patil kp101...@gmail.com wrote:

 What about the case 1, 90 ?
 It will give 190 as the answer, isn't it?
 Or am I getting your algo wrong?


 On Sun, Aug 14, 2011 at 11:56 PM, Dipankar Patro dip10c...@gmail.comwrote:

 Ankur, I agree with your algo.

 - radix sort from least significant to most significant.
 - a slight modification can be done on the appending 0 part.
 when you find the a digit is absent from the number, you leave the number.
 e.g
 95, 87, 9, 45, 38

 one's place, sort: (descending)
 9, 38, 87, 95, 45

 ten's place sort: (leave the number at its place if it doesn't have a
 ten's place)
 9, 95, 87, 45, 38

 ^^ I think this will work for all cases. Will require extremely good use
 of pointers.

 On 14 August 2011 19:16, Ankur Khurana ankur.kkhur...@gmail.com wrote:

 why will 678 come after 583 ?
 okay ., sort from least to most significant digit. append imaginary 0's
 at the end of the numbers with varying length to make them of same
 length


 On Sun, Aug 14, 2011 at 5:54 PM, Puneet Gautam 
 puneet.nsi...@gmail.comwrote:

 @ankur: No its not radix sort...radix sort would give wrong answer
 when the input contains heterogeneous numbered digits in the
 array(even when going 4m msd to lsd)...
 eg:
 32,583,678,1,45,9

 Radix sort would give:
 9,583,678,45,32,1

 whereas the answer has to be:

 9,678,543,45,32,1
 and hence largest no created is 967854345321

 I think thats the way radix sort will work...

 Correct me if i m wrong...!


 On 8/14/11, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  isn't it a simple question of applying radix sort from most
 significant to
  least signigicant digit and concatenating all the sorted numbers to
 get the
  largest number..
 
  On Sat, Aug 13, 2011 at 11:13 PM, Kunal Patil kp101...@gmail.com
 wrote:
 
  Let me clarify.
 
  Lets take example
  53
  147
  1471470
 
  As per algo:
  sort 5353535 , 1471471 and 1471470 lexicographically to get
 answer.
  But You are not going to compare all these simultaneously.
  Might be you will first compare 53 and 147 for lexicographical order.
 In
  this case you are not required  to calculate till max length.
  In fact while comparing two strings you will require only till
 (max(len1,
  len2)).
  (verify it !!)
  Comparing 53 and 1471470 doesn't even require till max length.
  Comparing 147 and 1471470 (co-incidentally) requires till max length.
  (worst case !)
 
 
  Consider you have only 2 strings.
  Then above code gives lexicographically largest of these two
  (This comparison is considering circular appending).
  You can now use this comparator function as parameter for sort()
 function
  in c++.
  So given set of strings as the input and this comparator function it
 will
  sort as per given criteria.
 
  I mentioned you have to append circularly till largest of all string
  length only for illustration purpose and to make understanding
 easier.
  Had I mentioned go on comparing each of 2 strings till
 max(len1,len2), It
  might not be grasped quickly.
  As you can see you will not always require string upto largest length
 to
  determine lexicographical order of 2 strings.
 
  I am bad at explaining things. So let me know whether this solved
 your
  doubt.
 
 
 
  On Sat, Aug 13, 2011 at 10:35 PM, aditi garg
  aditi.garg.6...@gmail.comwrote:
 
  @ kunal : arent we supposed to construct the string fr each number
 equal
  to the max length of any number...
  whr r v doing dat chking in dis algo?
 
 
  On Sat, Aug 13, 2011 at 10:25 PM, Kunal Patil kp101...@gmail.com
 wrote:
 
  I dont know whether this is best approach to do step 2 or not. But
 it's
  certainly good.
 
 
  //I will show for two strings s1 and s2
 
  len1 = s1.length();
  len2 = s2.length();
  ind1 = 0; //Index in the first string
  ind2 = 0; //Index in the second string
 
  while( ind1len1 ||  ind2  len2 ) //Match until both strings
 exhaust or
  function returns
  {
  if(ind1 == len1)  // String s1 has exhausted, so start over it
  ind1 = 0;
 
  if(ind2 == len2)  // String s2 has exhausted, so start over it
  ind2 = 0;
 
  for(; ind1  len1  ind2 len2; ind1++,ind2++ )
  // Go on comparing until any of the string exhausts or function
 returns
  {
  if( s1[ind1] == s2[ind2] ) //Same current char in both string so we
 need
  to match more char
  continue;
  else // mismatch
  return (s1[ind1]  s2 [ind2] );
  }
  }
 
  if (ind1==len1  ind2==len2) // same strings
  return true;
 
  //If I missed anything in the code, let me know
 
 
  On Sat, Aug 13, 2011 at 9:29 PM, aditi garg
  aditi.garg.6...@gmail.comwrote:
 
  @kunal: what is the best way to implement step 2?
 
 
  On Sat, Aug 13, 2011 at 7:33 PM, Ashish Sachdeva 
  ashish.asachd...@gmail.com wrote:
 
  @kunal: seems fine.. tried it on some cases

Re: [algogeeks] Memory Leak

2011-08-14 Thread Ankur Khurana
@rajeev  +1 . great software .

On Mon, Aug 15, 2011 at 9:33 AM, rajeev bharshetty rajeevr...@gmail.comwrote:

 Valgrind is an effective open source tool to detect memory leaks and many
 more bugs in the program.

 http://valgrind.org/


 On Mon, Aug 15, 2011 at 6:31 AM, *$* gopi.komand...@gmail.com wrote:

 use crtdbg.h

 _crtdumpmemoryleaks() .. will work only in debug version.


 On Mon, Aug 15, 2011 at 4:01 AM, Ankur Garg ankurga...@gmail.com wrote:

 Where ever u have allocated dynamic memory that qualifies to be a culprit
 for causing memory leak ...Scan through the code if the memory block has
 been deallocated or not ...


 Regards
 Ankur


 On Sun, Aug 14, 2011 at 6:03 PM, SAMMM somnath.nit...@gmail.com wrote:

 How to detect in which line the Memory Leak has occured ?? I want the
 line number where the Memory leak occurs ??? Give every wild answer u
 can think off 

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




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




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: an array question

2011-08-14 Thread Ankur Khurana
Just a qestion, how do you sort lexographically ? that is tha approach that
we will apply here.. .and yes the approach is flawed. will come with a
solution soon..

On Mon, Aug 15, 2011 at 8:42 AM, Dipankar Patro dip10c...@gmail.com wrote:

 @ Kunal:
 oh. zero is making some nice test cases. I will have to reconsider the
 solution that I provided.


 On 15 August 2011 01:53, Yasir yasir@gmail.com wrote:

 Not Sure! Me too looking for a solution.. :D

 So far,  Kunal's approach (Convert each string to length max_size where
 you append it circularly) seems to be working fine.  :-)

 ..and Chengjie's approach should also work, but the interviewer rejected
 this idea saying, he wants a good logic for this.  :)

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

 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.




 --

 ___

 Please do not print this e-mail until urgent requirement. Go Green!!
 Save Papers = Save Trees

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] matrix question ???!!!!!!!!!!??????????

2011-08-14 Thread Ankur Khurana
 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.



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


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


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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] os

2011-08-13 Thread Ankur Khurana
My 2 cents,
When the termination signal is sent to the thread either synchronously or
asynchronously , you just have a mechanism in place that if that thread is
in critical section , it exits from there and and unlocks the mutex at point
of exit. This can be  done by  associating a tokken with the thread that it
is executing in critical section and what mutex it locked. O we can do this
by making some table in Process control block.

On Sat, Aug 13, 2011 at 7:56 PM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:


 How do you make sure to unlock a mutex which was locked in a thread that
 dies/terminates?
 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Printing a Number triangle

2011-08-13 Thread Ankur Khurana
see , we can see that
first lline have 1 number, second have 2 and third have 3 .and so on. we
can observe that first number of every row is sum of first k narutal number,
where k is the row number. so for k=4, n=((4+1)*4)/2=10;

so run a for loop,


for(int i=1;inum_rows;i++)
{
prev=((i-)*i)/2;
k=((i+1)*i)/2;
for(int j=k;i;kprev;j--)
   {
coutprev ;
}
coutendl;
}


On Sun, Aug 14, 2011 at 9:43 AM, Dave dave_and_da...@juno.com wrote:

 @Beginner: The largest number n in row r satisfies n = (r^2 + r) / 2.
 So using the Quadratic Formula gives

 r = ( sqrt( 8*n + 1 ) - 1 ) / 2.

 For the row number r for any n (not necessarily the largest one in a
 row),

 r = ceil( sqrt( 8*n + 1 ) - 1 ) / 2 )

 where ceil( x ) is the smallest integer not exceeding x.

 Dave

 On Aug 13, 10:22 pm, Beginner murugavidya1...@gmail.com wrote:
  How to print this triangle?
  1
  3 2
  6 5 4
  10 9 8 7
   and how to find the number of rows if n is given?
  For ex if n=10 how to find num of rows=4??
  Is it Log 10 to the base of 2!!

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks]

2011-08-13 Thread Ankur Khurana
it's a simple dp , ned not be knapsack one.

int arr[n];
arr[0]=0
arr[1]=1;

for(int i=2;i=n;i++)
{
arr[i]=arr[i-1]+arr[i-2];
}

do you get the code ? i mean , pseudo code was almost similar.


On Sun, Aug 14, 2011 at 1:34 AM, sagar pareek sagarpar...@gmail.com wrote:

 Sorry 4 above post i thought it a diff ques


 On Sun, Aug 14, 2011 at 1:33 AM, sagar pareek sagarpar...@gmail.comwrote:

 its n/2+1


 On Sat, Aug 13, 2011 at 8:45 PM, Puneet Goyal puneetgoya...@gmail.comwrote:

 I think it's fibonacci series...
 T(n)= T(n-1) + T(n-2)

 Explanation:
 T(n): no. of ways for n stairs

 T(n-1): when it took the first step as 1 stair

 t(n-2): when it took the first step as 2 stairs

 the series can be started as
 T(1)=1
 T(2)=2
 and calculate the rest from above

 On Sat, Aug 13, 2011 at 8:37 PM, Gaurav Menghani 
 gaurav.mengh...@gmail.com wrote:

 Knapsack DP

 On Sat, Aug 13, 2011 at 8:35 PM, Kamakshii Aggarwal
 kamakshi...@gmail.com wrote:
  yes
 
  On Sat, Aug 13, 2011 at 8:30 PM, Puneet Goyal 
 puneetgoya...@gmail.com
  wrote:
 
  1 or 2 stairs?
 
  On Sat, Aug 13, 2011 at 8:24 PM, Kamakshii Aggarwal
  kamakshi...@gmail.com wrote:
 
  Given n stairs, how many number of ways can you climb if u use
 either 1
  or 2 at a time?
  --
  Regards,
  Kamakshi
  kamakshi...@gmail.com
 
  --
  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.
 
 
 
  --
 
 ---
  Puneet Goyal
  Student of B. Tech. III Year (Software Engineering)
  Delhi Technological University, 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,
  Kamakshi
  kamakshi...@gmail.com
 
  --
  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.
 



 --
 Gaurav Menghani

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




 --
 ---
 Puneet Goyal
 Student of B. Tech. III Year (Software Engineering)
 Delhi Technological University, 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




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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] c question

2011-08-13 Thread Ankur Khurana
aren't two programs same ? and scheduling of two forked and parent process
is prcoessor dependent. You dont have a say in it.
On Sun, Aug 14, 2011 at 1:21 AM, thanu moorthy moorthyth...@gmail.comwrote:

 #includestdio.h
 #includeunistd.h
 int main()
 {
   int return_value;
   printf(forking process);
   fork();
 printf(hello\n);
 return 0;

  }

 in the above program the output is

 forking processhello
 forking processhello

 but in the below prog


   includestdio.h
 #includeunistd.h
 int main()
 {
   int return_value;
   printf(forking process\n);
   fork();
 printf(hello\n);
 return 0;

  }
 the output is
 forking process
 hello
 hello

 why its so ??

 --
 by $THANU$

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Printing a Number triangle

2011-08-13 Thread Ankur Khurana
to print from 10 to 7 in the row number 4. here prev will be 6.

On Sun, Aug 14, 2011 at 10:05 AM, AASHISH SUMAN
aashish.barn...@gmail.comwrote:

 @ankur

 what is the need of
 prev=((i-)*i)/2;




 On Sun, Aug 14, 2011 at 9:51 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 see , we can see that
 first lline have 1 number, second have 2 and third have 3 .and so on.
 we can observe that first number of every row is sum of first k narutal
 number, where k is the row number. so for k=4, n=((4+1)*4)/2=10;

 so run a for loop,


 for(int i=1;inum_rows;i++)
 {
 prev=((i-)*i)/2;
 k=((i+1)*i)/2;
 for(int j=k;i;kprev;j--)
{
 coutprev ;
 }
 coutendl;
 }


 On Sun, Aug 14, 2011 at 9:43 AM, Dave dave_and_da...@juno.com wrote:

 @Beginner: The largest number n in row r satisfies n = (r^2 + r) / 2.
 So using the Quadratic Formula gives

 r = ( sqrt( 8*n + 1 ) - 1 ) / 2.

 For the row number r for any n (not necessarily the largest one in a
 row),

 r = ceil( sqrt( 8*n + 1 ) - 1 ) / 2 )

 where ceil( x ) is the smallest integer not exceeding x.

 Dave

 On Aug 13, 10:22 pm, Beginner murugavidya1...@gmail.com wrote:
  How to print this triangle?
  1
  3 2
  6 5 4
  10 9 8 7
   and how to find the number of rows if n is given?
  For ex if n=10 how to find num of rows=4??
  Is it Log 10 to the base of 2!!

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




 --
 Ankur Khurana
 Computer Science
 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.




 --
 *WITH BEST REGARDS :

 AASHISH SUMAN
 MCA FINAL YEAR
 *
 *NIT DURGAPUR*
 *+91-9547969906*

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Microsoft :)

2011-08-06 Thread Ankur Khurana
Congrats dude :)

On Sat, Aug 6, 2011 at 1:41 PM, siddharam suresh siddharam@gmail.comwrote:

 congrats
 Thank you,
 Siddharam



 On Sat, Aug 6, 2011 at 1:34 PM, Ragu ragu...@gmail.com wrote:

 Congrats dude...


 On 6 August 2011 13:07, KK kunalkapadi...@gmail.com wrote:

 Hey Congrats!! :)
 I got intern dere :)

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

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: MS [Written Question]

2011-08-04 Thread Ankur Khurana
I dont know , but the double function question was highly ambigous one. They
were satified by my arguements whie giving written test and asked me write
explaintation down but still they went on to deduct two marks. Kaafi strange
tha..

On Thu, Aug 4, 2011 at 1:33 PM, Nathiya Perumal contactnath...@gmail.comwrote:

 see first its performing the operation (-2+0.5) so the ans is -1.5 and then
 its rounding off.. the final ans is -1.

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Amazon Aptitude questions

2011-08-04 Thread Ankur Khurana
dev cpp par chal jaenge ,
ideone.com par try kar
cp=cpp nahi chalega . .

On Fri, Aug 5, 2011 at 12:40 AM, Kamakshii Aggarwal
kamakshi...@gmail.comwrote:

 i have a doubt regarding 3rd questions..acc to me both are valid...what is
 the correct answer?


 On Fri, Aug 5, 2011 at 12:27 AM, newOne trader.lu...@gmail.com wrote:

 2 issues:
 1. no error handling for malloc failure( can be ignored)
 2. no memset for pq.

 strcat will not work properly: as by definition it will search for the
 null char in first string, removes it then copies the second string
 including the null char of second string.

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Give an efficient search algo

2011-08-03 Thread Ankur Khurana
For question two ,
try this.

see te element at arr[0] . and supose you have to find k . if arr[0]==k ,
then yes we found the element else see the diff betweem arr[0] and k. that
will be minimum amount of steps needed to convert a[0] to k(let abs(a[0]-k)
= p). then repeat the procedure again at the new element arr[p] untill you
find the number of reach end of array..

On Thu, Aug 4, 2011 at 6:59 AM, Dave dave_and_da...@juno.com wrote:

 @Amit: If k is not known, you can find it with another binary search.

 Dave

 On Aug 3, 3:02 pm, amit karmakar amit.codenam...@gmail.com wrote:
  I think for question 1, the value of k is not provided, right?
 
  On Aug 4, 12:53 am, Ankur Garg ankurga...@gmail.com wrote:
 
 
 
   Dave's solution looks gud to me :)
 
   On Wed, Aug 3, 2011 at 3:52 PM, Ankur Garg ankurga...@gmail.com
 wrote:
Q1 can be looked as rotated sorted array...check whether the no is
 less or
greater than kth element ..if greater search using binary search with
 low =0
high k-1 and if less earch in right with low=k+1 high =n;
 
q2) Dont know :(
 
On Wed, Aug 3, 2011 at 3:44 PM, Dave dave_and_da...@juno.com
 wrote:
 
@Tushar: For problem 1, do a binary search on elements 1 to k, and
 if
no hit is found, do a binary search on elements k+1 to n.
 
For problem 2, suppose that you are searching the given array for
 the
number 2. The idea is to take big steps when you are far from the
target, and small steps when you are close. Start with i = 0. If
 a[i] !
= 2, then add abs(a[i]-2) to i and try again. This is because it
 will
take at least abs(a[i]-2) steps to get to 2.
 
 In this case, i = 0 and a[0] = 6, so add 4 to i, getting 4. a[4] =
 4,
so add 2 to i, getting 6. a[6] = 3, so add 1. a[7] = 2.
 
Dave
 
On Aug 3, 2:09 pm, TUSHAR tusharkanta.r...@gmail.com wrote:
 1.   Given an array of n-elements ? the 1st k -elements are in
 descending order and k+1 to n elements are in
   ascending order. give an  efficient algo for searching an
 element ?
 
 2.  Given an array of n-elements ? each element in the array is
 either
 same or less by 1 or larger by 1 from the
  previous element . give an  efficient algo for searching an
 element ?
 
   e.g :   6 6 6 5 4 4 3 2 3 4 3 4 
 
--
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.- Hide quoted text -
 
  - Show quoted text -

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




-- 
Ankur Khurana
Computer Science
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.



[algogeeks] Complexity of euclidean theorem to find GCD

2011-08-03 Thread Ankur Khurana
Hi ,
can you tell me that how do we arrive at the complexity of the repetitive
division theorem to find GCD. I tried to read it on net but was not able to
find a satisfactory answer. Is it log ( max(a,b)) or is it max of 5+max
number of digits(a,b)  . . Can anybody clarify this and how you arrive at
this result as well.


Regards,
Ankur Khurana

-- 
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] finding element in rotated array

2011-07-30 Thread Ankur Khurana
low =lower_bound , high=upper_bound;
int a=arr[low];
while(lowhigh)
{
mid=(low+high)/2;
if( arr[mid]a  midupper_bound  arr[mid+1] a)
break; //you found the index of distortion

if(arr[mid]a)
low=mid+1;
else high=mid-1;

}

On Sat, Jul 30, 2011 at 11:46 AM, saurabh singh saurab...@gmail.com wrote:

 Look for the spike...that is the index where the sorted property is
 disturbed.


 On Sat, Jul 30, 2011 at 11:44 AM, tech rascal techrascal...@gmail.comwrote:

 how to find distortion using binary search??


 On Sat, Jul 30, 2011 at 11:34 AM, Mohit Goel 
 mohitgoel291...@gmail.comwrote:

 yes ..u  r right ...thnks...

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




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] finding element in rotated array

2011-07-30 Thread Ankur Khurana
above is when the sorted array is in increasing order.

On Sat, Jul 30, 2011 at 11:56 AM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 low =lower_bound , high=upper_bound;
 int a=arr[low];
 while(lowhigh)
 {
 mid=(low+high)/2;
 if( arr[mid]a  midupper_bound  arr[mid+1] a)
 break; //you found the index of distortion

 if(arr[mid]a)
 low=mid+1;
 else high=mid-1;

 }

 On Sat, Jul 30, 2011 at 11:46 AM, saurabh singh saurab...@gmail.comwrote:

 Look for the spike...that is the index where the sorted property is
 disturbed.


 On Sat, Jul 30, 2011 at 11:44 AM, tech rascal techrascal...@gmail.comwrote:

 how to find distortion using binary search??


 On Sat, Jul 30, 2011 at 11:34 AM, Mohit Goel 
 mohitgoel291...@gmail.comwrote:

 yes ..u  r right ...thnks...

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




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] array constant

2011-07-30 Thread Ankur Khurana
or const int max=5;

On Sat, Jul 30, 2011 at 1:09 PM, varun pahwa varunpahwa2...@gmail.comwrote:

 make max as a macro. as for c static memory allocation take place either
 with a constant or a macro.
 i.e.
 either u declare
 #define max 5
 then write float arr[max];

 or u may write

 float arr[5];




 On Sat, Jul 30, 2011 at 1:05 PM, Arshad Alam alam3...@gmail.com wrote:

 Why it is showing an error at line number 5


 1. void main()
 2. {
 3. clrscr();
 4. int i,max=5;
 5. float arr[max];
 6. for(i=0;imax;i++)
 7.scanf(%f,arr[i]);
 8. getch();
 9.}

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




 --
 Varun Pahwa
 B.Tech (IT)
 7th Sem.
 Indian Institute of Information Technology Allahabad.
 Ph : 09793899112
 Official Email :: rit2008...@iiita.ac.in
 Another Email :: varunpahwa.ii...@gmail.com

 People who fail to plan are those who plan to fail.

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] FB intern

2011-07-30 Thread Ankur Khurana
use divide and conquer  . logm complexity . . .

On Sat, Jul 30, 2011 at 1:09 PM, saurabh singh saurab...@gmail.com wrote:

 o(log n)
 x^n=pow(x^n/2)*pow(x^n/2)*(x^mod2)

 the base case pow(x,1)=x  pow(x,0)=1

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

 Find the least time complexity algorithm(most efficient algo) to find
 x^m(x to the power of m)..Facebok intern interview question!

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




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks]

2011-07-30 Thread Ankur Khurana
use bit manipulation to use an integer as a hash table. set bits to hash the
alphabets . . .

On Sat, Jul 30, 2011 at 1:10 PM, Karthikeyan palani 
karthikeyan...@gmail.com wrote:

 Design an algorithm and write code to remove the duplicate characters in a
 string without using any additional buffer. NOTE: One or two additional
 variables are fine. An extra copy of the array is not.

 --
 karthikeyankkn

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: adobe written round que

2011-07-30 Thread Ankur Khurana
@roopam : i got the question all wrong. . .

On Sat, Jul 30, 2011 at 10:01 PM, Roopam Poddar mailroo...@gmail.comwrote:

 The objective is to divide the number by 3 and not just check for it's
 divisibility.
 Adding the digits using itoa() and then repeated subtraction will check for
 it's divisibility by 3 and not give us the quotient.
 To get that you will have to carry out repeated subtraction on the number
 anyway.
 So whats the point?

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

 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.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Tug of War

2011-07-30 Thread Ankur Khurana
@victor +1

On Sun, Jul 31, 2011 at 8:12 AM, Victor Manuel Grijalva Altamirano 
kavic1.mar...@gmail.com wrote:

 Classic problem of DP + bit´s...like knapsack


 2011/7/30 saurabh singh saurab...@gmail.com

 when i said pick elements in descending order,it meant sorting them.Sorry
 for being unclear.
 But i am open to any discussion about my logic because its pure intuition
 based algo,so it may be having lots of loop holes.


 On Sun, Jul 31, 2011 at 7:02 AM, saurabh singh saurab...@gmail.comwrote:

 @Amol according to my algo
 group 1=9 4 3
 group 2= 7 8 1

 Think again


 On Sat, Jul 30, 2011 at 6:27 PM, Gary Drocella gdroc...@gmail.comwrote:

 To Solve This Problem, I would
 1. Sort the given list S by their respective strengths.
 2. Then I would create two other lists A and B for respective
 partitions.
 3. (a) Remove First and Last from S add them both to A
(b) Remove First and Last from S add them both to B
 4. Repeat Step 3 until there is 1 or 0 people left in which if there
 is 1 person left we would print NO
 0 people we successfully partitioned the teams into equal strengths.

 This is just off the top of my head though, so not sure if it will
 completely work :)

 On Jul 30, 8:37 am, Amol Sharma amolsharm...@gmail.com wrote:
  @saurabh- your algo has very high probability of failure
 
  take the case  9,7,8,4,3,1
 
  acc to ur algo
  group 1 is  9,8,3  strength =20
  group 2 is  7,4,2  strength =13
 
  but it is possible to divide them into 2 equal grp's
  take
  G1 - 9,4,3  total =16
  G2 - 7,8,1  total =16
 
  so we have to think of some better algo
  --
 
  Amol Sharma
  Third Year Student
  Computer Science and Engineering
  MNNIT Allahabad
 
 
 
 
 
 
 
  On Sat, Jul 30, 2011 at 5:51 PM, shubham shubh2...@gmail.com wrote:
   hey sylvester,
   just clarify the problem ..
 
   Is it such that in forming the group some people can be left out
   or
   the sum of the number of people in both partitions is equal to the
 total
   number of people
 
   --
   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/-/gVAGoc_nYhAJ.
 
   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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD





 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




 --
 Victor Manuel Grijalva Altamirano
 Universidad Tecnologica de La Mixteca

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] do while problem

2011-07-29 Thread Ankur Khurana
or cin.ignore() or while(getchar()!='\n'0;  instead of only a getchar.

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

 when you enter two numbers and press Enter
 new line character is passed as character c

 Change your code as Follows:


 printf(do you want to continue(y/n):);
 getchar();
 scanf(%c,c);


 On Fri, Jul 29, 2011 at 4:31 PM, nullpointer nullpointer...@gmail.comwrote:

 #includestdio.h
 void add();
 void subtract();
 int main()
 {int choice;
 printf(enter your choice:1.add  2.subtract:);
 scanf(%d,choice);
 switch(choice)
 {case 1:
   add();
   break;
 default:
 printf(wrong choice entered);
 }
 }
 void add()
 {int a,b;
 char c;
 do
 {printf(enter two numbers:);

 scanf(%d %d,a,b);

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

 printf(do you want to continue(y/n):);
 scanf(%c,c);
 }while(c=='y'||c=='Y');
 printf(\n);
 }

 why second scanf inside do while not working???

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




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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
try this
 #includestdio.h

   void main()
{
  int n[3][3]= {
 2,4,3,
   6,8,5,
 3,5,1
 };
  int i,*ptr;
 ptr= (int *) n;
 for(i=0;i=8;i++)
  printf(\n%d,*(ptr+i));

}

On Fri, Jul 29, 2011 at 11:27 PM, rajeev bharshetty rajeevr...@gmail.comwrote:

#includestdio.h

void main()
 {
   int n[3][3]= {
  2,4,3,
6,8,5,
  3,5,1
  };
   int i,*ptr;
  ptr= n;
  for(i=0;i=8;i++)
   printf(\n%d,*(ptr+i));

 }

 In gcc 4.3.2 no error ,it is just showing a warning as

 ms50.c: In function ‘main’:
 ms50.c:11:8: warning: assignment from incompatible pointer type

 change the statement as ptr = n[0] warning vanishes

 On Fri, Jul 29, 2011 at 11:17 PM, Arshad Alam alam3...@gmail.com wrote:

 what's the problem with line number 12?

 1#includestdio.h
 2#includeconio.h
 3void main()
 4   {
 5clrscr();
 6int n[3][3]= {
 7 2,4,3,
 8 6,8,5,
 9 3,5,1
 10 };
 11  int i,*ptr;
 12 ptr=n;
 13 for(i=0;i=8;i++)
 14printf(\n%d,*(ptr+i));
 15 getch();
 }

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




-- 
Ankur Khurana
Computer Science
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.



[algogeeks] C output 3

2011-07-29 Thread Ankur Khurana
Please explain the output, that why is it in that form in hexadecimal form


#includestdio.h

int main()
{
  printf(%d %x,-11,-11);
return 0;
}


output :

-2 fffe

-- 
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] problem at line number 12

2011-07-29 Thread Ankur Khurana
no ,
n[0] is *(n+0)
so actually n is being dereferenced here .Check the basci diff

p is a pointer , but n is a pointer to a pointer.


On Fri, Jul 29, 2011 at 11:34 PM, Arshad Alam alam3...@gmail.com wrote:

 wow great... but why it is so yaar?
 ptr=n and ptr=n[0] is same na?


 On Fri, Jul 29, 2011 at 11:27 PM, rajeev bharshetty 
 rajeevr...@gmail.comwrote:

#includestdio.h

void main()
 {
   int n[3][3]= {
  2,4,3,
6,8,5,
  3,5,1
  };
   int i,*ptr;
  ptr= n;
  for(i=0;i=8;i++)
   printf(\n%d,*(ptr+i));

 }

 In gcc 4.3.2 no error ,it is just showing a warning as

 ms50.c: In function ‘main’:
 ms50.c:11:8: warning: assignment from incompatible pointer type

 change the statement as ptr = n[0] warning vanishes

 On Fri, Jul 29, 2011 at 11:17 PM, Arshad Alam alam3...@gmail.com wrote:

 what's the problem with line number 12?

 1#includestdio.h
 2#includeconio.h
 3void main()
 4   {
 5clrscr();
 6int n[3][3]= {
 7 2,4,3,
 8 6,8,5,
 9 3,5,1
 10 };
 11  int i,*ptr;
 12 ptr=n;
 13 for(i=0;i=8;i++)
 14printf(\n%d,*(ptr+i));
 15 getch();
 }

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
@rajeev: your code gives compilation error.

On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 no ,
 n[0] is *(n+0)
 so actually n is being dereferenced here .Check the basci diff

 p is a pointer , but n is a pointer to a pointer.


 On Fri, Jul 29, 2011 at 11:34 PM, Arshad Alam alam3...@gmail.com wrote:

 wow great... but why it is so yaar?
 ptr=n and ptr=n[0] is same na?


 On Fri, Jul 29, 2011 at 11:27 PM, rajeev bharshetty rajeevr...@gmail.com
  wrote:

#includestdio.h

void main()
 {
   int n[3][3]= {
  2,4,3,
6,8,5,
  3,5,1
  };
   int i,*ptr;
  ptr= n;
  for(i=0;i=8;i++)
   printf(\n%d,*(ptr+i));

 }

 In gcc 4.3.2 no error ,it is just showing a warning as

 ms50.c: In function ‘main’:
 ms50.c:11:8: warning: assignment from incompatible pointer type

 change the statement as ptr = n[0] warning vanishes

 On Fri, Jul 29, 2011 at 11:17 PM, Arshad Alam alam3...@gmail.comwrote:

 what's the problem with line number 12?

 1#includestdio.h
 2#includeconio.h
 3void main()
 4   {
 5clrscr();
 6int n[3][3]= {
 7 2,4,3,
 8 6,8,5,
 9 3,5,1
 10 };
 11  int i,*ptr;
 12 ptr=n;
 13 for(i=0;i=8;i++)
 14printf(\n%d,*(ptr+i));
 15 getch();
 }

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
http://ideone.com/OaCDR

On Fri, Jul 29, 2011 at 11:45 PM, rajeev bharshetty rajeevr...@gmail.comwrote:

 @ankur :which compiler are u using??


 On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 @rajeev: your code gives compilation error.


 On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana ankur.kkhur...@gmail.com
  wrote:

 no ,
 n[0] is *(n+0)
 so actually n is being dereferenced here .Check the basci diff

 p is a pointer , but n is a pointer to a pointer.


 On Fri, Jul 29, 2011 at 11:34 PM, Arshad Alam alam3...@gmail.comwrote:

 wow great... but why it is so yaar?
 ptr=n and ptr=n[0] is same na?


 On Fri, Jul 29, 2011 at 11:27 PM, rajeev bharshetty 
 rajeevr...@gmail.com wrote:

#includestdio.h

void main()
 {
   int n[3][3]= {
  2,4,3,
6,8,5,
  3,5,1
  };
   int i,*ptr;
  ptr= n;
  for(i=0;i=8;i++)
   printf(\n%d,*(ptr+i));

 }

 In gcc 4.3.2 no error ,it is just showing a warning as

 ms50.c: In function ‘main’:
 ms50.c:11:8: warning: assignment from incompatible pointer type

 change the statement as ptr = n[0] warning vanishes

 On Fri, Jul 29, 2011 at 11:17 PM, Arshad Alam alam3...@gmail.comwrote:

 what's the problem with line number 12?

 1#includestdio.h
 2#includeconio.h
 3void main()
 4   {
 5clrscr();
 6int n[3][3]= {
 7 2,4,3,
 8 6,8,5,
 9 3,5,1
 10 };
 11  int i,*ptr;
 12 ptr=n;
 13 for(i=0;i=8;i++)
 14printf(\n%d,*(ptr+i));
 15 getch();
 }

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




 --
 Ankur Khurana
 Computer Science
 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.




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Programming Puzzle!!!!!!!

2011-07-29 Thread Ankur Khurana
isn't it knapsack problem ?

On Fri, Jul 29, 2011 at 4:29 PM, ankit sambyal ankitsamb...@gmail.comwrote:

 @aman: My mistake.
 set* memo[0]=0*

 The revised algo is :


 Algo:
 1. int memo[S]
 2. initialize all its elements to infinite.
 *
 3.memo[0]=0*

 4.for i=1 to S
   for j=0 to N-1
  if(denom[j]  imemo[i-denom[j]] +1  memo[i])
   memo[i]=memo[i-denom[j]] +1
 5. return memo[S]

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
Thanks for pointing that out, my apologies  . .  .

On Fri, Jul 29, 2011 at 11:53 PM, rajeev bharshetty rajeevr...@gmail.comwrote:

 @ankur : Dude I think you compiled in ideone as C++ language but it is C :)
 http://ideone.com/HZhHu


 On Fri, Jul 29, 2011 at 11:51 PM, rajeev bharshetty 
 rajeevr...@gmail.comwrote:

 @ankur: But the same above code wont show any error on my gcc 4.3.2
 running on Open Suse 11.4 


 On Fri, Jul 29, 2011 at 11:48 PM, Ankur Khurana ankur.kkhur...@gmail.com
  wrote:

 http://ideone.com/OaCDR


 On Fri, Jul 29, 2011 at 11:45 PM, rajeev bharshetty 
 rajeevr...@gmail.com wrote:

 @ankur :which compiler are u using??


 On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana 
 ankur.kkhur...@gmail.com wrote:

 @rajeev: your code gives compilation error.


 On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana 
 ankur.kkhur...@gmail.com wrote:

 no ,
 n[0] is *(n+0)
 so actually n is being dereferenced here .Check the basci diff

 p is a pointer , but n is a pointer to a pointer.


 On Fri, Jul 29, 2011 at 11:34 PM, Arshad Alam alam3...@gmail.comwrote:

 wow great... but why it is so yaar?
 ptr=n and ptr=n[0] is same na?


 On Fri, Jul 29, 2011 at 11:27 PM, rajeev bharshetty 
 rajeevr...@gmail.com wrote:

#includestdio.h

void main()
 {
   int n[3][3]= {
  2,4,3,
6,8,5,
  3,5,1
  };
   int i,*ptr;
  ptr= n;
  for(i=0;i=8;i++)
   printf(\n%d,*(ptr+i));

 }

 In gcc 4.3.2 no error ,it is just showing a warning as

 ms50.c: In function ‘main’:
 ms50.c:11:8: warning: assignment from incompatible pointer type

 change the statement as ptr = n[0] warning vanishes

 On Fri, Jul 29, 2011 at 11:17 PM, Arshad Alam 
 alam3...@gmail.comwrote:

 what's the problem with line number 12?

 1#includestdio.h
 2#includeconio.h
 3void main()
 4   {
 5clrscr();
 6int n[3][3]= {
 7 2,4,3,
 8 6,8,5,
 9 3,5,1
 10 };
 11  int i,*ptr;
 12 ptr=n;
 13 for(i=0;i=8;i++)
 14printf(\n%d,*(ptr+i));
 15 getch();
 }

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




 --
 Ankur Khurana
 Computer Science
 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.




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




 --
 Ankur Khurana
 Computer Science
 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.




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*




 --
 Regards
 Rajeev N B http

Re: [algogeeks] C output 3

2011-07-29 Thread Ankur Khurana
i figured it out. I didnt know before that is was in 2's complement form .

On Fri, Jul 29, 2011 at 11:53 PM, sukhmeet singh sukhmeet2...@gmail.comwrote:

 I couldn't understand the problem .. u have used %x as indentifier that why
 it is so

 On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 Please explain the output, that why is it in that form in hexadecimal form


 #includestdio.h

 int main()
 {
   printf(%d %x,-11,-11);
 return 0;
 }


 output :

 -2 fffe


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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
AFAIK , it is adaptation of gcc standards, which is the problem with mingw
as well . So i use ideone to check my answer as it uses spoj engine which is
 considered more standard.  I guess that is the reason, i cant think of
other

On Fri, Jul 29, 2011 at 11:51 PM, rajeev bharshetty rajeevr...@gmail.comwrote:

 @ankur: But the same above code wont show any error on my gcc 4.3.2 running
 on Open Suse 11.4 


 On Fri, Jul 29, 2011 at 11:48 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 http://ideone.com/OaCDR


 On Fri, Jul 29, 2011 at 11:45 PM, rajeev bharshetty rajeevr...@gmail.com
  wrote:

 @ankur :which compiler are u using??


 On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana 
 ankur.kkhur...@gmail.com wrote:

 @rajeev: your code gives compilation error.


 On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana 
 ankur.kkhur...@gmail.com wrote:

 no ,
 n[0] is *(n+0)
 so actually n is being dereferenced here .Check the basci diff

 p is a pointer , but n is a pointer to a pointer.


 On Fri, Jul 29, 2011 at 11:34 PM, Arshad Alam alam3...@gmail.comwrote:

 wow great... but why it is so yaar?
 ptr=n and ptr=n[0] is same na?


 On Fri, Jul 29, 2011 at 11:27 PM, rajeev bharshetty 
 rajeevr...@gmail.com wrote:

#includestdio.h

void main()
 {
   int n[3][3]= {
  2,4,3,
6,8,5,
  3,5,1
  };
   int i,*ptr;
  ptr= n;
  for(i=0;i=8;i++)
   printf(\n%d,*(ptr+i));

 }

 In gcc 4.3.2 no error ,it is just showing a warning as

 ms50.c: In function ‘main’:
 ms50.c:11:8: warning: assignment from incompatible pointer type

 change the statement as ptr = n[0] warning vanishes

 On Fri, Jul 29, 2011 at 11:17 PM, Arshad Alam alam3...@gmail.comwrote:

 what's the problem with line number 12?

 1#includestdio.h
 2#includeconio.h
 3void main()
 4   {
 5clrscr();
 6int n[3][3]= {
 7 2,4,3,
 8 6,8,5,
 9 3,5,1
 10 };
 11  int i,*ptr;
 12 ptr=n;
 13 for(i=0;i=8;i++)
 14printf(\n%d,*(ptr+i));
 15 getch();
 }

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




 --
 Ankur Khurana
 Computer Science
 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.




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

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




 --
 Ankur Khurana
 Computer Science
 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.




 --
 Regards
 Rajeev N B http://www.opensourcemania.co.cc

 *Winners Don't do Different things , they do things Differently*

  --
 You received this message because you

Re: [algogeeks] adobe written round que

2011-07-29 Thread Ankur Khurana
when you use itoa , what you get is a string. get the sum of all the digits
, using c-'0' and then use repeated subtraction . . .

On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh sukhmeet2...@gmail.comwrote:

 repeated subtraction !!

 On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:

 Without using /,% and * operators. write a function to divide a number
 by 3. itoa() function is available.

 all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
 log3) or repetitive subtraction

 but none of them uses itoa() ..ne idea how its done?
 thnks !

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] adobe written round que

2011-07-29 Thread Ankur Khurana
you shouldn't be using itoa anyways. It is not a part of ANSI C. you might
like to use sprintf . you can search for reference on cplusplus.com

On Sat, Jul 30, 2011 at 1:36 AM, aditi garg aditi.garg.6...@gmail.comwrote:

 @Ankur: I dont know how to use itoa function...can u please write a small
 code...for eg in dis ques only can u tell me how to use itoa to get sum...

 On Sat, Jul 30, 2011 at 1:13 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 when you use itoa , what you get is a string. get the sum of all the
 digits , using c-'0' and then use repeated subtraction . . .


 On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh 
 sukhmeet2...@gmail.comwrote:

 repeated subtraction !!

 On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora 
 vivaciousnived...@gmail.com wrote:

 Without using /,% and * operators. write a function to divide a number
 by 3. itoa() function is available.

 all i cn thnk of is to use shift operator and addition ,  x/3=e^(logx-
 log3) or repetitive subtraction

 but none of them uses itoa() ..ne idea how its done?
 thnks !

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




 --
 Ankur Khurana
 Computer Science
 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.




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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Ankur Khurana
find the distrotion first in the array using binary search . now

you have the last element where the array was rotated. So pick your range,
it will be either left or right subarray. Binary search in that. log(n).

On Sat, Jul 30, 2011 at 11:01 AM, Mohit Goel mohitgoel291...@gmail.comwrote:

 Given   a  sorted   array   of   n   integers   that   has   been
 rotated   an   unknown   number   of
 times, give an O(log n) algorithm that finds an element in the
 array  You may assume
 that the array was originally sorted in increasing order

 EXAMPLE:

 Input: find 5 in array (15 16 19 20 25 1 3 4 5 7 10 14)

 Output: 8 (the index of 5 in the array)

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Ankur Khurana
it's rotation right , so no matter how many times you rotate , it will
sorted except for one distortion. no ?

On Sat, Jul 30, 2011 at 11:12 AM, Mohit Goel mohitgoel291...@gmail.comwrote:

 but this works ,if array is rotated multiple times ,around different
 pivots.

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Contiguous subarray with sum zero

2011-07-28 Thread Ankur Khurana
it will be answer as per my algo .

On Thu, Jul 28, 2011 at 7:39 PM, Tushar Bindal tushicom...@gmail.comwrote:

 can't we include -9 , 3 , 1, 5 , 0 as a possible sub array?

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Ankur Khurana
what do you exactly mean by
(int *[3])  ?

On Wed, Jul 27, 2011 at 6:27 PM, ramya reddy rmy.re...@gmail.com wrote:


 int *a[3];
 a= (int *[3]) malloc( 3*sizeof(*a));

 Regards
 Ramya
 --
 *Try to learn something about everything and everything about something*

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




-- 
Ankur Khurana
Computer Science
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.



[algogeeks] C output 2

2011-07-27 Thread Ankur Khurana
if i declare a string constant inside another function
like let us say
,
int how()
{

char *s=hello;
return s;
}


so when how() get executed , the memory for hello will remain reserved or it
can be allocated to others. Will it amount to memory leak ?

-- 
Ankur Khurana
Computer Science
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.



[algogeeks] C output.

2011-07-26 Thread Ankur Khurana
#includeiostream

#includestring.h
using namespace std;
#define N(e) e#e

int main()
{
int i=1,j=2,k=3;
int m = i++ || j++  k++;
couti j k m;
}

output :-2 2 3 1

http://www.ideone.com/0sKBr

can anybody explain ? why are ++j and ++k are not evaluating even though 
operator should be evaluated first in order of evaluation.

Regards,
Ankur

-- 
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] C output.

2011-07-26 Thread Ankur Khurana
but in precedence order   || . Checked the same in dennis ricthie.

On Tue, Jul 26, 2011 at 2:53 PM, rajeev bharshetty rajeevr...@gmail.comwrote:

 Replace || by  and then j and k will get evaluated.
 The thing is that i think  when the compiler sees a || operator ,if the
 first operand is true than it wont check for the second.Thus j and k are not
 getting evaluated.

 On Tue, Jul 26, 2011 at 2:46 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 #includeiostream

 #includestring.h
 using namespace std;
 #define N(e) e#e

 int main()
 {
 int i=1,j=2,k=3;
 int m = i++ || j++  k++;
 couti j k m;
 }

 output :-2 2 3 1

 http://www.ideone.com/0sKBr

 can anybody explain ? why are ++j and ++k are not evaluating even though
  operator should be evaluated first in order of evaluation.

 Regards,
 Ankur

  --
 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
 Rajeev N B http://www.opensourcemania.co.cc

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: please help

2011-07-26 Thread Ankur Khurana
i believe you are asking for rank in lexicographic rotation

On Tue, Jul 26, 2011 at 11:52 PM, coder coder
i.code.program...@gmail.comwrote:

 in the circular array ABCDEABCCDE
 The answer is 6 because the circular string starting from the element
 A in the 6th position comes first in the dictionary formed from all
 the possible strings of the circular array.

 for ABCDEAABCCDA  is 6

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] xplain output

2011-07-23 Thread Ankur Khurana
yes, try changing %f to %d somewhere, answers will come right , but can
anyone epalin the reason that if garbage values were to be printed , i am
having same garbage values on my machine as on his :P. How is that answers
and output comes out to be same

On Sat, Jul 23, 2011 at 12:56 AM, rajeev bharshetty rajeevr...@gmail.comwrote:

 I think when the mismatch of the format specifier and the variable occurs ,
 the compiler generates random  number output as, some garbage I suppose .


 On Sat, Jul 23, 2011 at 12:30 AM, geek forgeek geekhori...@gmail.comwrote:

 #includestdio.h
 void main()
 {
 int x;
 float t;
 scanf(%f,t);
 printf(%f\n,t);
 x=90;
 printf(%f\n,x);
 {
 x=1;
 printf(%f\n,x);
 {
 x=30;
 printf(%f\n,x);
 }
 printf(%f\n,x);
 }
 x==9;
 printf(%f\n,x);
 }

 input
 1.1

 output
 1.10
 1.09
 1.09
 1.09
 1.09
 1.09

 --
 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
 Rajeev N B http://www.opensourcemania.co.cc


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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Sorting in O(n)

2011-07-22 Thread Ankur Khurana
n logn merge sort.count sort only when range is known.

On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal sunny816.i...@gmail.comwrote:

 Cannot be done in O(N) if elements of list can take any value because then
 counting sort wont help

 On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.com wrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

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




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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Sorting in O(n)

2011-07-22 Thread Ankur Khurana
10^9--10^9 - 8- 7-  NULL . It wont help in this case...

On Sat, Jul 23, 2011 at 9:55 AM, keyan karthi keyankarthi1...@gmail.comwrote:

 counting sort ll help to some extent... find the min and max element O(n)
 now u just need an array of size  max-min to store the values then
 just traverse the list and while updating u do value+min... still it is not
 suitable if the magnitude is high.


 On Sat, Jul 23, 2011 at 9:45 AM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 n logn merge sort.count sort only when range is known.


 On Sat, Jul 23, 2011 at 1:35 AM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 Cannot be done in O(N) if elements of list can take any value because
 then counting sort wont help

 On Sat, Jul 23, 2011 at 1:24 AM, Pankaj jatka.oppimi...@gmail.comwrote:

 For linklist? How


 On Sat, Jul 23, 2011 at 1:23 AM, Kamakshii Aggarwal 
 kamakshi...@gmail.com wrote:

 use counting sort..


 On Sat, Jul 23, 2011 at 1:22 AM, rShetty rajeevr...@gmail.com wrote:

 How to sort Linked lists in O(n) time ??
 Give the algorithm or the explanation or clue to tackle the problem

 --
 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,
 Kamakshi
 kamakshi...@gmail.com

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




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




 --
 Ankur Khurana
 Computer Science
 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.


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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Unique characters in a string

2011-07-22 Thread Ankur Khurana
what if cahrs are in ascii code range and not just characters. Any solution
for that ?

On Sat, Jul 23, 2011 at 9:57 AM, keyan karthi keyankarthi1...@gmail.comwrote:

 u can use an integer as a bit mask to do this... by setting the
  alphabet-'a' th bit, and checking the same..


 On Sat, Jul 23, 2011 at 9:52 AM, Reynald reynaldsus...@gmail.com wrote:

 Implement an algorithm to determine if a string has all unique
 characters. What if you can not use additional data structures?

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Adobe Ques

2011-07-21 Thread Ankur Khurana
I gave an O(N)  solution in a different thread by same author for this
question...

On Thu, Jul 21, 2011 at 6:08 PM, Abhi abhi123khat...@gmail.com wrote:

 My solution for this :

 #includestdio.h
 int max(int a,int b)
 {
 return ab?a:b;
 }

 int main()
 {
 char str[] = abcdab;
 int count=0,max1=0;
 int i=0,j,k;
 int hash[26];
 for(i=0;i26;i++)
 hash[i]=-1;
 for(i=0;istrlen(str);i++)
 {
 count=0;
 for(j=i;hash[str[j]-'a']==-1;j++)
 {

 hash[str[j]-'a'] = 1;
 count++;
 }

 max1=max(count,max1);
 for(k=0;k26;k++)
 hash[k]=-1;


 }
 printf(%d ,max1);
 getch();
 return 0;
 }

 Worst case running time : O(n^2)  when string is of the form abcdeabcde.

 Does there exist an O(n) solution for this?

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

 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.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Adobe Ques

2011-07-21 Thread Ankur Khurana
Sorry , solution nahi dekha tha tera maine.

On Thu, Jul 21, 2011 at 9:29 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 I gave an O(N)  solution in a different thread by same author for this
 question...


 On Thu, Jul 21, 2011 at 6:08 PM, Abhi abhi123khat...@gmail.com wrote:

 My solution for this :

 #includestdio.h
 int max(int a,int b)
 {
 return ab?a:b;
 }

 int main()
 {
 char str[] = abcdab;
 int count=0,max1=0;
 int i=0,j,k;
 int hash[26];
 for(i=0;i26;i++)
 hash[i]=-1;
 for(i=0;istrlen(str);i++)
 {
 count=0;
 for(j=i;hash[str[j]-'a']==-1;j++)
 {

 hash[str[j]-'a'] = 1;
 count++;
 }

 max1=max(count,max1);
 for(k=0;k26;k++)
 hash[k]=-1;


 }
 printf(%d ,max1);
 getch();
 return 0;
 }

 Worst case running time : O(n^2)  when string is of the form abcdeabcde.

 Does there exist an O(n) solution for this?

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

 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Re: Adobe Ques

2011-07-21 Thread Ankur Khurana
but mine was different , check kar liyo

On Thu, Jul 21, 2011 at 10:06 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 Sorry , solution nahi dekha tha tera maine.


 On Thu, Jul 21, 2011 at 9:29 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 I gave an O(N)  solution in a different thread by same author for this
 question...


 On Thu, Jul 21, 2011 at 6:08 PM, Abhi abhi123khat...@gmail.com wrote:

 My solution for this :

 #includestdio.h
 int max(int a,int b)
 {
 return ab?a:b;
 }

 int main()
 {
 char str[] = abcdab;
 int count=0,max1=0;
 int i=0,j,k;
 int hash[26];
 for(i=0;i26;i++)
 hash[i]=-1;
 for(i=0;istrlen(str);i++)
 {
 count=0;
 for(j=i;hash[str[j]-'a']==-1;j++)
 {

 hash[str[j]-'a'] = 1;
 count++;
 }

 max1=max(count,max1);
 for(k=0;k26;k++)
 hash[k]=-1;


 }
 printf(%d ,max1);
 getch();
 return 0;
 }

 Worst case running time : O(n^2)  when string is of the form
 abcdeabcde.

 Does there exist an O(n) solution for this?

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

 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.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




 --
 Ankur Khurana
 Computer Science
 Netaji Subhas Institute Of Technology
 Delhi.




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Contiguous subarray with sum zero

2011-07-20 Thread Ankur Khurana
create another array with sum of the elements from 0 to i.

20 , -9 , 3 , 1, 5 , 0, -6 , 9
20 , 11,14,15,20,0,14,23
above thing can be done in O(n) .


now start hashing them (sum as keys and index as value), and if the sum
exist previously , then that means from that point , from where you are
hashing to the point of the value of previously hashed key , the Sum is 0.
store all the index at that sum .

use something like this
map(int , vector int ;
. I guess you are getting my point , if not , please free feel to ping.
Oveall comlexity is nlog(n) . n -no of elements and log n is searching time
in hash maps





On Wed, Jul 20, 2011 at 6:47 PM, Pankaj jatka.oppimi...@gmail.com wrote:

 Given an array with + and - numbers, including zero, Write an algorithm to
 find all the possible sub arrays which sum up to zero.

 For example, if given array is

 20 , -9 , 3 , 1, 5 , 0, -6 , 9

 Then possible sub arrays are:
 -9, 3, 1, 5
 0
 1, 5, 0, -6

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




-- 
Ankur Khurana
Computer Science , 4th year
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.



Re: [algogeeks] Whats the complexity?

2011-07-20 Thread Ankur Khurana
when n is not defined , you want complexity in terms of ?

On Wed, Jul 20, 2011 at 3:16 PM, Dumanshu duman...@gmail.com wrote:

 Given an infinite length list. u got to find index of an element k.
 use this approach-
 initially, take length as 2^x where x increases from 1 to ...
 while (still not found)
 {
 now if arr[2^x-1]  k,
  increment x
 else
 binarysearch on length 2^(x-1) to 2^(x)
 }

 Please help me to find the complexity of this particular approach...

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




-- 
Ankur Khurana
Computer Science
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.



Re: [algogeeks] Reverse a List with Recursion

2011-07-17 Thread Ankur Khurana
int reverse(node * tmp)
{
static int i;
   // couti ;
i++;
if(tmp==NULL)
{
return 0;
}
if((tmp-next)==NULL)
{
head=tmp;
i--;
return 0;
}
if((tmp-next)!=NULL)
{
reverse(tmp-next);
(tmp-next)-next=tmp;
i--;
if(i==0)
{
tmp-next=NULL;
tail=tmp;}

return 0;
}

return 0;
}

On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote:

 Hi,

 I was trying to accomplish this task with the following call , header
 = ReverseList(header)

 I don't want to pass tail pointer or anything and just want that i get
 a reversed list with new header properly assigned after this call. I
 am getting issues in corner conditions like returning the correct node
 to be assigned to header.

 Can anyone give an elegant solution with above requirement? Since it
 is with recursion, please test for multiple scenarios (empty list, one
 node list, twe nodes list etc) before posting your solution. In case
 of empty list, the procedure should report that.

 --
 Regards,
 Navneet

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




-- 
Ankur Khurana
Computer Science , 4th year
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.



[algogeeks] Free memory

2011-07-17 Thread Ankur Khurana
Can we do this ?

int i=12;
free(i);






Regards,
Ankur Khurana
Computer Science , 4th year
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.



[algogeeks] Re: Free memory

2011-07-17 Thread Ankur Khurana
more generally what is the memory structure of local , global and runtime
allocated variable . I guess , runtime allocation is done from memory heap ,
local goes in to a stack . What about global ?

On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote:

 Can we do this ?

 int i=12;
 free(i);






 Regards,
 Ankur Khurana
 Computer Science , 4th year
 Netaji Subhas Institute Of Technology
 Delhi.




-- 
Ankur Khurana
Computer Science , 4th year
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.



Re: [algogeeks] Re: Free memory

2011-07-17 Thread Ankur Khurana
local stack is different and global is different ? and runtime memory is
going to memory heap that i know.

Saurabh : above snippet does not give runtime error.


On Sun, Jul 17, 2011 at 3:04 PM, saurabh singh saurab...@gmail.com wrote:

 Global too goes to stack,the data stack.Static variables also go to the
 stack.That's how they retain their values during function calls.

 On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 more generally what is the memory structure of local , global and runtime
 allocated variable . I guess , runtime allocation is done from memory heap ,
 local goes in to a stack . What about global ?


 On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 Can we do this ?

 int i=12;
 free(i);






 Regards,
 Ankur Khurana
 Computer Science , 4th year
 Netaji Subhas Institute Of Technology
 Delhi.




 --
 Ankur Khurana
 Computer Science , 4th year
 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




-- 
Ankur Khurana
Computer Science , 4th year
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.



Re: [algogeeks] Re: Free memory

2011-07-17 Thread Ankur Khurana
holy sh*t . I need to switch from MinGw was using codeblocks. Thanks
:)

On Sun, Jul 17, 2011 at 4:02 PM, saurabh singh saurab...@gmail.com wrote:


 http://www.ideone.com/LmFES

 On Sun, Jul 17, 2011 at 3:59 PM, saurabh singh saurab...@gmail.comwrote:

 Machine/OS?
 I am pretty sure it will give.


 On Sun, Jul 17, 2011 at 3:09 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 local stack is different and global is different ? and runtime memory is
 going to memory heap that i know.

 Saurabh : above snippet does not give runtime error.


 On Sun, Jul 17, 2011 at 3:04 PM, saurabh singh saurab...@gmail.comwrote:

 Global too goes to stack,the data stack.Static variables also go to the
 stack.That's how they retain their values during function calls.

 On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana 
 ankur.kkhur...@gmail.com wrote:

 more generally what is the memory structure of local , global and
 runtime allocated variable . I guess , runtime allocation is done from
 memory heap , local goes in to a stack . What about global ?


 On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana 
 ankur.kkhur...@gmail.com wrote:

 Can we do this ?

 int i=12;
 free(i);






 Regards,
 Ankur Khurana
 Computer Science , 4th year
 Netaji Subhas Institute Of Technology
 Delhi.




 --
 Ankur Khurana
 Computer Science , 4th year
 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




 --
 Ankur Khurana
 Computer Science , 4th year
 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT ALLAHABAD





 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




-- 
Ankur Khurana
Computer Science , 4th year
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.



Re: [algogeeks] what would be the output of following code??

2011-07-16 Thread Ankur Khurana
answer for first should be
2 22 23

and for second
2 222
2
correct me if i am wrong.
On Sat, Jul 16, 2011 at 3:08 PM, Deoki Nandan deok...@gmail.com wrote:

 what about this 
 printf(\n%d,printf(%d %d,2,2)printf(%d%d ,2,2));


 On Sat, Jul 16, 2011 at 3:04 PM, swetha rahul swetharahu...@gmail.comwrote:

 2


 On Sat, Jul 16, 2011 at 2:51 PM, shiv narayan 
 narayan.shiv...@gmail.comwrote:

 Printf(“%d”,printf(“%d %d”,2,2)  printf(“%d %d ”, 2, 2));

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




 --
 **With Regards
 Deoki Nandan Vishwakarma

 *
 *

  --
 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] Re: Printf ...

2011-07-16 Thread Ankur Khurana
I am using  MinGW compiler (codeblocks , out put is 788 and not 678 . Its
compiler dependent so , let us leave it that way only.

On Sat, Jul 16, 2011 at 3:27 PM, shiv narayan narayan.shiv...@gmail.comwrote:

 according to me it processing is done from righ to left .first right
 most a would be incremented and then from righ to left
 for first question answer should be 8+7+6=21
 and for 2nd it should be

 (8)+(7)*10+(6)*100=678

 On Jul 15, 1:15 pm, Antony Kotre antonyko...@gmail.com wrote:
  can any tell and explain the output of following code
 
  #includestdio.h
  main()
  {   int a =5, b=5;
  int res1=(++a)+(++a)+(++a);
  int res2=(++b)+(++b)*10+(++b)*100;
 
  printf(%d\n%d\n,res1,res2);
 
 
 
 
 
 
 
  }

 --
 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] Merge unsorted arrays

2011-07-16 Thread Ankur Khurana
Use divide and conquer. take 2 array at a time and .so you are merging two
array at a time.

num_of_list=m;
length of list=n;

while(num_of_list  1)
{
while( (num of list where length = length_of_list) 2)
{
merge two lists of length (length_of_list);

}
if(num_of_list %2==0)
num_of_list/=2;
else
num_of_list/=2+1;
length of list=n;

}
(it is just a general idea , you have to take care of the left over list
every time , the check for that i havent posted)

so time complexity is


2*n* (m/2) + 2* 2n* (m/4) .. log(m) times.

so complexity is n*m*log(m)





On Sat, Jul 16, 2011 at 2:43 PM, aseem garg ase.as...@gmail.com wrote:

 Q2. Given m arrays of n size each, give an algorithm to combine these
 arrays into a single array with sorted elements. Also tell the time
 complexity of your solution.
 Aseem

  --
 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] Merge unsorted arrays

2011-07-16 Thread Ankur Khurana
oops , didnt see the unsorted thing. complexity is mnlog(n) + mn log(m)

On Sat, Jul 16, 2011 at 4:23 PM, sagar pareek sagarpar...@gmail.com wrote:

 sort all the arrays first O(nlogn)

 then use merge sort


 On Sat, Jul 16, 2011 at 3:43 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:

 Use divide and conquer. take 2 array at a time and .so you are merging two
 array at a time.

 num_of_list=m;
 length of list=n;

 while(num_of_list  1)
 {
 while( (num of list where length = length_of_list) 2)
 {
 merge two lists of length (length_of_list);

 }
 if(num_of_list %2==0)
 num_of_list/=2;
 else
 num_of_list/=2+1;
 length of list=n;

 }
 (it is just a general idea , you have to take care of the left over list
 every time , the check for that i havent posted)

 so time complexity is


 2*n* (m/2) + 2* 2n* (m/4) .. log(m) times.

 so complexity is n*m*log(m)





 On Sat, Jul 16, 2011 at 2:43 PM, aseem garg ase.as...@gmail.com wrote:

 Q2. Given m arrays of n size each, give an algorithm to combine these
 arrays into a single array with sorted elements. Also tell the time
 complexity of your solution.
 Aseem

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




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


-- 
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: Merge unsorted arrays

2011-07-16 Thread Ankur Khurana
you sort array before merging. and then use merge sort

On Sat, Jul 16, 2011 at 6:53 PM, noobcoder ase.as...@gmail.com wrote:

 how does ur algo produce sorted elements in final array?

 On Jul 16, 3:55 pm, Ankur Khurana ankur.kkhur...@gmail.com wrote:
  oops , didnt see the unsorted thing. complexity is mnlog(n) + mn log(m)
 
 
 
 
 
 
 
  On Sat, Jul 16, 2011 at 4:23 PM, sagar pareek sagarpar...@gmail.com
 wrote:
   sort all the arrays first O(nlogn)
 
   then use merge sort
 
   On Sat, Jul 16, 2011 at 3:43 PM, Ankur Khurana 
 ankur.kkhur...@gmail.comwrote:
 
   Use divide and conquer. take 2 array at a time and .so you are merging
 two
   array at a time.
 
   num_of_list=m;
   length of list=n;
 
   while(num_of_list  1)
   {
   while( (num of list where length = length_of_list) 2)
   {
   merge two lists of length (length_of_list);
 
   }
   if(num_of_list %2==0)
   num_of_list/=2;
   else
   num_of_list/=2+1;
   length of list=n;
 
   }
   (it is just a general idea , you have to take care of the left over
 list
   every time , the check for that i havent posted)
 
   so time complexity is
 
   2*n* (m/2) + 2* 2n* (m/4) .. log(m) times.
 
   so complexity is n*m*log(m)
 
   On Sat, Jul 16, 2011 at 2:43 PM, aseem garg ase.as...@gmail.com
 wrote:
 
   Q2. Given m arrays of n size each, give an algorithm to combine these
   arrays into a single array with sorted elements. Also tell the time
   complexity of your solution.
   Aseem
 
--
   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.
 
   --
   **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.

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




-- 
Ankur Khurana
Computer Science , 4th year
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.



[algogeeks] Basic String Queries

2011-07-11 Thread Ankur Khurana
if we are using strncpy( destination ,  source , num_of_char)

then if destination have less space allocated than num_of_char , what will
happen ?

Also , if there is no null char after string, what will happen , puts(str)
//where str is the string wihtout NULL character . I was not able to find
any reference regarding these doubts . Any suggestion or readable material ?

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

2011-03-20 Thread Ankur Khurana
problem ka link bhi diya karo ya code..

On Sun, Mar 20, 2011 at 3:34 AM, sunny sunny.verma...@gmail.com wrote:

 hello frnds...
 i am getting TLE in 12th test case ..
 can anyone over ther help me to shorten it..
 #includestdio.h
 #includeiostream
 using namespace std;
 int gcd(int a, int b)
 {  if(b==0)
return(a);
   else
   return gcd(b,a%b);

 }
 int main()
 {
int rec,g,count=0;
scanf(%d,rec);
for(int i=1;i=rec;i++){
for( int j=i;j=1;j--){
if((i+j)rec){
  g=gcd(i,j);
  if((i+j-g)==rec){
 count++;

  }
}
else
 break;
}
}
printf(%d,count);
return 0;
 }

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

2011-03-15 Thread Ankur Khurana
@utraksh : 10^9 is well in int limits

On Tue, Mar 15, 2011 at 12:56 PM, Satyam Kapoor satyamkapoo...@gmail.comwrote:

 @utkarsh:teri kismat acchi thi aur kuch nhimaze kar!

 ---
 Satyam Kapoor
 B.Tech-2nd Year
 MNNIT-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.


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

2011-03-15 Thread Ankur Khurana
@carl : may be this : https://www.spoj.pl/problems/SBSTR1/

On Tue, Mar 15, 2011 at 9:35 PM, kumar anurag anurag.it.jo...@gmail.comwrote:

 I used a prgram of c which converts brainfuck program to C progaram which u
 can compile using gcc


 On Tue, Mar 15, 2011 at 9:12 PM, Carl Barton 
 odysseus.ulys...@gmail.comwrote:

 Just out of interest. What are you planning to write in brainfuck?


 On 15 March 2011 14:58, Natansh Verma natansh.ve...@gmail.com wrote:

 I don't know about Windows 7, but there is an interpreter online, in case
 you want one.

 http://brainfuck.tk/


 On Tue, Mar 15, 2011 at 5:15 PM, cegprakash cegprak...@gmail.comwrote:

 do anyone knows a brainfuck compiler for windows 7? I need a link to
 download it.

 I'm new to this group.
 Hope you guyz will 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.


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




 --
 Kumar Anurag

 --
 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] SPoj maximum sum subseuence

2011-03-12 Thread Ankur Khurana
https://www.spoj.pl/problems/MAXSUMSQ/

 Hi in above problem , i am getting TLE but according to given contraints ,
i think my code is good enough to run. Can any body help me here



#include vector
#include map
#include algorithm
#include cstring
#include iostream
#include cstdio
#include cmath
#include cstdlib
#include climits
#define VI vector int
typedef long long int LL;
using namespace std;
VI v;
LL x,nos;

//finding maximum sum subsequence
LL findx()
{
int sz=v.size();
LL maxsum=INT_MIN;
int maxstart=0,maxend=0;
LL currentsum=0;
int currentstart=0,currentend=0;
for(currentend=0;currentendsz;currentend++)
{
currentsum=currentsum+v[currentend];

if(currentsummaxsum)
{
maxsum=currentsum;
maxstart=currentstart;
maxend=currentend;
}
if(currentsum0)
{
currentstart=currentend+1;
currentsum=0;
}
}

return maxsum;
}


// main Program
int main()
{
  //  freopen(input.txt,r,stdin);
int test;
int num;
map LL , LL m;
cintest;
LL sum=0;
int n;

int i;


while(test--)
{
sum=0;
nos=0;
m.clear();
m[0]=1;
scanf(%d,n);
v.resize(n);
for(i=0;in;i++)
{
   scanf(%d,v[i]);
}
x=findx();
nos=0;
for(i=0;in;i++)
{
sum=sum+v[i];
nos=nos+m[sum-x];
m[sum]++;
}
  coutx nosendl;
}

return 0;
}

-- 
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] manually initialise indexing of an array

2011-03-10 Thread Ankur Khurana
may be this will do
int arr[21];
int *a;
a=arr+10;
now a can vary from a[-10] to a[10]
I have doubts but will this work ?


On Thu, Mar 10, 2011 at 3:31 PM, amit amitthecoo...@gmail.com wrote:

 Indexing of an array starts with '0' by default. can we manually start
 with 1 or any other number say a negative one?

 --
 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] printing without loop

2011-03-01 Thread Ankur Khurana
simply use GOTO

On Tue, Mar 1, 2011 at 3:40 PM, vaibhav shukla vaibhav200...@gmail.comwrote:

 write printf statemen 100 times. lolzzz

 On Tue, Mar 1, 2011 at 2:01 PM, Subhransu 
 subhransu.panigr...@gmail.comwrote:

 Hey Guys,
  @preetikatyagi : The question is pretty straight Write a program
 printing number 1 to 100 without using any loop, GOTO statement , do while
   recursion 

 @sunny : We have to come up with one one logic not each time we have to
 change how we can add number's to make 100.
 It has to be with caller to decide how many number he has to print  the
 definition will take care of algorithm.


 *Subhransu Panigrahi
 *
 *Mobile:* *+91-9840931538*
  *Email:* subhransu.panigr...@gmail.com



 On Tue, Mar 1, 2011 at 1:27 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 int i=1;
 #define PRINT1 couti++endl;
 #define PRINT2 PRINT1 PRINT1
 #define PRINT4 PRINT2 PRINT2
 #define PRINT8 PRINT4 PRINT4
 #define PRINT16 PRINT8 PRINT8
 #define PRINT32 PRINT16 PRINT16
 #define PRINT64 PRINT32 PRINT32

 int main()
 {
  //as 100 = (1100100); we need to use PRINT64, PRINT32, and PRINT4
  PRINT64;
  PRINT32;
  PRINT4;
 }


 This will print 1 to 100. You can use this code to print from 1 to x
 (x=128). You can extend it to larger numbers, by adding PRINT128,
 PRINT256...etc.

 On 3/1/11, preetika tyagi preetikaty...@gmail.com wrote:
  May be we can use *goto *statement?
 
  On Mon, Feb 28, 2011 at 10:36 PM, gaurav gupta
  1989.gau...@googlemail.comwrote:
 
  Questions is : You have to print 1 to n without using any loop( for,
  while,
  do-while, goto ) and recursion.
 
  Any suggestion?
 
 
  On Tue, Mar 1, 2011 at 10:52 AM, preetika tyagi
  preetikaty...@gmail.comwrote:
 
  Can you elaborate on it and provide more details?
 
 
  On Mon, Feb 28, 2011 at 10:14 PM, Subhransupanigrahi 
  subhransu.panigr...@gmail.com wrote:
 
  Is there any way to print 1 to 10 (taking an example, it can also
 extend
  to 100) without using loop, recursion.
 
 
  Sent from my iPhone
 
  --
  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,
  Gaurav Gupta
  7676-999-350
 
  Quality is never an accident. It is always result of intelligent
 effort
  -
  John Ruskin
 
 
 
  --
  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.
 
 


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


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




 --
   best wishes!!
 Vaibhav Shukla
 DU-MCA

  --
 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] making a graphical c++ programme

2011-02-26 Thread Ankur Khurana
What is your primary purpose . If you want to make a game , OpenGL and
AllegroGL is way to go .Other wiase to make appliations , you can use visual
c++. Can you  be more specific ?
Regards,
Ankur

On Sat, Feb 26, 2011 at 1:22 PM, Logic King crazy.logic.k...@gmail.comwrote:

 I also want to know how to start making graphical program in c++..also
 can we integrate database with a c++ application.

 actually i want to make a c++ application using both c++ and
 databasehow should i start please guide me !!!


 On Sat, Feb 26, 2011 at 1:20 AM, UTKARSH SRIVASTAV 
 usrivastav...@gmail.com wrote:

 can anybody give me code of making a simple c++ graphical program.
 please also write statement of compiling and running the program in
 linux.
 and if you wish please explain the statements of program with
 comments...

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



Re: [algogeeks] CODECHEF FLIP COIN problem

2011-02-08 Thread Ankur Khurana
try lazy propogation

On Tue, Feb 8, 2011 at 8:14 PM, Gaurav Saxena grvsaxena...@gmail.comwrote:

 Hey thanks for your help
 I have written a code using range trees but I am still getting TLE [?][?][?]
 Please suggest me something


 Here is my code

 /*
  * File:   main1.c
  * Author: gs
  *
  * Created on 8 February, 2011, 7:46 PM
  */

 #include stdio.h
 #include stdlib.h


 #define MAX 30
 #define loop0(i,j) for(int i=0;ij;i++)
 #define loop1(i,j) for(int i=1;ij;i++)
 # define true 1
 # define false 0


 _Bool flag[MAX];
 int value[MAX];

 /*void initialize(int node, int b, int e)
 {
 if (b == e)
 {
 flag[node] = false;
 value[node] = 0;
 }
 else
 {
 initialize(2 * node, b, (b + e) / 2);
 initialize(2 * node + 1, (b + e) / 2 + 1, e);
 value[node] = 0;
 flag[node] = false;
 }
 }*/

 int update(int node, int b, int e, int i, int j)
 {
 int p1, p2;
 if (i  e || j  b)
 return 0;
 if(b==e)
 {
 if(flag[node] == true)
 return 1;
 else
 return 0;
 }
 if (b = i  e = j)
 {
 if(flag[node] == true)
 {
 flag[node] = false;
 flag[2*node] = !flag[2*node];
 flag[2*node+1] = !flag[2*node+1];
 p1 = update(2 * node, b, (b + e) / 2, i, j);
 p2 = update(2 * node + 1, (b + e) / 2 + 1, e, i, j);
 return (value[node] = p1 + p2);
 }
 else
 return value[node];
 }
 else
 {
 if(flag[node]==true)
 {
 flag[node]=false;
 flag[2*node]=!flag[2*node];
 flag[2*node+1]=!flag[2*node+1];
 }
 p1 = update(2 * node, b, (b + e) / 2, i, j);
 p2 = update(2 * node + 1, (b + e) / 2 + 1, e, i, j);
 return value[node] = p1 + p2;
 }
 }

 int query(int node, int b, int e, int i, int j)
 {
 int p1, p2;
 if (i  e || j  b)
 return 0;
 if (b = i  e = j)
 {
 flag[node] = !flag[node];
 return value[node] = e - b + 1 - value[node];
 }
 else
 {
 if(flag[node]==true)
 {
 flag[node]=false;
 flag[2*node]=!flag[2*node];
 flag[2*node+1]=!flag[2*node+1];
 }
 p1 = query(2 * node, b, (b + e) / 2, i, j);
 p2 = query(2 * node + 1, (b + e) / 2 + 1, e, i, j);
 if(p1==-1)
 p1=0;
 if(p2==-1)
 p2=0;
 return (value[node] = p1 + p2);
 }
 }

 int main()
 {
int i, n, q,ret;
int cmd, a, b, z;
scanf(%d %d,n,q);
//initialize(1, 0, tests-1);
for(i=0;i q;i++)
{
scanf(%d %d %d,cmd,a,b);
if(cmd==0)
value[1] = query(1,0,n-1,a,b);
else
printf(%d\n,update(1,0,n-1,a,b));
}
return 0;

 }




 On Tue, Feb 8, 2011 at 3:41 PM, sunny agrawal sunny816.i...@gmail.comwrote:

 make a tree where each node have the following structure

 1. rangeLow
 2. rangeHigh
 3. headCount of its complete subTree
 4. boolean variable change, if true means all nodes of that subtree need
 to be flipped but we are not flipping in the hope if again a flip occur we
 can reset the flag and we can save some time
 5.isHead

 initialise range tree as for root range 0-MAX
 leftSubTree 0-MAX/2 rightSubTree MAX/2+1 - MAX
 all headCount initially 0
 all changes to false

 as a query comes, if it matches with range of some node we can stop
 propagating at that level and making change true so no need to go till leaf
 nodes
 new head count at that node will be (total nodes in its range - prev
 headCount)


 if you are still not able to get it you should read a range tree tutorial,
 that will really help

 On Tue, Feb 8, 2011 at 2:28 PM, Gaurav Saxena grvsaxena...@gmail.comwrote:

 Actually I could not figure out any good way of doing this . [?][?]
 Could you please suggest me something or give some idea .
 Thanks for helping

 On Tue, Feb 8, 2011 at 1:51 PM, sunny agrawal 
 sunny816.i...@gmail.comwrote:

 i think time complexity of the O(nlgn) for an avg case will suffice

 no it will not be inefficient if we keep sufficient information at each
 node
 each node will keep information of all its childs(headCount) and using
 some optimizations such as if two flips on same range occur simultaneously,
 then after all there will be no effect at all so there was no need of doing
 anything.

 On Tue, Feb 8, 2011 at 1:27 PM, Gaurav Saxena 
 grvsaxena...@gmail.comwrote:

 If we make segments of the range of coins which are heads then in some
 case the result will become alternate which could be more inefficient. Any
 idea what time complexity will suffice ?
 Could you please elaborate your reply .


 On Tue, Feb 8, 2011 at 1:08 PM, sunny agrawal sunny816.i...@gmail.com
  wrote:

 i think your solution will be O(n) for each query
 so it will be O(Q*N), that will surely 

Re: [algogeeks] SUMMER INTERNSHIP

2011-01-09 Thread Ankur Khurana
somebody might enlighten for 3rd year as well (INDIA)

On Sun, Jan 9, 2011 at 6:53 PM, abhishesh srivastava 
abhishesh.srivast...@gmail.com wrote:

 Can anyone please tell me about the summer internship programs of various
 institute.
 I want to know how to register and about various summer internship program
 for CSE 2nd year student

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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] double and int

2011-01-06 Thread Ankur Khurana
in a C++ program ,
when we have something like this

double p=37.0;
int k;
k=(int)p;
 why is k!=p ?

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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: double and int

2011-01-06 Thread Ankur Khurana
not always. well , i got some problem using that approachwhen the output is
coming out of some library function , this doesn't qualify always i wlll
find an example by tomorrow.

On Thu, Jan 6, 2011 at 11:48 PM, juver++ avpostni...@gmail.com wrote:

 On my computer k == p.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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] Adobe Question

2011-01-04 Thread Ankur Khurana
will an o(n^2) do ? , i have one in mind but will that suffice ?

anyways , here it goes
make array
a[array_length][2];
a[k][0] and a[k][1] will contain the no. of 0's and 1 till kth position.
just iterate twice to see where
a[i][0]-a[j][0]==a[i][1]-a[j][1]
can be maximized . meanwhile i am thinking of other solution . . . .


On Tue, Jan 4, 2011 at 2:08 PM, bittu shashank7andr...@gmail.com wrote:

 You have a array of 0's and 1's. e.g.
 0001011101001010100101010101100111
 Find the maximum contiguous subsequence of the above sequence so the
 number of 0's and 1's in that subsequence are equal


 Regards
 Shashank Mani

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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] Puzzle Will Stuck

2011-01-04 Thread Ankur Khurana
it's exactly the same question as Buttons on codechef. search this forum ,
it have been discussed before

On Tue, Jan 4, 2011 at 4:13 PM, bittu shashank7andr...@gmail.com wrote:

 There is a lock which is an N by N grid of switches. Each switch can
 be in one of two states (on/off). The lock is unlocked if all the
 switches are on. The lock is built in such a way that, if you toggle
 some switch, all the switches in its row and its column toggle too

 Give an algorithm which, given N and a configuration of the N^2
 switches, will tell you whether the lock can be unlocked by a sequence
 of switch toggles

 Note 1: Can be done in O(N^2) time and O(1) space.
 Note 2: You just need to tell if a sequence which unlocks the lock
 exists (and not the actual sequence)

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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] Divide an array into two equal subsets

2010-12-29 Thread Ankur Khurana
Thanks everybody for wonderful support and special thanks to Vishal
raja. . But i was bit apprehensive about your last solution . . i will
test it :) and let you know as well . Thanks . . . .


On Thu, Dec 30, 2010 at 11:52 AM, vishal raja vishal.ge...@gmail.com wrote:
 But the same solution I've given above can give you the solution for this
 problem .
 In the formed table of P[i][j] , you can take another variable attached to
 it as count[i][j] for how many items we have selected yet.
 So you gotta find , the max. value of j which has count = 50.
 count[i][j] = count[i-1][j]   if P(i-1,j) ==1
 count[i][j] = count[i-1][j-a[i]]  if P(i-1,j-a[i]) ==1
 else count[i][j] = 0




 On Thu, Dec 30, 2010 at 11:42 AM, vishal raja vishal.ge...@gmail.com
 wrote:

 yeah, My bad.
 Missed that.

 On Wed, Dec 29, 2010 at 10:52 PM, Wladimir Tavares wladimir...@gmail.com
 wrote:

 Sum up all the number and divide by 2

 Using the algorithm subset problem to find a number close to median


 Wladimir Araujo Tavares
 Federal University of Ceará






 On Wed, Dec 29, 2010 at 2:07 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 How will you divide and array of approx 100 elements into two sub sets
 of 50 each such that the difference between both the subsets is the
 minimum possible one . .

  Thanks in advance .
 Ankur

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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] Amazon Question

2010-12-26 Thread Ankur Khurana
are we given range of numbers ?

On Sun, Dec 26, 2010 at 4:39 PM, bittu shashank7andr...@gmail.com wrote:
 You are provided with a stream of numbers, design a data structure to
 store the numbers in the stream along with their no. of occurrences.



 Regards
 Shashank Mani

 --
 You received this message because you are subscribed to the Google Groups 
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] Amazon Question

2010-12-26 Thread Ankur Khurana
i think if it given , can we consider a hash table ?

On Sun, Dec 26, 2010 at 4:39 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote:
 are we given range of numbers ?

 On Sun, Dec 26, 2010 at 4:39 PM, bittu shashank7andr...@gmail.com wrote:
 You are provided with a stream of numbers, design a data structure to
 store the numbers in the stream along with their no. of occurrences.



 Regards
 Shashank Mani

 --
 You received this message because you are subscribed to the Google Groups 
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] Amazon Question

2010-12-26 Thread Ankur Khurana
may be we can assume that klog(n)
else i dont see a way out than hashing , because that is the only
thing less that log(n).

On Sun, Dec 26, 2010 at 6:37 PM, mohit ranjan shoonya.mo...@gmail.com wrote:
 hmm..
 ok let me try to explain my point...

 suppose in stream, the rate is 1 integer/k time, so within k time we need to
 process that number and be ready for next number.


 Now when stream has just started, n is small so log(n) is OK, but a time
 will come when log(n)k and then numbers will start accumulating


 Mohit



 On Sun, Dec 26, 2010 at 6:25 PM, radha krishnan
 radhakrishnance...@gmail.com wrote:

 with BST  we can query the occurence in lg (n)

 On Sun, Dec 26, 2010 at 5:19 PM, mohit ranjan shoonya.mo...@gmail.com
 wrote:
  @Radha
 
  With BST, the time taken to search a node depends on size (n), which
  will
  keep on increasing as stream grows long, whereas we need to calculate
  freq
  within the fixed time interval for all numbers...
 
 
  any better solution ?
 
  Mohit
 
 
  On Sun, Dec 26, 2010 at 4:48 PM, radha krishnan
  radhakrishnance...@gmail.com wrote:
 
  An Augmented and self Balancin Binary Search Tree Will suffice
  Tree {
        int element;
        int occurence;
  }
  when u have the element in the BST increment the occurence
  Else create a New node
  Total Complexity is O(n lgn )
  Correct me if am wrong
  lg n -- for finding the previous occurence of the number
 
  On Sun, Dec 26, 2010 at 4:39 PM, bittu shashank7andr...@gmail.com
  wrote:
   You are provided with a stream of numbers, design a data structure to
   store the numbers in the stream along with their no. of occurrences.
  
  
  
   Regards
   Shashank Mani
  
   --
   You received this message because you are subscribed to the Google
   Groups Algorithm Geeks group.
   To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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 algoge...@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 algoge...@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: convert binary matrix to zero matrix

2010-12-25 Thread Ankur Khurana
i have devised another apporah for same but i would have liked to
understand what terence has said ?

On Sat, Dec 25, 2010 at 3:01 PM, Ankur ankur.kkhur...@gmail.com wrote:
 when you are talking abt starting from 1 that means that array is 1
 based , right ?

 and how did you get the steps calculated. please can you explain, once
 more
 take this example, a trivial but albeit will help me explain.

 111
 000
 000

 and
 011
 100
 100

 if it is feasible for you to reply .

 On Dec 8, 1:45 pm, Terence technic@gmail.com wrote:
 As Amir pointed out: convert the first row and first column to all zeros

 In details:

    1. choose operations on first row and first column to make up-left
       element 0.
           * There are 2 cases, 2 choices for each case:
                1. If the up-left element is 0, then
                      1. toggle both first row and first column, or
                      2. leave both untouched.
                2. If the up-left element is 1, then
                      3. toggle first row,  or
                      4. toggle first column
    2. for each 1 on the first row, toggle the corresponding column, to
       change first row to all 0s.
    3. for each 1 on the first column, toggle the corresponding row, to
       change first column to all 0s.

 After above 3 steps, if there are still some 1's, no solution is possible.
 Otherwise, compare the 2 choice, and choose the minimum steps.

 ---

 In fact, we can directly calculate the number of steps in choice a)-d):

    1. number of 0's on the first row and first column
    2. number of 1's on the first row and first column
    3. number of 0's on the first row + number of 1's on the first column
    4. number of 1's on the first row + number of 0's on the first column

 And if we denote the j'th element on i'th row as M[i,j] (start from 1),
 then the problem have valid solution if and only if:
 for each element M[i,j], M[1,1]+M[1,j]+M[i,1]+M[i,j] is even.

 On 2010-12-7 22:59, Prims wrote:

  Hello Rajan

  Suppose we have the following matrix

  1 1
  0 0

  If a toggle operation performed on first row, it will change all 1s to
  0s and 0s to 1s which result in the followig matrix

  0 0
  0 0

  It is zero matrix and the result.

  Similarly if a toggle operation is performed on column, it will change
  all 1s to 0s and 0s to 1s in that particular column.

  Say you have a function toggle(int , Type) which does the toggle
  operation.

  where number is the number of row or column
  Type can be of Type.Row or Type.Column.

  Hope it is clear

  -Prims
  On Dec 7, 5:33 pm, rajan goswamirajan.goswam...@gmail.com  wrote:
  @Prims

  Can you please elaborate the problem in detail...

  What do you mean by toggling row and column...

  1 Interchanging a row with some column ?
  2 Changing 0s to 1s and 1s to 0s of that row ?
  or Some thing else ?

  In both options mentioned above .. no of 1s present in a matrix can not be
  changed to 0s in any ways ...
  Please explain the step that can be performed on given matrix.

  regards,
  Rajan.

  On Mon, Dec 6, 2010 at 11:55 PM, Primstopcode...@gmail.com  wrote:
  Amir
  Could you please explain with an example in detail?
  On Dec 6, 7:02 pm, Amir hossein Shahriari
  amir.hossein.shahri...@gmail.com  wrote:
  actually a greedy approach for this problem exists:
  just convert the first row and first column to all zeros
  if after this step matrix is not a complete zero matrix then it's
  impossible
  to make it
  On Sun, Dec 5, 2010 at 9:10 AM, Primstopcode...@gmail.com  wrote:
  How do i convert a binary matrix(containing only 0s and 1s) to a
  complete zero matrix? Only operations allowed are u can toggle a whole
  row or a whole column. The conversion has to be done in minimum number
  of steps (a step is defined as toggling a whole row or whole column
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups�.com
  algogeeks%2bunsubscr...@googlegroups�.com
  .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.-Hidequoted text -
  - Show quoted text -
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups�.com
  .
  For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.-Hide quoted text -
  - Show quoted text -

 --
 You received this message because you are subscribed to the Google Groups 
 Algorithm 

[algogeeks] Codechef

2010-12-24 Thread Ankur Khurana
I have solved this problem , but i need test cases for this as it it
giving WA in online judge. i dont want algo , but if anyone have
solved this, please provide with some random test cases or one or two
corner test cases.

i will be greatful.

http://www.codechef.com/problems/ARRAYTRM

Given n numbers, you can perform the following operation any number of
times : Choose any subset of the numbers, none of which are 0.
Decrement the numbers in the subset by 1, and increment the numbers
not in the subset by K.

Is it possible to perform operations such that all numbers except one
of them become 0 ?

Input :

The first line contains the number of test cases T. 2*T lines follow,
2 for each case. The first line of a test case contains the numbers n
and K. The next line contains n numbers, a_1...a_n.

Output :

Output T lines, one corresponding to each test case. For a test case,
output YES if there is a sequence of operations as described, and
NO otherwise.

Sample Input :
3
2 1
10 10
3 2
1 2 2
3 2
1 2 3


Sample Output :
YES
YES
NO


Constraints :
1 = T = 1000
2 = n = 100
1 = K = 10
0 = a_i = 1000

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algoge...@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] how to delete a substring from a given string.???

2010-12-23 Thread Ankur Khurana
you can use direct c++ tem-plates. anyways ,
in c format.  use strstr() to find the pointer to the substring
present in the main given string. then just shift all the contents
after the subtring to the starting of your substring.

On Thu, Dec 23, 2010 at 3:47 AM, Ajay Kumar ajay...@gmail.com wrote:
 i dont noe the logic..help!!!

 --
 You received this message because you are subscribed to the Google Groups 
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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 Ranking Problem

2010-12-23 Thread Ankur Khurana
it is just like 0/1 knapsack problem with maximum weight of knapsack
as 40. but in this case that is minimum that we have to calculate.
calculate marks/time for every element . then try finding the elements
with max value/time to fulfill the quota of marks. i dont know if this
can be done in O(n) but it can be certainly done in nlogn. any other
views ?

On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com wrote:
 Thanks for reply. I am looking for O(n) for solution.

 Davin

 On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
 hint : use dp







 On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com wrote:
  Marks for Questions(1,6): {10,15,20,25,10,20}
  Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
  Passing Marks : 40 Out of 100

  Find Questions with minimum time to pass the exam?

  On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
   Please clarify the problem statement. Provide example.
   From the first view problem seems to be unclear.

  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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 Ranking Problem

2010-12-23 Thread Ankur Khurana
wverything i mentioned above can be done in O(n) but sorting part is
nlogn . so that is what i was saying. can you specify where i was not
clear ?

On Thu, Dec 23, 2010 at 9:22 PM, Nikhil Agarwal
nikhil.bhoja...@gmail.com wrote:
 @ankur can you hint your nlogn solution?

 On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 it is just like 0/1 knapsack problem with maximum weight of knapsack
 as 40. but in this case that is minimum that we have to calculate.
 calculate marks/time for every element . then try finding the elements
 with max value/time to fulfill the quota of marks. i dont know if this
 can be done in O(n) but it can be certainly done in nlogn. any other
 views ?

 On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com wrote:
  Thanks for reply. I am looking for O(n) for solution.
 
  Davin
 
  On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
  hint : use dp
 
 
 
 
 
 
 
  On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com
  wrote:
   Marks for Questions(1,6): {10,15,20,25,10,20}
   Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
   Passing Marks : 40 Out of 100
 
   Find Questions with minimum time to pass the exam?
 
   On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
Please clarify the problem statement. Provide example.
From the first view problem seems to be unclear.
 
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
  
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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
 Nikhil Agarwal
 Senior Undergraduate
 Computer Science  Engineering,
 National Institute Of Technology, Durgapur,India
 http://tech-nikk.blogspot.com
 http://beta.freshersworld.com/communities/nitd


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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 Ranking Problem

2010-12-23 Thread Ankur Khurana
i will try to elaborate or rewrite tat part

On Thu, Dec 23, 2010 at 10:25 PM, Ankur Khurana
ankur.kkhur...@gmail.com wrote:
 wverything i mentioned above can be done in O(n) but sorting part is
 nlogn . so that is what i was saying. can you specify where i was not
 clear ?

 On Thu, Dec 23, 2010 at 9:22 PM, Nikhil Agarwal
 nikhil.bhoja...@gmail.com wrote:
 @ankur can you hint your nlogn solution?

 On Thu, Dec 23, 2010 at 9:08 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 it is just like 0/1 knapsack problem with maximum weight of knapsack
 as 40. but in this case that is minimum that we have to calculate.
 calculate marks/time for every element . then try finding the elements
 with max value/time to fulfill the quota of marks. i dont know if this
 can be done in O(n) but it can be certainly done in nlogn. any other
 views ?

 On Thu, Dec 23, 2010 at 9:03 PM, Davin dkthar...@googlemail.com wrote:
  Thanks for reply. I am looking for O(n) for solution.
 
  Davin
 
  On Dec 23, 8:29 pm, snehal jain learner@gmail.com wrote:
  hint : use dp
 
 
 
 
 
 
 
  On Thu, Dec 23, 2010 at 8:30 PM, Davin dkthar...@googlemail.com
  wrote:
   Marks for Questions(1,6): {10,15,20,25,10,20}
   Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
   Passing Marks : 40 Out of 100
 
   Find Questions with minimum time to pass the exam?
 
   On Dec 23, 7:04 pm, juver++ avpostni...@gmail.com wrote:
Please clarify the problem statement. Provide example.
From the first view problem seems to be unclear.
 
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algoge...@googlegroups.com.
   To unsubscribe from this group, send email to
  
   algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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
 Nikhil Agarwal
 Senior Undergraduate
 Computer Science  Engineering,
 National Institute Of Technology, Durgapur,India
 http://tech-nikk.blogspot.com
 http://beta.freshersworld.com/communities/nitd


 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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 Ranking Problem

2010-12-23 Thread Ankur Khurana
how will you choose that ?? without sorting . can you please mention
what method you intend to use to achieve that purpose ?

On Fri, Dec 24, 2010 at 8:16 AM, Terence technic@gmail.com wrote:
 @Ankur:
 It is just 0/1 knapsack problem:
    Choose a subset of the questions with sum of scores not exceeding (Total
 Score - Pass Score), while maximize the sum of time of the subset.
 So I do not think O(nlogn) greedy algorithm will solve this problem.

 On 2010-12-23 23:38, Ankur Khurana wrote:

 it is just like 0/1 knapsack problem with maximum weight of knapsack
 as 40. but in this case that is minimum that we have to calculate.
 calculate marks/time for every element . then try finding the elements
 with max value/time to fulfill the quota of marks. i dont know if this
 can be done in O(n) but it can be certainly done in nlogn. any other
 views ?

 On Thu, Dec 23, 2010 at 9:03 PM, Davindkthar...@googlemail.com  wrote:

 Thanks for reply. I am looking for O(n) for solution.

 Davin

 On Dec 23, 8:29 pm, snehal jainlearner@gmail.com  wrote:

 hint : use dp







 On Thu, Dec 23, 2010 at 8:30 PM, Davindkthar...@googlemail.com  wrote:

 Marks for Questions(1,6): {10,15,20,25,10,20}
 Time for Each Questions(1,6) : { 2, 4,3,4, 2,4}
 Passing Marks : 40 Out of 100
 Find Questions with minimum time to pass the exam?
 On Dec 23, 7:04 pm, juver++avpostni...@gmail.com  wrote:

 Please clarify the problem statement. Provide example.
  From the first view problem seems to be unclear.

 --
 You received this message because you are subscribed to the Google
 Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@googlegroups.com.
 To unsubscribe from this group, send email to

 algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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 algoge...@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 algoge...@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: difference x

2010-12-22 Thread Ankur Khurana
@snehal : nothing wrong in what saurabh said. it was just that if you
are posting a question , then you should also post the approach you
have thought.plus you are posting in bulk . so , please whenever you
give a question , also mention your approach. it gives greater
confidence in question to be solved.

On Wed, Dec 22, 2010 at 9:35 PM, snehal jain learner@gmail.com wrote:
 @saurabh

 u might be a genius bt for ur kind information this is the group for
 learners... this group is a place where people come to learn new tricks, put
 their ideas and ask doubts.. so it would have been better if u had put your
 response rather than discouraging anyone from asking doubts..
 while putting this problem i had the nlogn approach in my mind as pointed by
 vivek. but i wanted a better approach O(n) as it exist for the sum problem
 where sum=x. so i posted it here.. it does not mean if u know a solution
 than the problem is   solved. there is always a chance of optimization which
 u can learn only by discussing...
 u could simply delete mail if u find it so simple..
 and everybody has his own style.. now a days i was solving algorithm
 problems from various blogs and sites so i posted all my doubts in one go...

 On Wed, Dec 22, 2010 at 7:44 PM, Saurabh Koar saurabhkoar...@gmail.com
 wrote:

 @Snehal:

 U r going crazy man.U r blindly picking up problems and throwing them
 in this group.It is not a place solving ur homework problems.Plz post
 problems which r either tricky so that the members can learn something
 or post problems which u cant solve after giving a measurable
 effort.Try to use ur minimum intelligence to solve a
 problem.Otherwise(as pointed out by Swapnil some days ago) it really
 decreases the value of this group.More people will be active if they
 see new thought provoking problems.Also, u post problems and don't
 clear doubts of the members regarding ur problems.This is also bad
 habit.

 Hope u will understand.No offence intended.

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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 algoge...@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: difference x

2010-12-22 Thread Ankur Khurana
ya i agree , your questions are good though.

On Wed, Dec 22, 2010 at 10:19 PM, snehal jain learner@gmail.com wrote:
 @ankur..

 its ok if u r asking for approach.. i ll do it from next tym.. bt posting in
 bulk is not an offence.. i bet u dont the solution to all my problems.. some
 of them u mite know some of them mite b new for u.. well same here u mite
 ask a prob and i mite find it easy.. i posted these problem cz i wanted to
 discuss it.. y wud i flood the group with question? ( i dont enjoy dat) i
 just posted all my doubts in one go.. as i had finishd many blogs n sites
 recently.

 On Wed, Dec 22, 2010 at 10:04 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 @snehal : nothing wrong in what saurabh said. it was just that if you
 are posting a question , then you should also post the approach you
 have thought.plus you are posting in bulk . so , please whenever you
 give a question , also mention your approach. it gives greater
 confidence in question to be solved.

 On Wed, Dec 22, 2010 at 9:35 PM, snehal jain learner@gmail.com
 wrote:
  @saurabh
 
  u might be a genius bt for ur kind information this is the group for
  learners... this group is a place where people come to learn new tricks,
  put
  their ideas and ask doubts.. so it would have been better if u had put
  your
  response rather than discouraging anyone from asking doubts..
  while putting this problem i had the nlogn approach in my mind as
  pointed by
  vivek. but i wanted a better approach O(n) as it exist for the sum
  problem
  where sum=x. so i posted it here.. it does not mean if u know a solution
  than the problem is   solved. there is always a chance of optimization
  which
  u can learn only by discussing...
  u could simply delete mail if u find it so simple..
  and everybody has his own style.. now a days i was solving algorithm
  problems from various blogs and sites so i posted all my doubts in one
  go...
 
  On Wed, Dec 22, 2010 at 7:44 PM, Saurabh Koar saurabhkoar...@gmail.com
  wrote:
 
  @Snehal:
 
  U r going crazy man.U r blindly picking up problems and throwing them
  in this group.It is not a place solving ur homework problems.Plz post
  problems which r either tricky so that the members can learn something
  or post problems which u cant solve after giving a measurable
  effort.Try to use ur minimum intelligence to solve a
  problem.Otherwise(as pointed out by Swapnil some days ago) it really
  decreases the value of this group.More people will be active if they
  see new thought provoking problems.Also, u post problems and don't
  clear doubts of the members regarding ur problems.This is also bad
  habit.
 
  Hope u will understand.No offence intended.
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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 algoge...@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: difference x

2010-12-22 Thread Ankur Khurana
saurabh , asking for a better sol. is not a crime. rest everybody is
intelligent.

On Wed, Dec 22, 2010 at 10:27 PM, Saurabh Koar saurabhkoar...@gmail.com wrote:
 @Snehal: I hv no problem wid ur doubts.Bt sometimes u post probs which
 r very basic.As u solved the looping prob in other thread I think u r
 intelligent enough to solve this prob(difference x) easily and also
 some other probs posted by u(not all).Some problems posted by u are
 really very tricky and I loved them.I jst requested u while posting if
 u review the ques carefully it will be helpful.I dint want to hurt
 u.If u r I m sorry.Bt still I will request u to post carefully.Lets
 finish this.And sorry once again.

 --
 You received this message because you are subscribed to the Google Groups 
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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] HP Question

2010-12-21 Thread Ankur Khurana
insertion sort in IMHO

On Tue, Dec 21, 2010 at 5:44 PM, bittu shashank7andr...@gmail.com wrote:


 Which one is the efficient sorting technique for arranging the books
 in a library?

 a) Bubble Sort
 b) Selection Sort
 c) Insertion Sort
 d) Heap Sort


 Regards
 Shashank

 --
 You received this message because you are subscribed to the Google Groups 
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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 Question

2010-12-21 Thread Ankur Khurana
ashish , nobody is fighting here , but are u sure you are clear on
your probability concepts ? independent events do multiply .
what is the probability that when we toss three coins , we get all three heads ?

On Tue, Dec 21, 2010 at 6:45 PM, Ashish Goel ashg...@gmail.com wrote:
 Dear Shashank

 What will get executed if AB and CD, then will foo2 get executed? NO
 In worst cast(when AB and CD happens at same time i.e.25%), the foo2 fn
 will get executed 50% i.e. 2500 times
 Don't get me wrong, but closed mind is one of the reason people get
 rejected.
 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com wrote:

 @ashish. u r getting wrong if  else makes complete unit so if 1
 fails other executes..no doubt in these..its not tough as much as u
 taking it


 what ii think some guys r right  i got same solution..i don't thinsg
 to xplain  becoz, kathir,ankur has xplained same...  answer will be

 2812


 Thanks  Regards
 Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
 Birla Institue of Technology,Mesra
 Computer Science  Engineering
 Cell +91-9740852296

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 Question

2010-12-21 Thread Ankur Khurana
can you provide the test cases ?
between ,
btw answer my question abt the tosses. plus closed mind argument goes
both ways. i have tried to explain.
if you dont want to understand , it is nobody's prob.wont comment
further on this topic.

On Tue, Dec 21, 2010 at 6:55 PM, Ashish Goel ashg...@gmail.com wrote:
 this is not probability purely...there is an else in between :)
 why don't you write the program and test it out yourself :)



 Best Regards
 Ashish Goel
 Think positive and find fuel in failure
 +919985813081
 +919966006652


 On Tue, Dec 21, 2010 at 6:52 PM, Ankur Khurana ankur.kkhur...@gmail.com
 wrote:

 ashish , nobody is fighting here , but are u sure you are clear on
 your probability concepts ? independent events do multiply .
 what is the probability that when we toss three coins , we get all three
 heads ?

 On Tue, Dec 21, 2010 at 6:45 PM, Ashish Goel ashg...@gmail.com wrote:
  Dear Shashank
 
  What will get executed if AB and CD, then will foo2 get executed? NO
  In worst cast(when AB and CD happens at same time i.e.25%), the foo2
  fn
  will get executed 50% i.e. 2500 times
  Don't get me wrong, but closed mind is one of the reason people get
  rejected.
  Best Regards
  Ashish Goel
  Think positive and find fuel in failure
  +919985813081
  +919966006652
 
 
  On Tue, Dec 21, 2010 at 5:31 PM, bittu shashank7andr...@gmail.com
  wrote:
 
  @ashish. u r getting wrong if  else makes complete unit so if 1
  fails other executes..no doubt in these..its not tough as much as u
  taking it
 
 
  what ii think some guys r right  i got same solution..i don't thinsg
  to xplain  becoz, kathir,ankur has xplained same...  answer will be
 
  2812
 
 
  Thanks  Regards
  Shashank Mani Narayan  Don't B Evil U can Earn While U Learn
  Birla Institue of Technology,Mesra
  Computer Science  Engineering
  Cell +91-9740852296
 
  --
  You received this message because you are subscribed to the Google
  Groups
  Algorithm Geeks group.
  To post to this group, send email to algoge...@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 algoge...@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 algoge...@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 algoge...@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 algoge...@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.



  1   2   >