Re: [algogeeks] Re: Amazon Job openings

2021-07-16 Thread Rahul Vatsa
It's great to see this group active after such a long time, though it was
not for discussing an algo, but I think it's fine if a member in the group
needs some help in his/her professional career and asks for the same here.
Many members in this group are in this industry from more than a decade or
so and are definitely able to help the new guys.
I think I joined this group 12 years back and in those days it used to be
very active. Over time it has become a silent group, let it be a useful
forum in some way.

On Fri, Jul 16, 2021 at 3:46 PM Artemij Art  wrote:

> Hello, guys!
> Have a nice day. Greetings from Russia.
>
> пт, 16 июл. 2021 г., 09:19 Himanshu Singh :
>
>> Hello Guys,
>>
>> Sorry to say pls stop spamming whole group.
>>
>> Thanks.
>>
>>
>> On Fri, Jul 16, 2021, 11:46 AM Yash Khandelwal <
>> khandelwalyash...@gmail.com> wrote:
>>
>>> Done kindly check the mail
>>>
>>> On Fri, Jul 16, 2021, 11:41 AM immanuel kingston <
>>> kingston.imman...@gmail.com> wrote:
>>>
 Please send a note to me on king...@amazon.com

 Thanks,
 Kingston

 On Fri, Jul 16, 2021 at 11:16 AM immanuel kingston <
 kingston.imman...@gmail.com> wrote:

> Hi all,
>
> I am a hiring manager at Amazon. We are hiring for SDE and Applied
> Science roles in my team. Please send a short note about yourself, the 
> role
> you wish to apply for and your updated CV.
>
> Thanks,
> Kingston
>
 --
 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.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/algogeeks/CACOkDGdqjf%2BCUbBEoZcBQUpOsGwyJ8SMq0gDf89tZYiS0K-H-Q%40mail.gmail.com
 
 .

>>> --
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/algogeeks/CAJKd1Pcup_HeQNq%2B3f%2BCcnT8puZ9zwZytnGhwkPHJzsLDdiR_g%40mail.gmail.com
>>> 
>>> .
>>>
>> --
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/algogeeks/CAHwkYYrM7DdSXb1e_Mqis_K-_Y8HUwVJeCKSD0YpLeWiQUA5Vg%40mail.gmail.com
>> 
>> .
>>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/algogeeks/CABbfMraU624PR_fKEs5RJ%3DwQd1NGw_gmiCBCV_i5beheNB91GA%40mail.gmail.com
> 
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/algogeeks/CAK%2BYZjJK64zB0D8-wwWHrbasygLm7yJevzfA9dA8KVbcW1B12A%40mail.gmail.com.


Re: [algogeeks] CAN ANYBODY HELP ME ?!! WİTH THİS ALGORİTHM

2018-11-06 Thread Rahul Rai
Let the glass be numbered 0 1 2 3... (2n - 1).
And the glass numbered 0 1 2 3...(n - 1)  are filled.
Pick every alternating ith filled glass starting from 1 indexed glass and
swap it with the (n - 1 - i)th unfilled glass.

Index 1 will swap with 2n - 2 indexed glass.
Index 3 will swap with 2n - 4 indexed glass.
.
.
.
So on.

Since the first glass is filled and there are 2n glasses(last glass being
indexed by 2n - 1) so the second glass (2n - 2 indexed glass) from the end
must be filled after processing.

On Tue, Nov 6, 2018, 16:24 mehmet ozturk  There are 2n glasses standing next to each other in a row, the first n of
> them are filled with
> a soda drink, while the remaining n glasses are empty. Make the glasses
> alternate in a filledempty-
> filled-empty pattern in the minimum no of glass moves.
>
> --
> 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.
>

-- 
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] Experience hiring in siemens with 5-8 years in C\C++

2016-10-24 Thread Rahul
How much is the maximum CTC which can be offered by Simens?

On Monday, October 24, 2016, Himanshu Singh 
wrote:

> Hello All,
>
> Openings at Siemens Bangalore with following skill set.
> 1. 5-8 years of experience.
> 2. c, c++ and Embedded experience.
> 3. Linux, RTOS.
> 4. RS485, CAN, BANet, I2C, SPI, Industrial Ethernet.
> 5. Linux system programming and scripting.
>
> If interested send your resume...
>
>
>
> *Regards,*
> *Himanshu Singh | Senior Software Engineer*
> *Mobile: *+91 7259897890
> *Siemens *
>
>
>
>
> --
> 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
> 
> .
>


-- 
Sent from Gmail Mobile

-- 
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] Urgent Need ITIL Service Management Operations Business/Process Analyst in Manhattan, NY for 6+ months

2015-09-09 Thread Rahul Vatsa
Please block this guy.

On Thu, Sep 10, 2015 at 1:08 AM, Shaik Asif 
wrote:

> Hi Partner,
>
>
>
> This is Shaik from Deegit Inc. Please find the below requirement for your
> review. If you are comfortable with the requirement please get back to me
> ASAP on sh...@deegit.com
>
>
>
> *Position: ITIL Service Management Operations Business/Process Analyst*
>
> Location: Manhattan, NY   10001
>
> Duration: 6+ Months
>
>
>
> ITIL v3 Foundations or higher certification required
>
> · Experience with BMC Remedy required
>
> · Experience with ServiceNow beneficial
>
> · Able to understand and document complex IT processes
>
> · Experience performing IT assessments and preparing gap analysis
> documents and recommendations
>
> · Experience working as an analyst in support of IT technical
> operations (e.g. - service desk, desktop support, server and application
> management)
>
> · Very strong communication: verbal and written required. Able to
> facilitate workshops and meetings: drive agendas, document findings and
> next steps
>
>
> Best Regards,
>
> ___
>
>
>
> Shaik | Deegit Inc |
>
> 1900 East Golf Rd., Suite 925 | Schaumburg, IL 60173 |
>
> Ph: 847.440.2436 ext - 358 | Fax: 847.330.1987
>
> sh...@deegit.com | www.deegit.com |
>
> --
> 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.
>

-- 
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] Urgent Need Test Lead - Performance Architect in Atlanta, GA for 6 months

2015-09-08 Thread Rahul
people aren't discussing algorithms either , like they used to in 2011

On 9/9/15, Shachindra A C <sachindr...@gmail.com> wrote:
> Hi all,
>
> Can we please limit this group to discussion on algorithms and not post
> jobs over here? This is becoming a nuisance with all job ads posted.
>
>
> On Tue, Sep 8, 2015 at 7:11 AM, Shaik Asif <shaik.deegi...@gmail.com>
> wrote:
>
>> Hi Partner,
>>
>>
>>
>> This is Shaik from Deegit Inc. Please find the below requirement for your
>> review. If you are comfortable with the requirement please get back to me
>> ASAP on sh...@deegit.com
>>
>>
>>
>> *Position: Test Lead - Performance Architect*
>>
>> Location: Atlanta, GA
>>
>> Duration: 6 Months
>>
>>
>>
>> · Performance Engineering of large transaction processing systems
>>
>> · Performance Modeling & Optimization of Solution Architectures
>>
>> · End tend systems performance analysis and performance tuning,
>> in one or more of the following technologies : J2EE (Weblogic, Websphere,
>> JBOSS), .NET, Oracle , SAP
>>
>> · Code Optimization and Platform Tuning in any of the above
>> technologies
>>
>> · Proficiency in Performance Testing, profiling and monitoring
>> tools (Certification in one or more of the following toolsets is
>> desirable)
>>
>> · HP LoadRunner
>>
>> · HP Performance Center
>>
>> · HP BAC, Diagnostics
>>
>> · HP Sitescope
>>
>> · CA Wily Introscope and CEM (APM)
>>
>> · SAR, vmstat, iostat, netstat, perfmon
>>
>> · CA Hyperformix
>>
>> · CA LISA (formerly called ITKLISA)
>>
>> · Building Performance Engineering Strategies for clients
>>
>> · Performance Testing (load, stress, volume, availability, etc.),
>> Regression, manual and automated testing of web based and client-server
>> systems
>>
>> · End-to-end phases of performance testing, including
>>
>> · Performance Requirements Definition
>>
>> · Test Planning & Scheduling
>>
>> · Test Environment Planning
>>
>> · Defining performance metrics tbe captured across system and
>> application tiers, using profiling & monitoring tools
>>
>> · Building performance test scripts
>>
>> · Performance test execution
>>
>> · End tend bottleneck analysis
>>
>> · Defining performance tuning measures end-to-end, across all
>> tiers of applications being performance tested
>>
>> · Analysis of test data tidentify impact on release
>>
>> · Root cause analysis / diagnosis of performance issues that
>> occur on production systems
>>
>> · Defect Tracking and documentation
>>
>> · Capacity Planning
>>
>> Best Regards,
>>
>> ___
>>
>>
>>
>> Shaik | Deegit Inc |
>>
>> 1900 East Golf Rd., Suite 925 | Schaumburg, IL 60173 |
>>
>> Ph: 847.440.2436 ext - 358 | Fax: 847.330.1987
>>
>> sh...@deegit.com | www.deegit.com |
>>
>> --
>> 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,
> Shachindra A C
>
> --
> 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

Rahul Rai

-- 
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] Technology for Graphical User Interface on Linux

2014-10-18 Thread rahul
ncurses.

On Friday, October 17, 2014, Mayur mayurhem...@gmail.com wrote:
 Not the right forum..
 But you can try Qt if licensing isn't a concern.
 Or GTK+.

 On Mon, Oct 6, 2014 at 8:03 PM, sagar sindwani sindwani.sa...@gmail.com
wrote:

 Hi all,
 I am looking for a good tool or language to create graphical user
interface in linux environment. Java can be used to achieve the purpose,
Can you please let me know any other technology for such purpose.


 Thanks
 Sagar

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

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


-- 
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] C++ initialization list

2014-09-28 Thread Rahul Vatsa
http://stackoverflow.com/questions/3127454/how-do-c-class-members-get-initialized-if-i-dont-do-it-explicitly

On Sun, Sep 28, 2014 at 12:22 PM, Deepak Garg deepakgarg...@gmail.com
wrote:

 Hi

 In example 1, member z will have a garbage value (i.e. 0 in your case )

 Thanks
 Deepak
 On Sep 28, 2014 11:29 AM, sagar sindwani sindwani.sa...@gmail.com
 wrote:

 I am working on How compilers handle initialization list. I came across a
 case where I am not sure what should be the compiler behaviour.

 *Example 1:-*

 #include iostream

 class A
 {
 public:
 int x,y,z;
 };

 int main()
 {
 A a1[2] =
 {
 { 1,2 },
 { 3,4 }
 };

 std::cout  a1[0].z is   a1[0].z  std::endl;

 return 0;
 }

 In above case a1[0].z is ? g++ shows it as 0 ( zero ). It is exactly 0 or
 garbage value, I am not sure on that.

 I tried lot of books and some documents , no where I found what C++ says
 for initialization of class objects.

 You can find handling of below case in almost every book.

 *Example 2:- *

 int arr[6] = {0};

 In Example 2,  compilers will auto-fill all members with 0. It is
 mentioned in books. But when it comes to User-defined datatypes nothing is
 mentioned.


 Please share your thoughts on this. If you find any document related to
 this, please share it as well.

 Thanks
 Sagar

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

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


-- 
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: Median of two sorted arrays of different sizes

2013-06-09 Thread rahul sharma
@doncan u plz explain the approach used.I didnt get this.

On 4/25/13, Don dondod...@gmail.com wrote:
 Let's say you have two arrays: A[x] and B[y].
 The median is the (x+y)/2th value.
 If A[i] is the median, then B[(x+y)/2-i] = A[i] and B[(x+y)/2-i+1] =
 A[i].
 You can use a binary search to find the point where that condition
 occurs. Of course you want to search on the smaller array.
 You'll need some logic at the end to determine if the median is in A
 or in B.

 // Input arrays A and B, sizeA = sizeB
 int A[sizeA];
 int B[sizeB];

 int min = 0;
 int max = sizeA;
 const int medianPos = (sizeA + sizeB) / 2;
 while(max = min)
 {
   i = (min + max) / 2;
   j = medianPos-i;
   if (B[j]  A[i]) min = i+1;
   else if (B[j+1]  A[i]) max = i-1;
   else break;
 }

 printf(Median is %d\n, (A[i]  B[j]) ? A[i] : B[j]);

 Don

 On Apr 24, 1:19 pm, rahul sharma rahul23111...@gmail.com wrote:
 IS this code correct?

 float findMedianUtil( int A[], int N, int B[], int M )
 {
     // If the smaller array has only one element
     if( N == 1 )
     {
         // Case 1: If the larger array also has one element, simply call
 MO2()
         if( M == 1 )
             return MO2( A[0], B[0] );

         // Case 2: If the larger array has odd number of elements, then
 consider
         // the middle 3 elements of larger array and the only element of
         // smaller array. Take few examples like following
         // A = {9}, B[] = {5, 8, 10, 20, 30} and
         // A[] = {1}, B[] = {5, 8, 10, 20, 30}
         if( M  1 )
             return MO2( B[M/2], MO3(A[0], B[M/2 - 1], B[M/2 + 1]) );

         // Case 3: If the larger array has even number of element, then
 median
         // will be one of the following 3 elements
         // ... The middle two elements of larger array
         // ... The only element of smaller array
         return MO3( B[M/2], B[M/2 - 1], A[0] );
     }

     // If the smaller array has two elements
     else if( N == 2 )
     {
         // Case 4: If the larger array also has two elements, simply call
 MO4()
         if( M == 2 )
             return MO4( A[0], A[1], B[0], B[1] );

         // Case 5: If the larger array has odd number of elements, then
 median
         // will be one of the following 3 elements
         // 1. Middle element of larger array
         // 2. Max of first element of smaller array and element just
         //    before the middle in bigger array
         // 3. Min of second element of smaller array and element just
         //    after the middle in bigger array
         if( M  1 )
             return MO3 ( B[M/2],
                          max( A[0], B[M/2 - 1] ),
                          min( A[1], B[M/2 + 1] )
                        );

         // Case 6: If the larger array has even number of elements, then
         // median will be one of the following 4 elements
         // 1)  2) The middle two elements of larger array
         // 3) Max of first element of smaller array and element
         //    just before the first middle element in bigger array
         // 4. Min of second element of smaller array and element
         //    just after the second middle in bigger array
         return MO4 ( B[M/2],
                      B[M/2 - 1],
                      max( A[0], B[M/2 - 2] ),
                      min( A[1], B[M/2 + 1] )
                    );
     }

     int idxA = ( N - 1 ) / 2;
     int idxB = ( M - 1 ) / 2;

      /* if A[idxA] = B[idxB], then median must exist in
         A[idxA] and B[idxB] */
     if( A[idxA] = B[idxB] )
         return findMedianUtil( A + idxA, N / 2 + 1, B, M - idxA );

     /* if A[idxA]  B[idxB], then median must exist in
        A[...idxA] and B[idxB] */
     return findMedianUtil( A, N / 2 + 1, B + idxA, M - idxA );

 }

 In the end I suspect the following part:-

   if( A[idxA] = B[idxB] )
         return findMedianUtil( A + idxA, N / 2 + 1, B, M - idxA );

     /* if A[idxA]  B[idxB], then median must exist in
        A[...idxA] and B[idxB] */
     return findMedianUtil( A, N / 2 + 1, B + idxA, M - idxA );

 plz comment

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




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




[algogeeks] kth smallest element in 2 sorted arrays

2013-06-09 Thread rahul sharma
Please suggest logm+logn aproach...
can be easily done in o(k)


How to do in logm +logn

plz suggest algo

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




[algogeeks] A Juggling Algorithm

2013-06-05 Thread rahul sharma
Can anybody explain me how juggling algo works for array rotation ???Whats
the logic behind 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.




Re: [algogeeks] Re: searching all matching words in a Trie with a given filter.

2013-06-05 Thread rahul sharma
wat exaclty the question is.
We have to make a tire with filter or we have a trie(whole dictionary) and
we have to check filter out the elements.

plz explain question


On Wed, May 29, 2013 at 7:55 PM, Don dondod...@gmail.com wrote:

 There has to be some way to know that a node is the end of a word, and
 to know what that word is. This might be done by using a parent
 pointer which lets you traverse the trie back to the root, rebuilding
 the word, or you could keep track of the word as you traverse down the
 trie. Putting the whole word in the node where the word ends would be
 the most simple and time-efficient approach, if you have the memory to
 support it.

 Here is a different way to do it, if the trie has a wordEnd flag and
 does not store the word in the node.

 void findWords(trie *root, char *filter, String word=)
 {
 if (!root) return;

 if (*filter == 0)  // When you reach the end of the filter at the
 end of a valid word, add the word.
 {
 if (root-wordEnd) words.add(word);
 }
 else if (*filter == '.')   // Search for words with any letter
 {
 for(int i = 'a'; i = 'z' ; ++i)
 findWords(root-link[i], filter+1, word+i);
 }
 else  // Search for words with the required letter
 {
  findWords(root-link[*filter], filter+1, word+*filter);
 }
 }

 On May 28, 11:36 pm, avinesh saini avinesh.sa...@gmail.com wrote:
  Thank you Don, I was also trying in similar way. But here I'm confused
 how
  you are storing the traversed words. Are you adding whole words at the
 node
  on which word is ending during insertion.
 
 
 
 
 
 
 
 
 
  On Wed, May 29, 2013 at 12:36 AM, Don dondod...@gmail.com wrote:
   void findWords(trie *root, char *filter)
   {
   if (!root) return;
 
   if (*filter == 0)  // When you reach the end of the filter at the
   end of a valid word, add the word.
   {
   if (root-words) words.add(root-word);
   }
   else if (*filter == '.')   // Search for words with any letter
   {
   for(int i = 'a'; i = 'z' ; ++i)
   findWords(root-link[i], filter+1);
   }
   else  // Search for words with the required letter
   {
findWords(root-link[*filter], filter+1);
   }
   }
 
   On May 28, 4:47 am, avinesh saini avinesh.sa...@gmail.com wrote:
How to search all the matching words for a filter in a trie.
e.g.
searching by filter  ...r..m will find all the words(of length =
 7) in
trie in which 4th character is 'r' and 7th character is 'm'.
 
--
*
*
*thanks  regards,*
*Avinesh
*
 
   --
   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.
 
  --
  *
  *
  *thanks  regards,*
  *Avinesh
  *

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




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




[algogeeks] t9 dictionary

2013-06-05 Thread rahul sharma
how to implement with trie.???is trie the best way..plz provide me raw algo
to start with,

-- 
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] Minimum number of coins to SUM to S

2013-06-05 Thread rahul sharma
yes clasic DP


On Wed, May 29, 2013 at 8:54 PM, Ravi Ranjan ravi.cool2...@gmail.comwrote:

 @DAve

 any proper reason or link to proof that at least twice can be solved using
 greedy but others are not??


 On Tue, May 28, 2013 at 12:41 PM, Shashwat Kumar 
 shashwatkmr@gmail.com wrote:

 This seems to be Coin Change problem. Just google that.


 On Tue, May 28, 2013 at 12:42 AM, Adolfo Ccanto adol...@gmail.comwrote:

 Can you write the constraints for this problem?
 thanks.
 Adolfo


 2013/5/18 rahul sharma rahul23111...@gmail.com

 Minimum of coins to sum s

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




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






 --
 Shashwat Kumar
 Third year Undergraduate student
 Department of Computer Science and Engineering
 IIT Kharagpur




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




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




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




[algogeeks] Re: t9 dictionary

2013-06-05 Thread rahul sharma
Can i implement by trie which is having structure as 9 pointers for 9
digits..like if it comes 4663...i will make a path 4663 from root to leaf
and in end i will have a linked list to store dataany more optimized
solution anyone having???plz suggest


On Thu, May 30, 2013 at 2:37 AM, rahul sharma rahul23111...@gmail.comwrote:

 how to implement with trie.???is trie the best way..plz provide me raw
 algo to start with,


-- 
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] searching all matching words in a Trie with a given filter.

2013-05-29 Thread rahul sharma
@don u r searching in a previously built trie with the given filter...then
wat is this add fxn doing?correct me if m getting u wrng
On Wednesday, May 29, 2013, avinesh saini avinesh.sa...@gmail.com wrote:
 Thank you Don, I was also trying in similar way. But here I'm confused
how you are storing the traversed words. Are you adding whole words at the
node on which word is ending during insertion.


 On Wed, May 29, 2013 at 12:36 AM, Don dondod...@gmail.com wrote:

 void findWords(trie *root, char *filter)
 {
 if (!root) return;

 if (*filter == 0)  // When you reach the end of the filter at the
 end of a valid word, add the word.
 {
 if (root-words) words.add(root-word);
 }
 else if (*filter == '.')   // Search for words with any letter
 {
 for(int i = 'a'; i = 'z' ; ++i)
 findWords(root-link[i], filter+1);
 }
 else  // Search for words with the required letter
 {
  findWords(root-link[*filter], filter+1);
 }
 }

 On May 28, 4:47 am, avinesh saini avinesh.sa...@gmail.com wrote:
  How to search all the matching words for a filter in a trie.
  e.g.
  searching by filter  ...r..m will find all the words(of length = 7)
in
  trie in which 4th character is 'r' and 7th character is 'm'.
 
  --
  *
  *
  *thanks  regards,*
  *Avinesh
  *

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





 --

 thanks  regards,
 Avinesh

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




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




[algogeeks] Minimum number of coins to SUM to S

2013-05-27 Thread rahul sharma
Minimum of coins to sum s

-- 
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: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
guys ..i got solution here
http://www.geeksforgeeks.org/program-to-count-number-of-set-bits-in-an-big-array/

plz tell how its complexity is logn.


On Fri, May 17, 2013 at 6:55 PM, Don dondod...@gmail.com wrote:

 Counting the set bits in one integer is not the problem which was
 asked.
 However, I think that something like this is both faster and more easy
 to understand than what you have written:

 int bitCount(unsigned int x)
 {
int result = 0;
while(x)
{
   if (x  1) ++result;
   x = 1;
}
return result;
 }

 On May 17, 8:32 am, bhargav ybbkris...@gmail.com wrote:
  as bitwise operators are fast can count by following logic, works oly fr
  +ve, just a tweak will make it to work with -ves also ..
 
  #include stdio.h
  main() {
  unsigned int x=12312,a;
  a=x1;
  //printf(%u,a);
  int count=0;
  while(x0) {
  a = x1;
  //printf(%u \n,a);
  if(ax)
  count++;
  x=a;}
 
  printf(%d\n,count );
  getch();
 
 
 
 
 
 
 
  }

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




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




[algogeeks] lexographic permutations complexity

2013-05-27 Thread rahul sharma
following is code from geeks for geeks.
Please tell how the complexity of this in n*n!
n*n! times loop will be executed and then wat about the statements in
loop??
reference:-
http://www.geeksforgeeks.org/lexicographic-permutations-of-string/(second
method)

void reverse(char str[], int l, int h)
{
   while (l  h)
   {
   swap(str[l], str[h]);
   l++;
   h--;
   }
}

// Print all permutations of str in sorted order
void sortedPermutations ( char str[] )
{
// Get size of string
int size = strlen(str);

// Sort the string in increasing order
qsort( str, size, sizeof( str[0] ), compare );

// Print permutations one by one
bool isFinished = false;
while ( ! isFinished )
{
// print this permutation
printf (%s \n, str);

// Find the rightmost character which is smaller than its next
// character. Let us call it 'first char'
int i;
for ( i = size - 2; i = 0; --i )
   if (str[i]  str[i+1])
  break;

// If there is no such chracter, all are sorted in decreasing order,
// means we just printed the last permutation and we are done.
if ( i == -1 )
isFinished = true;
else
{
// Find the ceil of 'first char' in right of first character.
// Ceil of a character is the smallest character greater than it
int ceilIndex = findCeil( str, str[i], i + 1, size - 1 );

// Swap first and second characters
swap( str[i], str[ceilIndex] );

// reverse the string on right of 'first char'
reverse( str, i + 1, size - 1 );
}
}
}

-- 
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: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
and how this is working
void init()
{
bitCount[0] = 0;
for(int i = 1; i  65536; ++i) bitCount[i] = bitCount[i/2] + (i1);
}
it is working fine..but plz tell the logic behind this


On Thu, May 23, 2013 at 11:12 AM, rahul sharma rahul23111...@gmail.comwrote:


 @don...i got  it...its complexity is logn..how?


 On Thu, May 23, 2013 at 11:10 AM, rahul sharma rahul23111...@gmail.comwrote:

 @don..you are counting in an integer only...correct if wrng?


 On Wed, May 22, 2013 at 7:28 PM, Don dondod...@gmail.com wrote:

 My program works with any numbers.
 Don

 On May 22, 3:45 am, Pramida Tumma pramida.tu...@gmail.com wrote:
  This above program works only if the array contains consecutive numbers
  starting from 1 to n. What to do if the array contains random numbers?
 
 
 
 
 
 
 
  On Fri, May 17, 2013 at 6:55 PM, Don dondod...@gmail.com wrote:
   Counting the set bits in one integer is not the problem which was
   asked.
   However, I think that something like this is both faster and more
 easy
   to understand than what you have written:
 
   int bitCount(unsigned int x)
   {
  int result = 0;
  while(x)
  {
 if (x  1) ++result;
 x = 1;
  }
  return result;
   }
 
   On May 17, 8:32 am, bhargav ybbkris...@gmail.com wrote:
as bitwise operators are fast can count by following logic, works
 oly fr
+ve, just a tweak will make it to work with -ves also ..
 
#include stdio.h
main() {
unsigned int x=12312,a;
a=x1;
//printf(%u,a);
int count=0;
while(x0) {
a = x1;
//printf(%u \n,a);
if(ax)
count++;
x=a;}
 
printf(%d\n,count );
getch();
 
}
 
   --
   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.

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






-- 
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: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
@pramidathat can be done in 0(n)..lets say int takes 4 bytes
i will make and array of first 256 numbers ...
while finding for inte i will take a char pointer pointing to first byte
and then using array of 256 int i will count in that byte and increent
array and count in it.and so on...access all the 4 bits...0(1) to create
the first 256 numbers array and 0(n) to access array.hope m clear


On Wed, May 22, 2013 at 1:15 PM, Pramida Tumma pramida.tu...@gmail.comwrote:

 This above program works only if the array contains consecutive numbers
 starting from 1 to n. What to do if the array contains random numbers?


 On Fri, May 17, 2013 at 6:55 PM, Don dondod...@gmail.com wrote:

 Counting the set bits in one integer is not the problem which was
 asked.
 However, I think that something like this is both faster and more easy
 to understand than what you have written:

 int bitCount(unsigned int x)
 {
int result = 0;
while(x)
{
   if (x  1) ++result;
   x = 1;
}
return result;
 }

 On May 17, 8:32 am, bhargav ybbkris...@gmail.com wrote:
  as bitwise operators are fast can count by following logic, works oly fr
  +ve, just a tweak will make it to work with -ves also ..
 
  #include stdio.h
  main() {
  unsigned int x=12312,a;
  a=x1;
  //printf(%u,a);
  int count=0;
  while(x0) {
  a = x1;
  //printf(%u \n,a);
  if(ax)
  count++;
  x=a;}
 
  printf(%d\n,count );
  getch();
 
 
 
 
 
 
 
  }

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



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




-- 
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] least common ancestore bst

2013-05-27 Thread rahul sharma
then solution i posted aboive is correct in that case???plz comment


On Fri, May 17, 2013 at 9:49 AM, avinesh saini avinesh.sa...@gmail.comwrote:

 If one node is parent of other then Parent Node is lowest common ancestor.
 Source- http://en.wikipedia.org/wiki/Lowest_common_ancestor (just read it)


 On Mon, May 13, 2013 at 1:42 AM, rahul sharma rahul23111...@gmail.comwrote:

 [image: BST_LCA]
 what should be ancestor of 12 and 14.it should be 12 or
 14...if 12 then for 20 and 22 also it is 20...if 12 ans 14 has
 ancestor as 8 then for 20 and 22 it is NULL.

 @allplz give me clear one line definition in case if one node is
 parent of other then what is LCA


 On Sun, Apr 21, 2013 at 10:32 PM, Tushar Patil 
 tushar01pa...@gmail.comwrote:

 @rahul : It's fine solution, but can we check  the root-data == n1 ||
 n2 before calling function recursively, I think if we check this condition
 1st it will reduce unnecessary function calls.
Correct me if i am wrong?
 Thanks,
 Tushar Patil.



 On Sun, Apr 21, 2013 at 10:26 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 int leastCommanAncestor(struct node* root, int n1, int n2)
 {
  if(root==NULL)
  return -1;
  if(root-datan1  root-datan2)
  return leastCommanAncestor(root-left,n1,n2);
  else if(root-datan1  root-datan2)
  return leastCommanAncestor(root-right,n1,n2);
  return root-data;

 }

 Does this code miss any case?N suppose if we have to find LCA of n1 and
 n2 and suppose n1 is parent of n2 ..then this will return n1..is this fyn
 or if n1 is parent of n2 then we should return -1??

 Plz. comment

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 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,*
 *Avinesh Kumar
 National Institute of Technology, Calicut.*
 *Kerala- 673601*
 *+91 7849080702*

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




-- 
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: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
@don...i got  it...its complexity is logn..how?


On Thu, May 23, 2013 at 11:10 AM, rahul sharma rahul23111...@gmail.comwrote:

 @don..you are counting in an integer only...correct if wrng?


 On Wed, May 22, 2013 at 7:28 PM, Don dondod...@gmail.com wrote:

 My program works with any numbers.
 Don

 On May 22, 3:45 am, Pramida Tumma pramida.tu...@gmail.com wrote:
  This above program works only if the array contains consecutive numbers
  starting from 1 to n. What to do if the array contains random numbers?
 
 
 
 
 
 
 
  On Fri, May 17, 2013 at 6:55 PM, Don dondod...@gmail.com wrote:
   Counting the set bits in one integer is not the problem which was
   asked.
   However, I think that something like this is both faster and more easy
   to understand than what you have written:
 
   int bitCount(unsigned int x)
   {
  int result = 0;
  while(x)
  {
 if (x  1) ++result;
 x = 1;
  }
  return result;
   }
 
   On May 17, 8:32 am, bhargav ybbkris...@gmail.com wrote:
as bitwise operators are fast can count by following logic, works
 oly fr
+ve, just a tweak will make it to work with -ves also ..
 
#include stdio.h
main() {
unsigned int x=12312,a;
a=x1;
//printf(%u,a);
int count=0;
while(x0) {
a = x1;
//printf(%u \n,a);
if(ax)
count++;
x=a;}
 
printf(%d\n,count );
getch();
 
}
 
   --
   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.

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





-- 
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: count number of set bits in an (big) array (Asked in Google interview)

2013-05-27 Thread rahul sharma
@don..you are counting in an integer only...correct if wrng?


On Wed, May 22, 2013 at 7:28 PM, Don dondod...@gmail.com wrote:

 My program works with any numbers.
 Don

 On May 22, 3:45 am, Pramida Tumma pramida.tu...@gmail.com wrote:
  This above program works only if the array contains consecutive numbers
  starting from 1 to n. What to do if the array contains random numbers?
 
 
 
 
 
 
 
  On Fri, May 17, 2013 at 6:55 PM, Don dondod...@gmail.com wrote:
   Counting the set bits in one integer is not the problem which was
   asked.
   However, I think that something like this is both faster and more easy
   to understand than what you have written:
 
   int bitCount(unsigned int x)
   {
  int result = 0;
  while(x)
  {
 if (x  1) ++result;
 x = 1;
  }
  return result;
   }
 
   On May 17, 8:32 am, bhargav ybbkris...@gmail.com wrote:
as bitwise operators are fast can count by following logic, works
 oly fr
+ve, just a tweak will make it to work with -ves also ..
 
#include stdio.h
main() {
unsigned int x=12312,a;
a=x1;
//printf(%u,a);
int count=0;
while(x0) {
a = x1;
//printf(%u \n,a);
if(ax)
count++;
x=a;}
 
printf(%d\n,count );
getch();
 
}
 
   --
   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.

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




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




[algogeeks] [Adobe]Generate all possible combinations (of r elements) inside an array of size N

2013-05-27 Thread rahul sharma
 Generate all possible combinations (of r elements) inside an array of size
N
E.g. arr [] = {2,8,14} All possible combinations of r=2 will be {2,8},
{8,14}, {14,2}

Asked in adobe

-- 
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] least common ancestore bst

2013-05-16 Thread rahul sharma
[image: BST_LCA]
what should be ancestor of 12 and 14.it should be 12 or
14...if 12 then for 20 and 22 also it is 20...if 12 ans 14 has
ancestor as 8 then for 20 and 22 it is NULL.

@allplz give me clear one line definition in case if one node is parent
of other then what is LCA


On Sun, Apr 21, 2013 at 10:32 PM, Tushar Patil tushar01pa...@gmail.comwrote:

 @rahul : It's fine solution, but can we check  the root-data == n1 || n2
 before calling function recursively, I think if we check this condition 1st
 it will reduce unnecessary function calls.
   Correct me if i am wrong?
 Thanks,
 Tushar Patil.



 On Sun, Apr 21, 2013 at 10:26 PM, rahul sharma rahul23111...@gmail.comwrote:

 int leastCommanAncestor(struct node* root, int n1, int n2)
 {
  if(root==NULL)
  return -1;
  if(root-datan1  root-datan2)
  return leastCommanAncestor(root-left,n1,n2);
  else if(root-datan1  root-datan2)
  return leastCommanAncestor(root-right,n1,n2);
  return root-data;

 }

 Does this code miss any case?N suppose if we have to find LCA of n1 and
 n2 and suppose n1 is parent of n2 ..then this will return n1..is this fyn
 or if n1 is parent of n2 then we should return -1??

 Plz. comment

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




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




[algogeeks] Next higher number with same number of set bits

2013-05-12 Thread rahul sharma
unsigned snoob(unsigned x) {
unsigned smallest, ripple, ones;
// x = xxx0  
smallest = x  -x; //  0001 
ripple = x + smallest; // xxx1  
ones = x ^ ripple; // 0001  
ones = (ones  2)/smallest; //   0111
return ripple | ones; // xxx1  0111
}


please expalin the reason for right shifting by 2Although results are
coming ok..but
wats the logic behind this..


Plz comment.

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




[algogeeks] count number of set bits in an (big) array (Asked in Google interview)

2013-05-12 Thread rahul sharma
I was searching for google questions and got this question.Use look up to
do it in bext way


What is best time complexity for this..
plz post algo too

-- 
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] MS written Reasoning question

2013-05-03 Thread rahul sharma
@ashish...4 all selected...remaining 2 to be selected..1 m,ba 1
betch makes one 2 mba and 1 mca...but as it is not only option coz we can
put 2 mcas at 2 remaing pos so this is not true...3 are ignored 4th must be
true..


On Mon, Apr 29, 2013 at 7:37 AM, ashish gupta ashish12.it...@gmail.comwrote:

 Ans is  1 M.A + 2 B.Tech + 2 MBA + 1 MCA.

 Explanation:

 (1) Exactly one must be an MA.
 (2) Given: 2 b.tech are seleceted and the statement if at least one
 btech is selected then exactly 2 MBA are selected (vice versa condition)
 So exactly 2 MBA will be selected.
 (3) Remaining 1 would be MCA.


 So ans would be (d)

 option (b) is not correct as it says that only 2 mba and only 1 mca are
 selected but the total no of selected candidates are 6.

 --
 Ashish


 On Fri, Apr 26, 2013 at 11:32 PM, rahul sharma rahul23111...@gmail.comwrote:

 10 candidates appear for an interview and 6 selected.
 2-M.A
 2-MCA
 4-BTECH
  2-MBA.
 If at least one MBA is selected then exactly 2 btech are selected and
 vice versa.
 Of six candidates,exactly one must be an MA cndidate

 question:- which of the following statementsis definitely true:,if 2
 btech are selected:

 a- two mca and 2 ma are selected.
 b- only 2 mbas and  only one mca is selected
 c-one MBA and two MAs are selected.
 d- Two MBAs are selected.


 My approach:- we are with 2 btech,one ma,one mba

 remaining two can be 1 mba+1mca
 or 2 mcas

 But correct option is d.
 How is this definitely true and b is not??
 plz comment



  --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




  --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] MS written Reasoning question

2013-04-28 Thread rahul sharma
10 candidates appear for an interview and 6 selected.
2-M.A
2-MCA
4-BTECH
2-MBA.
If at least one MBA is selected then exactly 2 btech are selected and vice
versa.
Of six candidates,exactly one must be an MA cndidate

question:- which of the following statementsis definitely true:,if 2 btech
are selected:

a- two mca and 2 ma are selected.
b- only 2 mbas and  only one mca is selected
c-one MBA and two MAs are selected.
d- Two MBAs are selected.


My approach:- we are with 2 btech,one ma,one mba

remaining two can be 1 mba+1mca
or 2 mcas

But correct option is d.
How is this definitely true and b is not??
plz comment

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Re: Find the number of islands/connected components

2013-04-26 Thread rahul sharma
got the islands...but first we scan each element then also dfs for them if
all are 1..then how it can be o(row*col)...plz explain me complexity ofr
this


On Fri, Apr 26, 2013 at 2:07 PM, atul anand atul.87fri...@gmail.com wrote:

 {*1*,* 1*, 0, 0, 0},
 {0, *1*, 0, 0, *1*
 },
 {*1*, 0, 0, *1*, *1*},
 {0, 0, 0, 0, 0},
 {*1*, 0, *1*, 0, *1*}

 above different set of color represent different island.Simple DFS is used to 
 find all the island



 On Fri, Apr 26, 2013 at 3:11 AM, Don dondod...@gmail.com wrote:

 The complexity is still O(ROWS*COLS) because each location in the
 matrix will be visited once by the loop and once by DFS. Once a
 location has been visited by DFS, it is marked as visited and can't be
 visited again.
 Don

 On Apr 25, 5:11 pm, rahul sharma rahul23111...@gmail.com wrote:
  What will be complexity if all elements in matrix are 1..
 
  when first dfs will call then all matrix will be scanned setting each
  element to visited...
  then again loop contiues to scan all the elements..plz explain
 
  On Thu, Apr 11, 2013 at 2:04 AM, rahul sharma rahul23111...@gmail.com
 wrote:
 
 
 
 
 
 
 
   {*1*,* 1*, 0, 0, 0},
   {0, *1*, 0, 0, *1*},
   {*1*, 0, 0, *1*, *1*},
   {0, 0, 0, 0, 0},
   {*1*, 0, *1*, 0, *1*}
 
   Can anybody eplain how there are 5 islands in above matrix..thnx in
 advance
 
   source:-http://www.geeksforgeeks.org/find-number-of-islands/

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.



  --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Find the number of islands/connected components

2013-04-25 Thread rahul sharma
@don..can u plz tell me how the complexity of this
http://www.geeksforgeeks.org/find-number-of-islands/ is ROW*COL?


On Thu, Apr 11, 2013 at 4:35 PM, rahul sharma rahul23111...@gmail.comwrote:


 M not getting matrix..is it adjacencyif simple 1 means connected
 components then first wehave 3 ones..then in second line 3 ones form 1 more
 island..hw in last row 3 islands are formed..these are 3 1 means three
 independent nodes...m I ryt?

 On Thursday, April 11, 2013, Arpit Sood soodfi...@gmail.com wrote:
  islands are five as for each cell we assume all surrounding positions to
 be connected... so if coordinates are (x,y) then it is connected to (x+1,
 y), (x-1, y), (x+1, y+1), (x-1, y+1), (x+1, y-1), (x-1, y-1), (x, y-1), (x,
 y+1
 
 
  On Thu, Apr 11, 2013 at 9:35 AM, rahul sharma rahul23111...@gmail.com
 wrote:
 
  I didnt get..plz explain more...thnx
 
  On Thursday, April 11, 2013, Don dondod...@gmail.com wrote:
   Reformatting to make it easier to see:
  
   11000
   01001
   10011
   0
   10101
  
   In this case an island is any set of 1's which are connected
   vertically, horizontally, or diagonally.
   So the five islands are
  
   11000
   01002
   10022
   0
   30405
  
   Don
  
   On Apr 10, 4:34 pm, rahul sharma rahul23111...@gmail.com wrote:
   {*1*,* 1*, 0, 0, 0},
   {0, *1*, 0, 0, *1*},
   {*1*, 0, 0, *1*, *1*},
   {0, 0, 0, 0, 0},
   {*1*, 0, *1*, 0, *1*}
  
   Can anybody eplain how there are 5 islands in above matrix..thnx in
 advance
  
   source:-http://www.geeksforgeeks.org/find-number-of-islands/
  
   --
   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.
   For more options, visit https://groups.google.com/groups/opt_out.
  
  
  
 
  --
  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.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 
 
 
  --
  Regards,
  Arpit Sood
 
  --
  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.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 


-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Find the number of islands/connected components

2013-04-25 Thread rahul sharma
What will be complexity if all elements in matrix are 1..

when first dfs will call then all matrix will be scanned setting each
element to visited...
then again loop contiues to scan all the elements..plz explain


On Thu, Apr 11, 2013 at 2:04 AM, rahul sharma rahul23111...@gmail.comwrote:

 {*1*,* 1*, 0, 0, 0},
 {0, *1*, 0, 0, *1*},
 {*1*, 0, 0, *1*, *1*},
 {0, 0, 0, 0, 0},
 {*1*, 0, *1*, 0, *1*}


 Can anybody eplain how there are 5 islands in above matrix..thnx in advance

 source:-http://www.geeksforgeeks.org/find-number-of-islands/



-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Median of two sorted arrays of different sizes

2013-04-24 Thread rahul sharma
IS this code correct?

float findMedianUtil( int A[], int N, int B[], int M )
{
// If the smaller array has only one element
if( N == 1 )
{
// Case 1: If the larger array also has one element, simply call MO2()
if( M == 1 )
return MO2( A[0], B[0] );

// Case 2: If the larger array has odd number of elements, then consider
// the middle 3 elements of larger array and the only element of
// smaller array. Take few examples like following
// A = {9}, B[] = {5, 8, 10, 20, 30} and
// A[] = {1}, B[] = {5, 8, 10, 20, 30}
if( M  1 )
return MO2( B[M/2], MO3(A[0], B[M/2 - 1], B[M/2 + 1]) );

// Case 3: If the larger array has even number of element, then median
// will be one of the following 3 elements
// ... The middle two elements of larger array
// ... The only element of smaller array
return MO3( B[M/2], B[M/2 - 1], A[0] );
}

// If the smaller array has two elements
else if( N == 2 )
{
// Case 4: If the larger array also has two elements, simply call MO4()
if( M == 2 )
return MO4( A[0], A[1], B[0], B[1] );

// Case 5: If the larger array has odd number of elements, then median
// will be one of the following 3 elements
// 1. Middle element of larger array
// 2. Max of first element of smaller array and element just
//before the middle in bigger array
// 3. Min of second element of smaller array and element just
//after the middle in bigger array
if( M  1 )
return MO3 ( B[M/2],
 max( A[0], B[M/2 - 1] ),
 min( A[1], B[M/2 + 1] )
   );

// Case 6: If the larger array has even number of elements, then
// median will be one of the following 4 elements
// 1)  2) The middle two elements of larger array
// 3) Max of first element of smaller array and element
//just before the first middle element in bigger array
// 4. Min of second element of smaller array and element
//just after the second middle in bigger array
return MO4 ( B[M/2],
 B[M/2 - 1],
 max( A[0], B[M/2 - 2] ),
 min( A[1], B[M/2 + 1] )
   );
}

int idxA = ( N - 1 ) / 2;
int idxB = ( M - 1 ) / 2;

 /* if A[idxA] = B[idxB], then median must exist in
A[idxA] and B[idxB] */
if( A[idxA] = B[idxB] )
return findMedianUtil( A + idxA, N / 2 + 1, B, M - idxA );

/* if A[idxA]  B[idxB], then median must exist in
   A[...idxA] and B[idxB] */
return findMedianUtil( A, N / 2 + 1, B + idxA, M - idxA );
}

In the end I suspect the following part:-

  if( A[idxA] = B[idxB] )
return findMedianUtil( A + idxA, N / 2 + 1, B, M - idxA );

/* if A[idxA]  B[idxB], then median must exist in
   A[...idxA] and B[idxB] */
return findMedianUtil( A, N / 2 + 1, B + idxA, M - idxA );

plz comment

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Interview Question

2013-04-19 Thread rahul sharma
search the previous posts before posting

search for
[algogeeks] Amazon Interview Question
you will get 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Re: algorithm to sort based on frequency.

2013-04-16 Thread rahul sharma
@don.can u plz explain with example.


On Wed, Feb 1, 2012 at 9:29 PM, Don dondod...@gmail.com wrote:

 Build a hashmap with the array value as a key mapping to a struct
 which contains the key, frequency, and location of first occurance.
 Then sort the hashed elements comparing first by frequency and
 breaking ties based on first occurance. Then iterate through the
 sorted elements and fill in the array. All steps are O(n) except for
 the sort, so the overall complexity is O(n*log n).
 Don

 On Feb 1, 2:58 am, Varun tewari.va...@gmail.com wrote:
  I was asked this question sometime during an interview.
 
  WE have an array of known length. The elements in array can be
 repetitive.
  now sort the array based on frequency of occurrence of each element in
  array.
  Eg: a= {4.3.2.5.4.6.2.6}
  after sorting a={4,4,2,2,6,6,3,5}
 
  4,2,6 all occurs twice, in this case retain the order in which they
  appeared in original array.
  I was able to give a solution using hashing the elements of the array to
 a
  new array, and if hash matches, incrementing the count, and then sort the
  hash values. Later, re scan the array to retain the order in case
 there's a
  match in frequency of any two element.
 
  Looking for better alternatives.
  Please pour in.

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



-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Re: algorithm to sort based on frequency.

2013-04-16 Thread rahul sharma
Can anyone give me example using hash+linked list method ..although i got
dave method.but still...


On Tue, Apr 16, 2013 at 8:58 PM, Dave dave_and_da...@juno.com wrote:

 @Varun: Here is an algorithm using sorting only:

 1. Append an index onto each number, so your example becomes {{4,0},
 {3,1}, {2,2}, etc.}

 2. Sort the numbers and their associated indices into ascending order by
 number. Your example becomes {{2,2}, {2,6}, {3,1}, {4,0}, {4,4}, etc.}. If
 the sort is not stable, the indices on equal numbers may not be in order,
 as I've shown here, but that doesn't matter. It will be taken care of in
 the next step.

 3. Scan the array, and collapse every sequence of adjacent entries with
 equal numbers into one entry with the lowest index, and append the
 frequency to the entry. Your example becomes {{2,2,2}, {3,1,1}, {4,0,2},
 etc.}

 4. Sort the array with frequency as the primary key and index as the
 secondary key. You get {{4,0,2}, {2,2,2}, {6,5,2}, {3,1,1}, {5,1,3}}.

 5. Reexpand the array by repeating each number according to its frequency,
 giving {4,4,2,2,6,6,3,5}.

 Dave

 On Wednesday, February 1, 2012 2:58:43 AM UTC-6, Varun wrote:

 I was asked this question sometime during an interview.

 WE have an array of known length. The elements in array can be repetitive.
 now sort the array based on frequency of occurrence of each element in
 array.
 Eg: a= {4.3.2.5.4.6.2.6}
 after sorting a={4,4,2,2,6,6,3,5}

 4,2,6 all occurs twice, in this case retain the order in which they
 appeared in original array.
 I was able to give a solution using hashing the elements of the array to
 a new array, and if hash matches, incrementing the count, and then sort the
 hash values. Later, re scan the array to retain the order in case there's a
 match in frequency of any two element.

 Looking for better alternatives.
 Please pour in.

  --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] inplace m*n transpose

2013-04-12 Thread rahul sharma
in this there are permutation cycles which are used to do transpose.can
anybody tell me

nl = (ol x R) mod (N-1)

nl- new location

ol- old location

N-total elements

if i is current element then it will be placed at new location

next = (i*r)%size;

r- no. of rows

please explain how it works logically?i did nt get this


source:-http://www.geeksforgeeks.org/inplace-m-x-n-size-matrix-transpose/

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Find the number of islands/connected components

2013-04-11 Thread rahul sharma
M not getting matrix..is it adjacencyif simple 1 means connected
components then first wehave 3 ones..then in second line 3 ones form 1 more
island..hw in last row 3 islands are formed..these are 3 1 means three
independent nodes...m I ryt?
On Thursday, April 11, 2013, Arpit Sood soodfi...@gmail.com wrote:
 islands are five as for each cell we assume all surrounding positions to
be connected... so if coordinates are (x,y) then it is connected to (x+1,
y), (x-1, y), (x+1, y+1), (x-1, y+1), (x+1, y-1), (x-1, y-1), (x, y-1), (x,
y+1


 On Thu, Apr 11, 2013 at 9:35 AM, rahul sharma rahul23111...@gmail.com
wrote:

 I didnt get..plz explain more...thnx

 On Thursday, April 11, 2013, Don dondod...@gmail.com wrote:
  Reformatting to make it easier to see:
 
  11000
  01001
  10011
  0
  10101
 
  In this case an island is any set of 1's which are connected
  vertically, horizontally, or diagonally.
  So the five islands are
 
  11000
  01002
  10022
  0
  30405
 
  Don
 
  On Apr 10, 4:34 pm, rahul sharma rahul23111...@gmail.com wrote:
  {*1*,* 1*, 0, 0, 0},
  {0, *1*, 0, 0, *1*},
  {*1*, 0, 0, *1*, *1*},
  {0, 0, 0, 0, 0},
  {*1*, 0, *1*, 0, *1*}
 
  Can anybody eplain how there are 5 islands in above matrix..thnx in
advance
 
  source:-http://www.geeksforgeeks.org/find-number-of-islands/
 
  --
  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.
  For more options, visit https://groups.google.com/groups/opt_out.
 
 
 

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.





 --
 Regards,
 Arpit Sood

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Trie | (Insert and Search)

2013-04-10 Thread rahul sharma
http://www.geeksforgeeks.org/trie-insert-and-search/

Can any body tell me what is need of checking pcrawl!=0 int the
return..cant we check only its value0 to check whether its a leaf node

return (0 != pCrawl  pCrawl-value);

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Trie | (Insert and Search)

2013-04-10 Thread rahul sharma
M asking in case of DELETE from trie fxn


On Wed, Apr 10, 2013 at 9:15 PM, rahul sharma rahul23111...@gmail.comwrote:

 http://www.geeksforgeeks.org/trie-insert-and-search/

 Can any body tell me what is need of checking pcrawl!=0 int the
 return..cant we check only its value0 to check whether its a leaf node

 return (0 != pCrawl  pCrawl-value);





-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Interview question

2013-04-10 Thread rahul sharma
isnt the complexity should be o(m*n*n) instead of (n*n*n) as m can be
greater than n..plz comment


On Wed, Apr 10, 2013 at 10:11 PM, rahul sharma rahul23111...@gmail.comwrote:


 http://www.geeksforgeeks.org/dynamic-programming-set-27-max-sum-rectangle-in-a-2d-matrix/

 wat is complexity of thisn3  or mn2


-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Interview question

2013-04-10 Thread rahul sharma
M is number of rows n n is col..outer 2 loops are running n times and inner
is for kadane m tymes n for temp m times total 2m...so isnt it should be
n*n*m?
On Thursday, April 11, 2013, Don dondod...@gmail.com wrote:
 M is a matrix, not a number. M is NxN, so the algorithm is O(N^3) as
 stated in the text.

 On Apr 10, 4:19 pm, rahul sharma rahul23111...@gmail.com wrote:
 isnt the complexity should be o(m*n*n) instead of (n*n*n) as m can be
 greater than n..plz comment

 On Wed, Apr 10, 2013 at 10:11 PM, rahul sharma rahul23111...@gmail.com
wrote:









 http://www.geeksforgeeks.org/dynamic-programming-set-27-max-sum-recta...

  wat is complexity of thisn3  or mn2

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Find the number of islands/connected components

2013-04-10 Thread rahul sharma
I didnt get..plz explain more...thnx

On Thursday, April 11, 2013, Don dondod...@gmail.com wrote:
 Reformatting to make it easier to see:

 11000
 01001
 10011
 0
 10101

 In this case an island is any set of 1's which are connected
 vertically, horizontally, or diagonally.
 So the five islands are

 11000
 01002
 10022
 0
 30405

 Don

 On Apr 10, 4:34 pm, rahul sharma rahul23111...@gmail.com wrote:
 {*1*,* 1*, 0, 0, 0},
 {0, *1*, 0, 0, *1*},
 {*1*, 0, 0, *1*, *1*},
 {0, 0, 0, 0, 0},
 {*1*, 0, *1*, 0, *1*}

 Can anybody eplain how there are 5 islands in above matrix..thnx in
advance

 source:-http://www.geeksforgeeks.org/find-number-of-islands/

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Re: Dlete Linked List

2013-04-09 Thread rahul sharma
sory..following is correct code
void deleteList(struct node** head)
{
   /* deref head_ref to get the real head */
 struct node* next;

   while (*head != NULL)
   {
   next = *head-next;
   free(next);
   *head = next;
   }


}


On Tue, Apr 9, 2013 at 9:27 PM, Don dondod...@gmail.com wrote:

 head is not even declared, so I doubt that it would compile.
 I believe that you want to free head, not next.


 On Apr 9, 11:31 am, rahul sharma rahul23111...@gmail.com wrote:
   Is the following code correct for linked list deletion or i need to copy
  head in some tem. pointer and dlete and theninitialize head to NULLL.Plz
  comment
   void deleteList(struct node** head_ref)
   {
  /* deref head_ref to get the real head */
struct node* next;
 
 while (*head != NULL)
  {
  next = *head-next;
  free(next);
  *head = next;
  }
 
   }

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Amazon interview question

2013-04-09 Thread rahul sharma
 A = {5, 3, 8, 9, 16}
After one iteration A = {3-5,8-3,9-8,16-9}={-2,5,1,7}
After second iteration A = {5-(-2),1-5,7-1} sum =7+(-4)+6=9
Given an array, return sum after n iterations

my sol/
void abc(int arr[],n)
{
for(i=0;in;i++)
arr[i]=arr[i+1]-arr[i];
abc(arr,n-1);
}


I wana ask that the complexity is o(n) or o(n)2..as loop is executed n
times..say n is 10...so fxn is called 10 timesi.e  10 n..and ignoring n
it comes out to be...n..but if we implemeted with 2 loops then
complexity is n2 ...and both sol are taking same no of iterations...please
tell whether complexity is n or n2 for above codeif it is n2 then how???

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Re: Amazon interview question

2013-04-09 Thread rahul sharma
i forgot to add base case..can add wen 2 elemnts are there then there sum
is stored and we reurn from there...i m in hurry,,,sry for that,,


On Wed, Apr 10, 2013 at 12:11 AM, Don dondod...@gmail.com wrote:

 It is O(N^2) because the inner loop takes N steps to execute and that
 loop will be executed N times.

 However, I would suggest not using recursion. There is no reason to
 not do it iteratively. Your recursive solution has no base case so it
 will recurse until your computer runs out of stack space, at which
 point it will crash.

 Don

 On Apr 9, 2:29 pm, rahul sharma rahul23111...@gmail.com wrote:
   A = {5, 3, 8, 9, 16}
  After one iteration A = {3-5,8-3,9-8,16-9}={-2,5,1,7}
  After second iteration A = {5-(-2),1-5,7-1} sum =7+(-4)+6=9
  Given an array, return sum after n iterations
 
  my sol/
  void abc(int arr[],n)
  {
  for(i=0;in;i++)
  arr[i]=arr[i+1]-arr[i];
  abc(arr,n-1);
 
  }
 
  I wana ask that the complexity is o(n) or o(n)2..as loop is executed
 n
  times..say n is 10...so fxn is called 10 timesi.e  10 n..and
 ignoring n
  it comes out to be...n..but if we implemeted with 2 loops then
  complexity is n2 ...and both sol are taking same no of
 iterations...please
  tell whether complexity is n or n2 for above codeif it is n2 then
 how???

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Re: Amazon interview question

2013-04-09 Thread rahul sharma
If you have any other solution ..please post that...i thnik recursion is ok
with base case...we need to scan again after first iteration...??


On Wed, Apr 10, 2013 at 12:12 AM, rahul sharma rahul23111...@gmail.comwrote:

 i forgot to add base case..can add wen 2 elemnts are there then there sum
 is stored and we reurn from there...i m in hurry,,,sry for that,,


 On Wed, Apr 10, 2013 at 12:11 AM, Don dondod...@gmail.com wrote:

 It is O(N^2) because the inner loop takes N steps to execute and that
 loop will be executed N times.

 However, I would suggest not using recursion. There is no reason to
 not do it iteratively. Your recursive solution has no base case so it
 will recurse until your computer runs out of stack space, at which
 point it will crash.

 Don

 On Apr 9, 2:29 pm, rahul sharma rahul23111...@gmail.com wrote:
   A = {5, 3, 8, 9, 16}
  After one iteration A = {3-5,8-3,9-8,16-9}={-2,5,1,7}
  After second iteration A = {5-(-2),1-5,7-1} sum =7+(-4)+6=9
  Given an array, return sum after n iterations
 
  my sol/
  void abc(int arr[],n)
  {
  for(i=0;in;i++)
  arr[i]=arr[i+1]-arr[i];
  abc(arr,n-1);
 
  }
 
  I wana ask that the complexity is o(n) or o(n)2..as loop is
 executed n
  times..say n is 10...so fxn is called 10 timesi.e  10 n..and
 ignoring n
  it comes out to be...n..but if we implemeted with 2 loops then
  complexity is n2 ...and both sol are taking same no of
 iterations...please
  tell whether complexity is n or n2 for above codeif it is n2 then
 how???

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.





-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: Median in stream of running integers

2013-03-24 Thread rahul sharma
So we need to implement prelocate down for deletion?

On Sunday, March 24, 2013, atul anand atul.87fri...@gmail.com wrote:
 yeah implementation is wrong.

 On 3/24/13, tec technic@gmail.com wrote:
 The heap implementation is wrong to only prelocate up on deletion top.
 15
   /\
   14  13
  /  \/  \
1211109
/\/\/\/\
   8  7  6  5  4  3  2  1
 For example, for the above heap, when deleteTop is called, 1 is moved to
 top, and heaplify is called on node 9, which does nothing and leave the
 heap in an invalid state.

 Comapring l and r child to find maximum/minimum is only needed in
prelocate
 down, not in prelocate up.


 2013/3/24 rahul sharma rahul23111...@gmail.com

 And also in heapify y we r not comapring l and r chid to find maximum?


 On Sun, Mar 24, 2013 at 6:07 PM, rahul sharma
 rahul23111...@gmail.comwrote:

 I was goin thorugh question on this link

http://www.geeksforgeeks.org/median-of-stream-of-integers-running-integers/
 My doubt is y we uses prelocate up in case of deletion also.In deletion
 we use pre locate down.But y here we used pre locate up..plz
xplain.thnx
 in
 advance

 // Heapification
  // Note that, for the current median tracing problem
  // we need to heapify only towards root, always
  void heapify(int i)
  {
  int p = parent(i);

 // comp - differentiate MaxHeap and MinHeap
  // percolates up
  if( p = 0  comp(A[i], A[p]) )
  {
  Exch(A[i], A[p]);
  heapify(p);
  }
  }

  int deleteTop()
  {
  int del = -1;

 if( heapSize  -1)
  {
  del = A[0];

 Exch(A[0], A[heapSize]);
  heapSize--;
  heapify(parent(heapSize+1));
  }

 return del;
  }


  --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.






 --
 __

 --
 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.
 For more options, visit

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] Solution Book

2013-03-17 Thread Rahul
I
s your account hacked?

--
www.quora.com/rahul-rai


On Mon, Mar 18, 2013 at 12:27 AM, shady sinv...@gmail.com wrote:

 Does anyone have solutions for Let Us C by Yashwant Kanetkar ?
 If yes, then please PM me.

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] trie implementation

2013-03-14 Thread rahul sharma
Can anybody provide me to understand t9 implementation? I dnt need code..I
need how to implement t9 with trie with explanation..thnx in advance

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Re: trie implementation

2013-03-14 Thread rahul sharma
On Thursday, March 14, 2013, rahul sharma rahul23111...@gmail.com wrote:
 Can anybody provide any link me to understand t9 implementation? I dnt
need code..I need how to implement t9 with trie with explanation..thnx in
advance

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [algogeeks] [Off topic] Call for Moderators for Algogeeks

2013-03-14 Thread rahul sharma
You mean one who can provide solutions to the pending questions or some
type of management of group like the type of posts and off topic??

On Wed, Mar 13, 2013 at 11:25 PM, shady sinv...@gmail.com wrote:

 Hi,
 Does anyone wants to be moderator ? We want someone who is actively
 participating in discussions and can frequently check the pending tasks for
 moderation.

 Shady

 --
 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.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.




[algogeeks] Compiler doubt

2013-01-22 Thread rahul sharma
S-aAbB\bAaB\e


A-S
B-s



Find follow(A) and follow(B)???explanation required??thnx in advance

-- 




Re: [algogeeks] Re: Find all words in given character Matrix

2013-01-17 Thread rahul
are u maintaining any known list of word from dictionary , if not , it
might have lots of words some of them doesn't have any meaning   :-),
please give clear picture of what you want to achieve.

On Thu, Jan 17, 2013 at 11:49 PM, Don dondod...@gmail.com wrote:

 Store the word list in a trie. Starting at each location in the
 matrix, search the trie for the patterns formed in each direction.

 On Jan 17, 12:33 pm, Piyush piyush.to...@gmail.com wrote:
  Given a MxN char array matrix, find all words in it. search left, right,
  diagonally

 --




-- 




Re: [algogeeks] Pointers Usage

2013-01-02 Thread Rahul
Take a look at the linux kernel .
Or VLC player 's source code.
You will not ask this question again.

--
www.quora.com/rahul-rai


On Thu, Jan 3, 2013 at 12:44 AM, atul anand atul.87fri...@gmail.com wrote:

 @shady : It allows us to allocate m/m dynamically ..which in itself is
 very big advantage.
 m/m consumption can be ignored , if you compare with the flexibility
 it provides.
 eg:-

 int *arr=(int *)malloc(sizeof(int) * 100);

 now  m/m consumption here is 100*4+8;// extra 8 wont hurt if you
 compare with the advantage.

 another advantage:-
 suppose dere are 1000 integer value stored in
 m/m...a1,a2,a3,a4a100...now among all these only one is active at
 a particular time T.
 now to make it more interesting,suppose multiple threads want to find
 which one is active at a particular time T.

 it would be better if we have int *active pointer.
 now anyone among a1,a2,a3a100 becomes active then we store its
 address to *active.All threads now just need to synchronize and check
 *active pointer to find which one is active at a particular time T
 among a1,a2,a3...a10 instead of checking each variable which is
 time consuming and may corrupt at some time.
 I hope it helps.


 now suppose mutiple threads are accessing sam

 --




-- 




[algogeeks] B-Tree

2013-01-01 Thread rahul sharma
IF btree is of order n,then what is min nuber of values at each node
Is it floor(n/2)
a
I read if oreder is 5 then min values in each node is 2...SO is it
floor(n/2)

-- 




Re: [algogeeks] Pointers Usage

2013-01-01 Thread rahul
Optimization.

On Wed, Jan 2, 2013 at 1:35 AM, shady sinv...@gmail.com wrote:

 Why do we use pointers at all considering space as a factor other than
 allocating memory dynamically does it have any other use ?

 to store an integer
 (int *) = 8 bytes, and while making it point to an integer location would
 cost another 4 bytes, total = 12 bytes ... compared to directly taking
 (int) = 4 bytes

 --




-- 




[algogeeks] DBMS gate 2012 query

2012-12-27 Thread rahul sharma
HI
please explain the following question no: 2 on below link as i am not able
to copy it.

http://www.geeksforgeeks.org/database-management-system-set-3/

-- 




Re: [algogeeks] Re: adobe apti question

2012-12-16 Thread rahul sharma
I got it from aomewhr .answer given is e...
E option is wrng as per my opinion..
It should be 13 or 23 instead of 12or23

am i ryt?

On Mon, Dec 17, 2012 at 12:03 AM, Shubham Sandeep 
s.shubhamsand...@gmail.com wrote:

 according to me option c holds
 Reason:it is either that FG or EH pair occurs but both pairs cannot
 occur as one is an oucome of B while other holds if C occurs. since either
 B or C (but not both) may follow A... so point prooved. but D will always
 be there weather B or C follows after A.
 since must occur is asked my answer is option C


 On Sun, Dec 16, 2012 at 11:39 PM, marti amritsa...@gmail.com wrote:

 Yes I feel (e) is the right option.


 On Sunday, December 16, 2012 11:18:57 PM UTC+5:30, rahul sharma wrote:

 A causes B or C, but not both
 F occurs only if B occurs
 D occurs if B or C occurs
 E occurs only if C occurs
 J occurs only if E or F occurs
 D causes G,H or both
 H occurs if E occurs
 G occurs if F occurs

 6. If A occurs which of the following must occurs

 I. F and G
 II. E and H
 III. D

 (a) I only
 (b) II only
 (c) III only
 (d) I,II,  III
 (e) I  II (or) II  III but not both

 Ans. (e)
 E option should be   or 113
 am i ryt???
 A- b or c.
 if A-Bthen B-fg   and Delse if A-C   ,then   c-eh and c-d

 am i ryt

  --






 --
 Regards,
 SHUBHAM SANDEEP
 IT 3rd yr.
 NIT ALD.

  --




-- 




Re: [algogeeks] Re: Adobe Interview Question

2012-12-12 Thread rahul
@don , becoz this is India...and shit happens everywhere

On Wed, Dec 12, 2012 at 11:48 PM, Don dondod...@gmail.com wrote:

 I dislike interview questions which place arbitrary restrictions on
 the solver.
 It may be a good puzzle, but it's not a good interview question.

 Print the numbers 1 to 100 without using a loop.

 Why would you want to do that?

 Divide a number by 5 without using the divide operator.

 Again, why? Interview questions shouldn't be about silly little
 tricks, but about showing that you can do a real-world job.

 Don

 On Dec 11, 10:23 pm, saurabh singh saurab...@gmail.com wrote:
  I would have replied back with I am doing it with C programming language
  only. the read function that we use is not an actual system call. It
  is a *wrapper
  to a system call*. Any other function that we use usually ends up in
  calling some system call. The actual system call is called by low level
  routines.
  If he still disagreed I would have given him this solution:
 
  #includestdio.h
  int main()
  {
  int ch;
  while((ch=getchar())!=-1) putchar(ch);
  return 0;
 
  }
 
  Would have run this as *./a.out  file_to_read*
  *
  *
  If he still disagreed I would have walked out :P
 
  Saurabh Singh
  B.Tech (Computer Science)
  MNNIT
  blog:geekinessthecoolway.blogspot.com
 
  On Tue, Dec 11, 2012 at 11:23 PM, manish untwal manishuntw...@gmail.com
 wrote:
 
 
 
 
 
 
 
   i answered with the...system call too..but he said...do it in C
   programming language only don't use...system call here!!
 
   On Tue, Dec 11, 2012 at 10:32 PM, saurabh singh saurab...@gmail.com
 wrote:
 
   stdin is a file pointer.
   freopen returns a file pointer..
   I suggest using read system call.
 
   For the second question it would be simply
   (len)!/((frequency_0)!*(frequency_1)!*(frequency_2)!...)
 
   However this will also contains permutations which begin with 0. So
   subtract the number of permutations that begin with 0 from this
 number.
 
   Since any factorial in the denominator part will be less than or
 equal to
   (len)! we can calculate and store them while calculating len! Hence
 the
   overall operation will take O(len) time which would be O(log n) where
 n is
   the number.
 
   Saurabh Singh
   B.Tech (Computer Science)
   MNNIT
   blog:geekinessthecoolway.blogspot.com
 
   On Tue, Dec 11, 2012 at 11:02 AM, amrit harry 
 dabbcomput...@gmail.comwrote:
 
   1st:
 
   freopen(filename,r,stdin);
 
   while(scanf(%s,str)!=-1)
   {
   printf(%s\n,str);
   }
 
   On Sun, Dec 9, 2012 at 3:22 PM, manish untwal 
 manishuntw...@gmail.comwrote:
 
   I gave this interview in August this year, two of the question i was
   not able to answer properly
   1) how to print the content of file in C without using the file
 pointer.
   2) count the total number of permutation of a number in order O(n)
 
   --
 
   --
   Thanks  Regards
   Amritpal singh
 
--
 
--
 
   --
   With regards,
   Manish kumar untwal
   Indian Institute of Information Technology
   Allahabad (2009-2013 batch)
 
--

 --




-- 




Re: [algogeeks] Re: Largest contigious subarray with average greather than k

2012-11-26 Thread Rahul Kumar Patle
) {

 max_ending_here -= a[ts];
 if (avgGreater(max_ending_here, ts+1, te, k)) {
  ts++;
 System.out.println(Result subarray start index: + ts
 +  End index: + te);
  break;
 }
 ts++;
 }
  ts = s;
 te = e;
 max_ending_here = max_so_far;
  while (ts  te) {

 max_ending_here -= a[te];
 if (avgGreater(max_ending_here, ts, te-1, k)) {
  te--;
 System.out.println(Result subarray start index: + ts
 +  End index: + te);
  break;
 }
 te--;
 }

 }

 return max_so_far;
 }

 static boolean avgGreater(int sum, int s, int e, float k) {
 float t= (float) (sum / (e - s + 1));
  return t=k? true : false;
 }

  public static void main(String[] args) {

 int[] a = { 100, 10, -1, -1, 4, -1, 7, 2, 8 };
  System.out.println(maxAvgSum(a, 5));
 }
 }


 On Wed, Nov 21, 2012 at 10:07 PM, Sachin Chitale 
 sachinchital...@gmail.com wrote:

 Hello,

 Algorithm--
 1. Find out start and end index of contiguous subarray which has max
 sum O(n)
 2.Once u have start and end index calculate avg if it satisfies the
 condition then done O(n)
   2.1 other wise run a loop through start to end index and remove
 trailing elements by increasing start
  2.2 simultaneously check avg..this will lead to proper subarray.
 3. In similar fashion start reducing end valuse keeping start
 constant.do it sub steps of 2...

 compare result of 2 and 3 and choose d best one...
 give me some time to write code


 On Wed, Nov 21, 2012 at 12:29 AM, Koup anastasaki...@gmail.com wrote:

 To be correct I need the longest subarray that has an average greater
 than k but my main problem here is to find the longest one. Thank you !

 --






 --
 Regards,
 Sachin Chitale
 Application Engineer SCJP, SCWCD
 Contact# : +91 8086284349, 9892159511
 Oracle Corporation




 --
 Regards,
 Sachin Chitale
 Application Engineer SCJP, SCWCD
 Contact# : +91 8086284349, 9892159511
 Oracle Corporation

 --




  --






 --
 Regards,
 Sachin Chitale
 Application Engineer SCJP, SCWCD
 Contact# : +91 8086284349, 9892159511
 Oracle Corporation

 --






-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 




Re: [algogeeks] Re: Output

2012-11-25 Thread Rahul Kumar Patle
@pandey : here you are shifting 1 to right by 4 bit (as rushiraj said
correctly)
which becomes 0.1, then you are doing negation which becomes
11...0(mask)
now do you and operation
mask  56  = 40
mask  64 = 64
mask  127 = 111
you can notice that only 5th lsb (effective value 16) is zero which is
present in 56 and 127 but not in 64
so 64 remains the same but 56 and 127 got reduced by 16.


On Sat, Nov 24, 2012 at 8:36 PM, Dave dave_and_da...@juno.com wrote:

 @Rajesh: In binary, mask = 111...10 (with 4-byte ints, this is 27
 1-bits followed by 5 0-bits). The logical product of num with mask zeros
 out the low order 5 bits while retaining the high order 27 bits. Thus, res
 is num truncated to the largest multiple of 32 that does not exceed num. 56
 = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127
 (=3*32 + 31) goes to 3*32 = 96.

 Dave

 On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:

 void dosomething(int num)
 {
 int mask=~(15-1);
 int res=nummask;
  printf(%d,res);
 }
 int main()
 {
 dosomething(56);
  dosomething(64);
 dosomething(127);
 return 0;
 }

 please explain  the logic behind the output.

 Thanks,
 Rajesh

  --






-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 




Re: [algogeeks] Re: Output

2012-11-25 Thread Rahul Kumar Patle
sorry its left shift.. one mistake.. other than this ans is correct.. i have
done left shift on 1 by 4 bits that why result became ~(0.1)
ignore the right shift i have mentioned..

On Sun, Nov 25, 2012 at 4:48 PM, Rahul Kumar Patle 
patlerahulku...@gmail.com wrote:

 @pandey : here you are shifting 1 to right by 4 bit (as rushiraj said
 correctly)
 which becomes 0.1, then you are doing negation which becomes
 11...0(mask)
 now do you and operation
 mask  56  = 40
 mask  64 = 64
 mask  127 = 111
 you can notice that only 5th lsb (effective value 16) is zero which is
 present in 56 and 127 but not in 64
 so 64 remains the same but 56 and 127 got reduced by 16.


 On Sat, Nov 24, 2012 at 8:36 PM, Dave dave_and_da...@juno.com wrote:

 @Rajesh: In binary, mask = 111...10 (with 4-byte ints, this is 27
 1-bits followed by 5 0-bits). The logical product of num with mask zeros
 out the low order 5 bits while retaining the high order 27 bits. Thus, res
 is num truncated to the largest multiple of 32 that does not exceed num. 56
 = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127
 (=3*32 + 31) goes to 3*32 = 96.

 Dave

 On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:

 void dosomething(int num)
 {
 int mask=~(15-1);
 int res=nummask;
  printf(%d,res);
 }
 int main()
 {
 dosomething(56);
  dosomething(64);
 dosomething(127);
 return 0;
 }

 please explain  the logic behind the output.

 Thanks,
 Rajesh

  --






 --
 Thanks and Regards:
 Rahul Kumar Patle
 M.Tech, School of Information Technology
 Indian Institute of Technology, Kharagpur-721302, 
 Indiahttp://www.iitkgp.ac.in/
 Mobile No: +91-8798049298, +91-9424738542
 Alternate Email: rahulkumarpa...@hotmail.com
 [image: 
 Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
 [image: Twitter] https://twitter.com/rahulkumarpatle
 https://www.facebook.com/rkpatle




-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 




Re: [algogeeks] C o/p adobe

2012-11-16 Thread rahul sharma
but with adding it willl copy aalll the codewe we dont need to copy..if
we declare int i in file 1...and include in file 2..then i can use it in
file 2 with its extern declaration...m i ryt?

On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar y.neeraj2...@gmail.comwrote:

 For Dev-C++, you have to include one file in another.
 So either add *#include file1.c *in file2.c and compile file2.c or add 
 *#include
 file2.c *in file1.c and compile file1.c.

 Hope this helps.


 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey rkd7...@gmail.comwrote:

 @rahulsharma
  file1.c

 #includestdio.h
 extern int i;// defintion provided in this file itself
 extern int j; // definition provided in file2
 void next()
 {
 ++i;
 other();
 }
 int main()
 {
 ++i;
 printf(%d\n,j);
 printf(%d\n,i);
next();
 }
 int i=3;

 // end of file1.c

 file2.c
 extern int i; // declaration of i as extern
 int j=10; // j defined in file2 here which was declared as extern in file
 1

 void other()
 {
 ++i;
 printf(%d\n,i);
 }
 // end of file2.c

 compile both file together
 as
 rahul@rahul:~gcc file1.c file2.c
 rahul@rahul:~./a.out
 you will get the required output





 On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar 
 y.neeraj2...@gmail.comwrote:

 That's why you are getting the error. You have to compile both the files
 together. Search on google. I don't use dev c++.

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

  No...individually...dev cpp..how to compile both together???


 On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar y.neeraj2...@gmail.com
  wrote:

 Which compiler are you using ? Are you compiling both the files
 together ?

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730



 On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma rahul23111...@gmail.com
  wrote:

 but how can i use extern..if i simply declare a variable in file1 as
 int j and try to use in file2 with extern then it shows that j nit
 defined..how cum file2 knows in which file j is definedfor e.g if i 
 use
 extern in file it means that this variable/fxn is defined somewhr 
 else.then
 what are those files in which it searches this variable definition..i m
 getting errorplese give me 2 files in which one files defines 
 variable
 and other uses using extern.its not working for me

 On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey 
 rkd7...@gmail.com wrote:

 @rahul it will compile perfectly well . note that you have declared
 j in file 1 as extern and used it and have not provided its definition 
 any
 where
 so getting compile error.
 as far as functions are concerned they are external by defaullt as
 specified by @shobhit

 i am attaching your corrected code which runs fine ...
 file1.c


 #includestdio.h
 extern int i;
 //extern int j; // provide a declaration for this
 void next(void);

 int main()
 {
 ++i;
 printf(%d\n,i);

 next();
 getchar();
 }
 int i=3;
 void next()
 {
 ++i;
 printf(%d\n,i);
 //printf(%d,j); // since no defintion provided so getting error
 other();
 }

 file2.c


 extern int i;
 void other()
 {
 ++i;
 printf(%d\n,i);
 }

 if you want to use j u need to provide defintion either in file 1 or
 file 2
 output:
 4
 5
 6




 On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

 can nyone provide me dummy code of how exactly to use extern in c..
 in dev environment

 when i declare int i in one fyl
 and try use use with extern int i in another then it doesnt
 compile..plz coment


 On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

 Then why its not running?


 On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA 
 shobhitgupta1...@gmail.com wrote:

 http://www.geeksforgeeks.org/archives/840

 By default, the declaration and definition of a C function have
 “extern” prepended with them. It means even though we don’t use 
 extern with
 the declaration/definition of C functions, it is present there. For
 example, when we write.

 int foo(int arg1, char arg2);

 There’s an extern present in the beginning which is hidden and
 the compiler treats it as below.


 extern int foo(int arg1, char arg2);


  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

  Pleaase reply with sol as asp

 Fille 1:
  #includestdio.h
 extern int i;

 extern int j;
 void next(void);
 int main()
 {
 ++i;
 printf(%d,i);
 next();
 getchar();
 }
 int i=3;
 void next()
 {
  ++i;
  printf(%d,i);
  printf(%d,j);
 other();
  }
 File 2:
  extern int i;

 void other()
 {
  ++i;
 printf(%d,i)'
 }

 How cum file 1 knows what

Re: [algogeeks] C o/p adobe

2012-11-16 Thread rahul sharma
ok..thnxi got it.your r ryt n i m ryt too:)..thnx

On Fri, Nov 16, 2012 at 11:54 PM, Neeraj Gangwar y.neeraj2...@gmail.comwrote:

 Ignore last to last mail. Sorry. Do show expanded content in last mail.
 On 16 Nov 2012 23:49, Neeraj Gangwar y.neeraj2...@gmail.com wrote:

 Yes, it would be like copying the code in the other file. You have to
 find a way to do it in Dev-C++.
 In linux it's simple. Just use *gcc file1.c file2.c *in terminal (as
 told earlier).

 If you are still confused, Think it this way
 If you are compiling only one file in which you have declared variable as
 intern, where would compiler find its actual definition because you are *not
 compiling *the second file.

 *file1.c : file in which variable is defined*
 *file2.c : file in which variable is declared as extern*
 *
 *
 When you compile both the files together, as compiler sees *extern 
 *declaration,
 it will check if you have defined that variable somewhere. It will only
 check files that are being compiled*. So if you are not compiling *file1.c
 *it will not check that file. That's why you have to compile both the
 files together.

 In simple words, what extern does is that it checks if you have defined
 that variable somewhere* in the code that is *being compiled. *

 Try following codes
 *//start of code*
 *#includestdio.h*
 *main() {*

 *extern int i;*
 *printf(i = %d, i);*
 *return 0;*

 *}*
 *//end of code*
 It will show you an error that variable i has not been defined anywhere
 in the file.
 *
 *
 *//start of code*
 *#includestdio.h*
 *main() {*

 *extern int i;*
 *printf(i = %d, i);*
 *return 0;*

 *}*
 *
 *
 *int i = 7;*
 *// end of code*
 Try above code, it will run and show you the correct result. Your codes
 are doing precisely the same thing.

 *#include file1.c* or *#include file2.c* was based on the same idea.

 *scope rules apply.

 Some lines of *the* book The C Programming Language by Dennis Ritchie:
 There must be only one definition of an external variable among all the
 files *that make up the*
 *source program*; other files may contain extern declarations to access
 it. (There may also be
 extern declarations in the file containing the definition.) Array sizes
 must be specified with
 the definition, but are optional with an extern declaration.


 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Fri, Nov 16, 2012 at 10:52 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 but with adding it willl copy aalll the codewe we dont need to
 copy..if we declare int i in file 1...and include in file 2..then i can use
 it in file 2 with its extern declaration...m i ryt?


 On Fri, Nov 16, 2012 at 2:42 PM, Neeraj Gangwar 
 y.neeraj2...@gmail.comwrote:

 For Dev-C++, you have to include one file in another.
 So either add *#include file1.c *in file2.c and compile file2.c or
 add *#include file2.c *in file1.c and compile file1.c.

 Hope this helps.


 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Fri, Nov 16, 2012 at 9:11 AM, Rahul Kumar Dubey 
 rkd7...@gmail.comwrote:

 @rahulsharma
  file1.c

 #includestdio.h
 extern int i;// defintion provided in this file itself
 extern int j; // definition provided in file2
 void next()
 {
 ++i;
 other();
 }
 int main()
 {
 ++i;
 printf(%d\n,j);
 printf(%d\n,i);
next();
 }
 int i=3;

 // end of file1.c

 file2.c
 extern int i; // declaration of i as extern
 int j=10; // j defined in file2 here which was declared as extern in
 file 1

 void other()
 {
 ++i;
 printf(%d\n,i);
 }
 // end of file2.c

 compile both file together
 as
 rahul@rahul:~gcc file1.c file2.c
 rahul@rahul:~./a.out
 you will get the required output





 On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar 
 y.neeraj2...@gmail.com wrote:

 That's why you are getting the error. You have to compile both the
 files together. Search on google. I don't use dev c++.

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

  No...individually...dev cpp..how to compile both together???


 On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar 
 y.neeraj2...@gmail.com wrote:

 Which compiler are you using ? Are you compiling both the files
 together ?

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730



 On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

 but how can i use extern..if i simply declare a variable in file1
 as int j and try to use in file2 with extern then it shows that j nit
 defined..how cum file2 knows in which file j is definedfor e.g if 
 i use
 extern in file it means that this variable/fxn is defined

Re: [algogeeks] C o/p adobe

2012-11-15 Thread rahul sharma
 No...individually...dev cpp..how to compile both together???

On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar y.neeraj2...@gmail.comwrote:

 Which compiler are you using ? Are you compiling both the files together ?

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730



 On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma rahul23111...@gmail.comwrote:

 but how can i use extern..if i simply declare a variable in file1 as int
 j and try to use in file2 with extern then it shows that j nit defined..how
 cum file2 knows in which file j is definedfor e.g if i use extern in
 file it means that this variable/fxn is defined somewhr else.then what are
 those files in which it searches this variable definition..i m getting
 errorplese give me 2 files in which one files defines variable and
 other uses using extern.its not working for me

 On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey rkd7...@gmail.comwrote:

 @rahul it will compile perfectly well . note that you have declared j in
 file 1 as extern and used it and have not provided its definition any where
 so getting compile error.
 as far as functions are concerned they are external by defaullt as
 specified by @shobhit

 i am attaching your corrected code which runs fine ...
 file1.c


 #includestdio.h
 extern int i;
 //extern int j; // provide a declaration for this
 void next(void);

 int main()
 {
 ++i;
 printf(%d\n,i);

 next();
 getchar();
 }
 int i=3;
 void next()
 {
 ++i;
 printf(%d\n,i);
 //printf(%d,j); // since no defintion provided so getting error
 other();
 }

 file2.c


 extern int i;
 void other()
 {
 ++i;
 printf(%d\n,i);
 }

 if you want to use j u need to provide defintion either in file 1 or
 file 2
 output:
 4
 5
 6




 On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 can nyone provide me dummy code of how exactly to use extern in c..
 in dev environment

 when i declare int i in one fyl
 and try use use with extern int i in another then it doesnt
 compile..plz coment


 On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 Then why its not running?


 On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA 
 shobhitgupta1...@gmail.com wrote:

 http://www.geeksforgeeks.org/archives/840

 By default, the declaration and definition of a C function have
 “extern” prepended with them. It means even though we don’t use extern 
 with
 the declaration/definition of C functions, it is present there. For
 example, when we write.

 int foo(int arg1, char arg2);

 There’s an extern present in the beginning which is hidden and the
 compiler treats it as below.

 extern int foo(int arg1, char arg2);


  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

  Pleaase reply with sol as asp

 Fille 1:
  #includestdio.h
 extern int i;

 extern int j;
 void next(void);
 int main()
 {
 ++i;
 printf(%d,i);
 next();
 getchar();
 }
 int i=3;
 void next()
 {
  ++i;
  printf(%d,i);
  printf(%d,j);
 other();
  }
 File 2:
  extern int i;

 void other()
 {
  ++i;
 printf(%d,i)'
 }

 How cum file 1 knows what is other();as we havnet define with
 extern void other();
 it should be error
 but when i include the statemetn extern void other,then also it
 shows??
 pls provide me o/p of this questiona nd also tell how use use
 variable of one file in other as simply writing extern in a is not 
 accesing
 global a of other file

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




 --
 *RAHUL KUMAR DUBEY*
 *BTech-3rd  year *
 *Computer Science Engineering *
 *Motilal Nehru National Institute Of Technology*
 *Allahabad[211004],UP.*

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

Re: [algogeeks] time complexity of gcd euclid algo(recursive)

2012-11-15 Thread Rahul Kumar Dubey
The complexity is O(h^2) where h is the number of digits in the smaller
number *m* in base 10.


On Tue, Nov 13, 2012 at 3:34 PM, Shruti Gupta fundooshr...@gmail.comwrote:

 hi

 Can anyone help me find out the time complexity of recursive gcd algorithm
 (using euclid's algo)
 i.e. for the following program :

 int gcd(int n,int m) //given nm
 {
if(n%m==0)
return m;
else
 return gcd(m,n%m);

 }

 i think the soln is lg(a*b) but have no idea how..

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




-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 o/p adobe

2012-11-15 Thread Rahul Kumar Dubey
@rahulsharma
 file1.c

#includestdio.h
extern int i;// defintion provided in this file itself
extern int j; // definition provided in file2
void next()
{
++i;
other();
}
int main()
{
++i;
printf(%d\n,j);
printf(%d\n,i);
   next();
}
int i=3;

// end of file1.c

file2.c
extern int i; // declaration of i as extern
int j=10; // j defined in file2 here which was declared as extern in file 1
void other()
{
++i;
printf(%d\n,i);
}
// end of file2.c

compile both file together
as
rahul@rahul:~gcc file1.c file2.c
rahul@rahul:~./a.out
you will get the required output





On Fri, Nov 16, 2012 at 8:27 AM, Neeraj Gangwar y.neeraj2...@gmail.comwrote:

 That's why you are getting the error. You have to compile both the files
 together. Search on google. I don't use dev c++.

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730


 On Thu, Nov 15, 2012 at 11:32 PM, rahul sharma rahul23111...@gmail.comwrote:

  No...individually...dev cpp..how to compile both together???


 On Thu, Nov 15, 2012 at 9:26 PM, Neeraj Gangwar 
 y.neeraj2...@gmail.comwrote:

 Which compiler are you using ? Are you compiling both the files together
 ?

 *Neeraj Gangwar*
 B.Tech. IV Year
 Electronics and Communication IDD
 Indian Institute of Technology Roorkee
 Contact No. : +91 9897073730



 On Thu, Nov 15, 2012 at 9:10 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 but how can i use extern..if i simply declare a variable in file1 as
 int j and try to use in file2 with extern then it shows that j nit
 defined..how cum file2 knows in which file j is definedfor e.g if i use
 extern in file it means that this variable/fxn is defined somewhr else.then
 what are those files in which it searches this variable definition..i m
 getting errorplese give me 2 files in which one files defines variable
 and other uses using extern.its not working for me

 On Thu, Nov 15, 2012 at 12:08 PM, Rahul Kumar Dubey 
 rkd7...@gmail.comwrote:

 @rahul it will compile perfectly well . note that you have declared j
 in file 1 as extern and used it and have not provided its definition any
 where
 so getting compile error.
 as far as functions are concerned they are external by defaullt as
 specified by @shobhit

 i am attaching your corrected code which runs fine ...
 file1.c


 #includestdio.h
 extern int i;
 //extern int j; // provide a declaration for this
 void next(void);

 int main()
 {
 ++i;
 printf(%d\n,i);

 next();
 getchar();
 }
 int i=3;
 void next()
 {
 ++i;
 printf(%d\n,i);
 //printf(%d,j); // since no defintion provided so getting error
 other();
 }

 file2.c


 extern int i;
 void other()
 {
 ++i;
 printf(%d\n,i);
 }

 if you want to use j u need to provide defintion either in file 1 or
 file 2
 output:
 4
 5
 6




 On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

 can nyone provide me dummy code of how exactly to use extern in c..
 in dev environment

 when i declare int i in one fyl
 and try use use with extern int i in another then it doesnt
 compile..plz coment


 On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

 Then why its not running?


 On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA 
 shobhitgupta1...@gmail.com wrote:

 http://www.geeksforgeeks.org/archives/840

 By default, the declaration and definition of a C function have
 “extern” prepended with them. It means even though we don’t use extern 
 with
 the declaration/definition of C functions, it is present there. For
 example, when we write.

 int foo(int arg1, char arg2);

 There’s an extern present in the beginning which is hidden and the
 compiler treats it as below.



 extern int foo(int arg1, char arg2);


  On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma 
 rahul23111...@gmail.com wrote:

  Pleaase reply with sol as asp

 Fille 1:
  #includestdio.h
 extern int i;

 extern int j;
 void next(void);
 int main()
 {
 ++i;
 printf(%d,i);
 next();
 getchar();
 }
 int i=3;
 void next()
 {
  ++i;
  printf(%d,i);
  printf(%d,j);
 other();
  }
 File 2:
  extern int i;

 void other()
 {
  ++i;
 printf(%d,i)'
 }

 How cum file 1 knows what is other();as we havnet define with
 extern void other();
 it should be error
 but when i include the statemetn extern void other,then also it
 shows??
 pls provide me o/p of this questiona nd also tell how use use
 variable of one file in other as simply writing extern in a is not 
 accesing
 global a of other file

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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

Re: [algogeeks] Advice needed

2012-11-14 Thread Rahul Kumar Dubey
modern C does suppport bool
u need to include
*#includestdbool.h *
header
it will work fine as in C++



On Sat, Oct 27, 2012 at 3:21 AM, rahul sharma rahul23111...@gmail.comwrote:

 There is question asked like
 O/p of following in C(32 bit OS)
 #include iostream
  #includestdio.h
 using namespace std;


 bool IsEqual(char * a)
 {
 printf(abc);
 return true;
 }

 int main()
 {
 char str[30];
 printf(%d,sizeof(sizeof(IsEqual(str;
 getchar();
 return 0;
 }
 I run with .cppi know o/p and all in c++...but c doesn't support
 bool.so what should i write in answer as it is asked in written..so wat
 should be writen

 4 i.e the answer in c++ or should i write that c doesn't support bool

 plez comment

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




-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] using name space std

2012-11-14 Thread Rahul Kumar Dubey
using namespace std -- it specify that we want to use whole namespace
named*  std .*

In  std namespace varous objects like cout, cin ,endl etc are define
if we donot  use std namespace then we have to explicitly specify name
namespace in which particular objects are defined
eg. std::couthello world ;
  std::cinx; etc *
for more deatils about namespaces read chapter 10 part 1 (thinking in C++
by bruceckel , very nice explanation )
*


On Tue, Oct 9, 2012 at 8:52 PM, rishabh singh yadav 
rishirocker.sing...@gmail.com wrote:

  namespaces allows us to group a set of global classes, objects and/or
 functions under a name. If you specify *using namespace std* then you
 don't have to put *std::* throughout your code.


 On Tue, Oct 9, 2012 at 7:46 PM, rahul sharma rahul23111...@gmail.comwrote:

 That i know..please tell me its use and need


 On Tue, Oct 9, 2012 at 12:05 AM, Abhishek Patro agbpa...@gmail.comwrote:

 if u have seen the iostream file then it begins like this:-

 #include bits/c++config.h
 #include ostream
 #include istream
 *
 *
 *namespace std *
 {
   /**
*  @name Standard Stream Objects
*
*  The lt;iostreamgt; header declares the eight emstandard stream
*  objects/em.  For other declarations, see
*  http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#10 and
 the
*  @link s27_2_iosfwd I/O forward declarations @endlink
*
*  They are required by default to cooperate with the global C
 library's
*  @c FILE streams, and to be available during program startup and
*  termination.  For more information, see the HOWTO linked to above.
   */
   //@{
   extern istream cin; /// Linked to standard input
   extern ostream cout; /// Linked to standard output
   extern ostream cerr; /// Linked to standard error (unbuffered)

 The new implementation is done in C# format. So we use the term using
 to include the iostream package.



 On Tue, Oct 9, 2012 at 12:01 AM, rahul sharma 
 rahul23111...@gmail.comwrote:

 using name space std

 Please explain about this
 thnx

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




 --
 Abhishek Patro

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 o/p adobe

2012-11-14 Thread Rahul Kumar Dubey
@rahul it will compile perfectly well . note that you have declared j in
file 1 as extern and used it and have not provided its definition any where
so getting compile error.
as far as functions are concerned they are external by defaullt as
specified by @shobhit

i am attaching your corrected code which runs fine ...
file1.c

#includestdio.h
extern int i;
//extern int j; // provide a declaration for this
void next(void);

int main()
{
++i;
printf(%d\n,i);
next();
getchar();
}
int i=3;
void next()
{
++i;
printf(%d\n,i);
//printf(%d,j); // since no defintion provided so getting error
other();
}

file2.c

extern int i;
void other()
{
++i;
printf(%d\n,i);
}

if you want to use j u need to provide defintion either in file 1 or file 2
output:
4
5
6




On Wed, Oct 24, 2012 at 10:56 PM, rahul sharma rahul23111...@gmail.comwrote:

 can nyone provide me dummy code of how exactly to use extern in c..
 in dev environment

 when i declare int i in one fyl
 and try use use with extern int i in another then it doesnt compile..plz
 coment


 On Wed, Oct 24, 2012 at 9:58 PM, rahul sharma rahul23111...@gmail.comwrote:

 Then why its not running?


 On Wed, Oct 24, 2012 at 6:50 PM, SHOBHIT GUPTA 
 shobhitgupta1...@gmail.com wrote:

 http://www.geeksforgeeks.org/archives/840

 By default, the declaration and definition of a C function have “extern”
 prepended with them. It means even though we don’t use extern with the
 declaration/definition of C functions, it is present there. For example,
 when we write.

 int foo(int arg1, char arg2);

 There’s an extern present in the beginning which is hidden and the
 compiler treats it as below.

 extern int foo(int arg1, char arg2);


 On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma 
 rahul23111...@gmail.comwrote:

 Pleaase reply with sol as asp

 Fille 1:
 #includestdio.h
 extern int i;

 extern int j;
 void next(void);
 int main()
 {
 ++i;
 printf(%d,i);
 next();
 getchar();
 }
 int i=3;
 void next()
 {
  ++i;
  printf(%d,i);
  printf(%d,j);
 other();
  }
 File 2:
 extern int i;

 void other()
 {
  ++i;
 printf(%d,i)'
 }

 How cum file 1 knows what is other();as we havnet define with
 extern void other();
 it should be error
 but when i include the statemetn extern void other,then also it shows??
 pls provide me o/p of this questiona nd also tell how use use variable
 of one file in other as simply writing extern in a is not accesing global a
 of other file

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 all inversions in an array

2012-11-14 Thread Rahul Kumar Dubey
@carl barbon
if in worst case to print all inversion it takes O(n^2) why to use merge
sort ot BIT , simply use insertion sort ..


On Wed, Oct 24, 2012 at 12:03 AM, Dipit Grover dipitgro...@gmail.comwrote:

 ^ Exactly!

 Dipit Grover
 B.Tech in Computer Science and Engineering - lVth year
 IIT Roorkee, India



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




-- 
*RAHUL KUMAR DUBEY*
*BTech-3rd  year *
*Computer Science Engineering *
*Motilal Nehru National Institute Of Technology*
*Allahabad[211004],UP.*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] test cases

2012-11-10 Thread rahul

On Oct 17, 2012 2:46 PM, w.s miller wentworth.miller6...@gmail.com
wrote:

 Hi,

 You are given N numbers. You have to perform two kinds of operations:
 U x y - x-th number becomes equal to y.
 Q x y - calculate the sum of distinct numbers from x-th to y-th. It means
 that the sum for the set {1, 2, 3, 2, 7} will be equal to 13 (1+2+3+7).
 Input

 The first line of input contains an integer N. 1=N=5
 The second line consists of N numbers.
 The third line consists of an integer Q. 1=Q=10
 The following Q lines will consist of queries of the form described in the
 task description.
 All numbers in input will fit in the signed 32-bit type.
 Output

 Output an answer for every query of the second type.
 Here is my code .But it is giving the wrong answer.Can anybody suggest me
 the test cases where it is giving Wrong Answer..

 #includestdio.h
 #includemath.h
 int main()
 {
 int list[5],i,n,j,sum,k,l;char c;long t;
 scanf(%d,n);
 for(i=0;in;i++)
 {
 scanf(%d,list[i]);
 }
 scanf(%ld,t);
 while(t)
 {
 sum=0;
 fflush(stdin);
 scanf(%c,c);
 scanf(%d%d,k,l);

 if(c=='Q'  (k=l))
 {
 for(i=k-1;il-1;i++)
 {
 for(j=i+1;jl;j++)
 {
if(list[i]==list[j])
   break;
else if((j==l-1) (list[i]!=list[j]))
{
   sum=sum+list[i];
}
 }
  }
  printf(%d\n,sum+list[l-1]);
  }
  if(c=='U')
  {
  list[k-1]=l;
  }
  t--;
 }
 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] output of the program with explanation

2012-11-05 Thread rahul patil
its because it is integer pointer subtraction, So  subtraction  result will
be divided by integer size.

so 30/4 = 7.

2012/11/6 rajesh pandey rajesh.pandey.i...@gmail.com

 *int *x ,int *y;
 x=(int *) 50;
 y=(int *)20;
 coutx-yendl;

 why the output is 7.*

 --
 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/-/wgVXAzGRgU4J.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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,
Rahul Patil

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Ternary operators

2012-11-01 Thread rahul sharma
I cant get to you..please explain...what will first statement expanded to
during compilation..??.and why 0 is converted to base..i know exp3 is
convertered to exp to..so int to array..???base array comes in int???and
what is 0??what if we have 1 in case of 0?

On Thu, Nov 1, 2012 at 5:20 PM, Saurabh Kumar srbh.ku...@gmail.com wrote:

 There's nothing to do with the type of A String.
 The reason for which the first code gives compilation error is: operator
 () has higher precedence than ternary operator (?:) so, without braces
 your are actually messing up the parsing of coutstream.

 * cout  test ? A String : 0  endl;*

 consider removing the last *endl*. It shall give no compilation error.

 * cout  test ? A String : 0;* // this compiles and runs fine with my
 compiler(g++ 4.5), but as *cout  test* will take precedence, there is
 no point of putting a ternary operator there, unless you use braces, of
 course.


 In teh second case however, reason given is valid:
  i.e. return type of ternary operator is determined by A String and the
 expression 0 will be taken as address of a string location. Hence, there is
 no guarantee of output.


 On 31 October 2012 19:52, rahul sharma rahul23111...@gmail.com wrote:

 plz read carefully


 On Wed, Oct 31, 2012 at 10:18 AM, Tamanna Afroze afroze...@gmail.comwrote:

 sorry for my last post, i didn't look carefully at the code. I think
 without bracket the ternary expression is incomplete, that's why; first
 code doesn't compile correctly.



 On Wed, Oct 31, 2012 at 9:51 AM, Tamanna Afroze afroze...@gmail.comwrote:

 both codes are same. Where is the difference?


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Ternary operators

2012-10-31 Thread rahul sharma
plz read carefully

On Wed, Oct 31, 2012 at 10:18 AM, Tamanna Afroze afroze...@gmail.comwrote:

 sorry for my last post, i didn't look carefully at the code. I think
 without bracket the ternary expression is incomplete, that's why; first
 code doesn't compile correctly.



 On Wed, Oct 31, 2012 at 9:51 AM, Tamanna Afroze afroze...@gmail.comwrote:

 both codes are same. Where is the difference?


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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] BIG O

2012-10-31 Thread rahul sharma
Its nlogn dude

On Wed, Oct 31, 2012 at 8:03 PM, jai gupta jaigupt...@ymail.com wrote:

 is O(long n!)
 n! is O(n^n) by sterling approximation
 hence it is O(log n^n) = O(nlogn)


 On Sun, Oct 28, 2012 at 11:14 PM, Pralay Biswas 
 pralaybiswas2...@gmail.com wrote:

 @ Siddharth :
 Well, here is how you may understand it:
 1) There is an outer loop that runs n times. (k)
 2) Then there is an inner loop where j is initially set to current k, but
 it halves itself in every iteration
   -- So for example, if k is 32, and j halves every time, then
 the inner loop runs for 5 times (32-16-8-4-2 etc)
   -- This is a log base 2 order depreciation in for all k
 3) So for every k, the inner loop runs for log k times. k itself varies
 from 1 to n, hence O(nlogn)

 Hope this helps.

 #Pralay
 MS-CS, UC Irvine

 On Sun, Oct 28, 2012 at 10:38 AM, bharat b 
 bagana.bharatku...@gmail.comwrote:

 while loop : logj base 2 ..
 == log1 + log2 + ... logn = log(n!) [since logab = loga + logb]
 == O(log(n^n)) = O(nlogn)


 On Sun, Oct 28, 2012 at 3:56 AM, Siddharth Malhotra 
 codemalho...@gmail.com wrote:

 Can somebody explain how it is O(n log n).
 What is the significance of while loop in the above code?

 I understand that the for loop implies O(n),does the log n in the O(n
 log n) comes from the while loop?
 What if there where two while loops in the for loop separately?

 On Sat, Oct 27, 2012 at 3:26 AM, Pralay Biswas 
 pralaybiswas2...@gmail.com wrote:

 Yes!


 On Fri, Oct 26, 2012 at 2:55 PM, rahul sharma rahul23111...@gmail.com
  wrote:

 for k=1 to n
 {
 j=k;
 while(j0)
 j=j/2;
 }
 the complexity is big o is o(nlogn)
 am i ryt

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.


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




 --

 kriateive

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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] Extern in c

2012-10-31 Thread rahul sharma
How actually to use extern

suppose in file 1 i write code..(test_new.c)

#include stdio.h

 #includemath.h

 int interest_rate =5;
int main()
{
   int test = 0;
   int t=5;
  // coutceil(log2(5));//
//  coutpow(2,ceil(log2(5)));

 getchar();
   return 0;
}

In file 2 i write

#includestdio.h
#includetest_new.c
extern int interest_rate;
void fun()
{
interest_rate=6;
}

it works..
now if i make interest_rate as static in c..it also wokrs in file 2..but it
should not...and if i remove the declaration of interest from file 2 it
also works...all this happening becoz i #included test_new.c(file1) in
file2so i definition comes in a...plz tell how to tell fille 2 to refer
file 1...as by #inlcuded resultsare not as accepted...itz full code coming
in file a...i want that

global variable is accessible in file 2 but for static it shows that itz an
undefined referenceplz provide me code snippet..

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Informatica written que : C output

2012-10-31 Thread Rahul Kumar Patle
@shivam: but when i replace
printf(Hello); by printf(Hello\n);
it works correctly.. can you justify this by your logic..


On Wed, Oct 31, 2012 at 1:07 PM, Shivam Rohilla 
rohillashivam.jade...@gmail.com wrote:

 Yes it will print 30+ times.
 fork() -- it's create the the child process which copie's the address
 stack of the parent process.
 now when you will do fork();
 look 1st iteration -- it wil break; ( if parent process scheduled 1st by
 the kernel )
 when 2nd iteration -- it will again fork in child process. and will print
 hello once and dan goes to parent dan break.
 when 3rd iteration --  it will fork again and print hello twice and dan
 break
 when 4th iteration -- it will again fork and prnt hello 4 times i.e.
 hello once by iteration and dan fork child will start process from start
 and dan print hello 3 more times and dan parent will schedule and dan break.
 and so on...

 On 31 October 2012 11:49, tendua bharat.kra...@gmail.com wrote:

 \n also flushes the standard output buffer. If it is not present, it is
 possible that you have previously entered data in it. Flushing also means
 it forces printf to print on the screen as soon as \n is processed.
 Otherwise it is buffered output and you can never predict how long would OS
 buffer your output and when precisely it chooses to actually print.

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

 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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 and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] You are given two 32-bit numbers, N and M, and two bit positions, i and j.

2012-10-31 Thread rahul sharma
You are given two 32-bit numbers, N and M, and two bit positions, i and j.
Write a method to set all bits between i and j in N equal to M (e.g., M
becomes a substring of N located at i and starting at j).
EXAMPLE:
Input: N = 100, M = 10101, i = 2, j = 6
Output: N = 10001010100

Following is code...guys i think that in line no. 5  (1j) this should be
replaced with (1j+1).means we have to shift 1 left by j+1 bits..Line no.
5 should be
 int left = max - ((1  j+1) - 1);
plz comment ???

public static int updateBits(int n, int m, int i, int j) {
2 int max = ~0; /* All 1’s */
3
4 // 1’s through position j, then 0’s
5 int left = max - ((1  j) - 1);
6
7 // 1’s after position i
8 int right = ((1  i) - 1);
9
10 // 1’s, with 0s between i and j
11 int mask = left | right;
12
13 // Clear i through j, then put m in there
14 return (n  mask) | (m  i);
15 }

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Complicated declaration C

2012-10-30 Thread rahul sharma
void(*f)(void(*)(int*,void **),int(*)(void**,int*));


f is a fxn pointer to fxn which takes 2 args and teturn nothing

2 arguments are

1. pointer to function which returns nothing and takes 2 args one pointer
to int and pointer to pointer to void
2. pointer to fxn returning int and takes 2 args as pointer to void pointer
and pointer to int..


This is as per me but in book highlighted int above in red as 2 argument is
replaced by int*..so i wana ask whether 2 argument returning int pointer or
int ..Accoring to me its int..please reply asap

Thnx

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Informatica written que : C output

2012-10-30 Thread Rahul Kumar Patle
can anyone explain the reason for weird output producing by this code..
it is giving output hello many time 30 but as code's logic it should print
only 9 time
it runs correctly when i comment out statements inside else{}
thanks in advance

#includestdio.h
#includestdlib.h
int count = 0;
main()
{
int tmp[10] , i;
int n = 0;
for(i=0;i9;i++)
{
tmp[i]=fork();
if(tmp[i]0)
break;
else
{
//count++;
printf(Hello);
//printf( %d - %d \n , tmp[i], count);
}
}
}

-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Pre/Post L and r value

2012-10-30 Thread rahul sharma
@saurabh..thnxplz provide me code snippet for pre increment also..it
will help a lot..i can guess it will do n++ and return itself..plz give
code snippet...

On Mon, Oct 29, 2012 at 10:50 AM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 Post increment returns temp object because it has to return the old value
 of object not the new incremented one:
 Simply put, the code for post increment somewhat goes like this:

 int operator++ (int n){
  int temp = n;
 n = n+1;
 return temp;
 }

 that's also the reason you cannot use it as a lvalue in an exprression, as
 you would be assigning nowhere.

 On 27 October 2012 20:09, rahul sharma rahul23111...@gmail.com wrote:

 But y post returns temp. object


 On Fri, Oct 26, 2012 at 8:18 PM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 i++: Post increment can't be a lvalue because Post increment internally
 returns a temporary object (NOT the location of i) hence you cannot assign
 anything to it. The result of i++ can be used only as a rvalue.
  ++i: whereas, in Pre-increment  value gets incremented and the same
 location is returned back to you, hence can be used as lvalue in an
 expression.(C++ allows this)
 Both can be used as rvalues though.

 On 26 October 2012 18:54, rahul sharma rahul23111...@gmail.com wrote:

  why pre inc. is l value and post is r value..please explain

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


  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] Re: #in macros

2012-10-30 Thread rahul sharma
ossam link...thnx..vikram

On Tue, Oct 30, 2012 at 3:20 PM, Vikram Pradhan vpradha...@gmail.comwrote:

 Macro arguments are scanned and expanded before the substitution in macro
 body unless they are convert to a string representation (using #) or
 concatenated with other tokens (using ##).

 Xstr(oper)  = Xstr(multiply) =str(multiply)=multiply// in
 Xstr(x) , x is a simple argument so it will expand fully

 str(oper)=oper// in str(x) , x is converting to string so it
 will not get expanded

 check this link :
 http://gcc.gnu.org/onlinedocs/cpp/Argument-Prescan.html#Argument-Prescan




 On Sun, Oct 28, 2012 at 3:28 PM, rahul sharma rahul23111...@gmail.comwrote:

 And when char *opername=str(oper);

 then o/p is operwhy behaviour is diff. in 2 cases

 On Sun, Oct 28, 2012 at 2:53 PM, rahul sharma rahul23111...@gmail.comwrote:

 #includestdio.h
 #include str(x) #x
 #define Xstr(x) str(x)
 #define oper multiply


 int main()
 {
 char *opername=Xstr(oper);
 printf(%s,opername);
 }
 so firstly Xstr is expanded to str(oper)
 then str(oper) is expanded to #oper now i have read that

 If, however, a parameter name is preceded by a # in the replacement
 text, the
 combination will be expanded into a quoted string with the parameter
 replaced by the actual argument...and in this case actual is also oper so
 it becomes oper...so it should print oper .i thnik i am mistaken
 anyhre...correct???


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




 --
 Vikram Pradhan | B.Tech| Computer Science  Engineering | NIT Jalandhar  |
  9740186063 |

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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] C Macro

2012-10-30 Thread rahul sharma
Yeah its working...actually it was written in book...and i did nt
compilemistake of author

On Tue, Oct 30, 2012 at 12:17 PM, Vikram Pradhan vpradha...@gmail.comwrote:

 @rahul : dude it's working fine ...check your printf() statement you
 are swapping the pointers and printing the original float values of a and x
 it should be printf(%f%f,*p,*q);

 or if you want to swap float values not the pointers then it should be
 swap(a,x,float);
 printf(%f%f,a,x);


 On Mon, Oct 29, 2012 at 11:30 PM, atul anand atul.87fri...@gmail.comwrote:

 well they should not , if you see it closely  pointer p and q
 contain contain address of a and x.
 and swap() macro will swap value these pointers are holding i.e adress
 of a and xbut will it reflect address of a and x ???...NO
 so if you print the address p and q ...before and after the swap then
 you should see that after swap p will be holding address of x and
 q will be holding address of a..that it

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  I have taken form book...i am writing exact code
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t;
 
 
  int main()
  {
  float a,x;
  a=20.0;
  x=30.0;
  float *p,*q;
  p=a,q=x;
  swap(p,q,float*);
  printf(%f %f,a,x);
  getchar();
  }
 
  o/p=20.000 30.000
 
 
  why not swapped???
  On Mon, Oct 29, 2012 at 11:01 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  if you think the your expanded version is incorrect.You are wrong ,
  because int * will hold pointer but you are not allocating address of
  x ..instead you are allocating x value as an address of x to *t.This
  wont work.
  so to make it work you need to save the address of x and y in temp
  pointers i.e
 
 int *p.*q;
  p=x;
  q=y;
  int t;
  t=*p;
  *p=*q;
  *q=t;
  now you can convert it into macro.
 
  On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
   @atul...mistakenly  i have put w at place of t in my last post...i
 wana
  say
  
  
  
   On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com
 wrote:
  
   Just replace your macro with its definition and you will understand.
  
   its not doing swapping of pointers...plz explain
  
  
  
   @dCode i expanded..but its fine...please tell
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
   int main
   int x=10,y=20;
   int *p,*q;
   swap(x,y,int*);
  
   int * t;
   t=x;
   x=y;
   y=t;
  
  
   There is int* at the end..there is som problem with my
   keyborad...:(.acc to me axpanded version is above..but not
  swapping
   two pointerssplz comment
  
  
  
  
   On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
   rahul23111...@gmail.comwrote:
  
   its now doing swapping of pointers...plz explain
  
  
   On Sun, Oct 28, 2012 at 8:08 PM, atul anand
   atul.87fri...@gmail.comwrote:
  
   it should swap
  
   On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
Why the following code is not able to swap two macros???although
it
is
easily swapping 2 variables
   
#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t
   
   
int main
   
   
int x=10,y=20;
int *p,*q;
   
swap(x,y,int);
   
--
You received this message because you are subscribed to the
 Google
   Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com
 .
To unsubscribe from 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.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from this group, send email to
   algogeeks+unsubscr...@googlegroups.com

Re: [algogeeks] Re: Repeated values

2012-10-30 Thread rahul sharma
Can we modify the array???we can make index we visit as negative and then
if any one already containing -ve..then its repeating

On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:

 Does your algorithm work if N=4 and the array is {1,1,2,2}.

 Don

 On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
  if sum of all elements = n(n-1)/2 , no elements are repeated
  else some numbers are repeated
 
 
 
 
 
 
 
  On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
   Given an array of N integers in the range 0..N-1, determine if any
   number is repeated in the array.
   Solution should execute in O(n) time and use constant space.
   Don
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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] Re: Repeated values

2012-10-30 Thread rahul sharma
i thnik this is the solution...
http://www.geeksforgeeks.org/archives/9755

On Wed, Oct 31, 2012 at 2:20 AM, Don dondod...@gmail.com wrote:

 We can modify the array. The algorithm should work even if we use
 unsigned integers and N is the largest unsigned integer.

 Don

 On Oct 30, 4:42 pm, rahul sharma rahul23111...@gmail.com wrote:
  Can we modify the array???we can make index we visit as negative and then
  if any one already containing -ve..then its repeating
 
 
 
 
 
 
 
  On Wed, Oct 31, 2012 at 1:40 AM, Don dondod...@gmail.com wrote:
   Does your algorithm work if N=4 and the array is {1,1,2,2}.
 
   Don
 
   On Oct 30, 2:32 pm, arumuga abinesh arumugaabin...@gmail.com wrote:
if sum of all elements = n(n-1)/2 , no elements are repeated
else some numbers are repeated
 
On Tue, Oct 30, 2012 at 11:57 PM, Don dondod...@gmail.com wrote:
 Given an array of N integers in the range 0..N-1, determine if any
 number is repeated in the array.
 Solution should execute in O(n) time and use constant space.
 Don
 
 --
 You received this message because you are subscribed to the Google
   Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



Re: [algogeeks] C Macro

2012-10-29 Thread rahul sharma
@atul...mistakenly  i have put w at place of t in my last post...i wana say



On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote:

 Just replace your macro with its definition and you will understand.

 its not doing swapping of pointers...plz explain



@dCode i expanded..but its fine...please tell

 #includestdio.h
 #define swap(a,b,c) c t;t=a,a=b,b=t

 int main
 int x=10,y=20;
 int *p,*q;
 swap(x,y,int*);

int * t;
t=x;
x=y;
y=t;


There is int* at the end..there is som problem with my
keyborad...:(.acc to me axpanded version is above..but not swapping
two pointerssplz comment




 On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma rahul23111...@gmail.comwrote:

 its now doing swapping of pointers...plz explain


 On Sun, Oct 28, 2012 at 8:08 PM, atul anand atul.87fri...@gmail.comwrote:

 it should swap

 On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
  Why the following code is not able to swap two macros???although it is
  easily swapping 2 variables
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t
 
 
  int main
 
 
  int x=10,y=20;
  int *p,*q;
 
  swap(x,y,int);
 
  --
  You received this message because you are subscribed to the Google
 Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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 Macro

2012-10-29 Thread rahul sharma
I have taken form book...i am writing exact code

#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t;


int main()
{
float a,x;
a=20.0;
x=30.0;
float *p,*q;
p=a,q=x;
swap(p,q,float*);
printf(%f %f,a,x);
getchar();
}

o/p=20.000 30.000


why not swapped???
On Mon, Oct 29, 2012 at 11:01 PM, atul anand atul.87fri...@gmail.comwrote:

 if you think the your expanded version is incorrect.You are wrong ,
 because int * will hold pointer but you are not allocating address of
 x ..instead you are allocating x value as an address of x to *t.This
 wont work.
 so to make it work you need to save the address of x and y in temp
 pointers i.e

int *p.*q;
 p=x;
 q=y;
 int t;
 t=*p;
 *p=*q;
 *q=t;
 now you can convert it into macro.

 On 10/29/12, rahul sharma rahul23111...@gmail.com wrote:
  @atul...mistakenly  i have put w at place of t in my last post...i wana
 say
 
 
 
  On Mon, Oct 29, 2012 at 10:07 AM, dCoder bansal@gmail.com wrote:
 
  Just replace your macro with its definition and you will understand.
 
  its not doing swapping of pointers...plz explain
 
 
 
  @dCode i expanded..but its fine...please tell
 
  #includestdio.h
  #define swap(a,b,c) c t;t=a,a=b,b=t
 
  int main
  int x=10,y=20;
  int *p,*q;
  swap(x,y,int*);
 
  int * t;
  t=x;
  x=y;
  y=t;
 
 
  There is int* at the end..there is som problem with my
  keyborad...:(.acc to me axpanded version is above..but not
 swapping
  two pointerssplz comment
 
 
 
 
  On Sun, Oct 28, 2012 at 9:16 PM, rahul sharma
  rahul23111...@gmail.comwrote:
 
  its now doing swapping of pointers...plz explain
 
 
  On Sun, Oct 28, 2012 at 8:08 PM, atul anand
  atul.87fri...@gmail.comwrote:
 
  it should swap
 
  On 10/28/12, rahul sharma rahul23111...@gmail.com wrote:
   Why the following code is not able to swap two macros???although it
   is
   easily swapping 2 variables
  
   #includestdio.h
   #define swap(a,b,c) c t;t=a,a=b,b=t
  
  
   int main
  
  
   int x=10,y=20;
   int *p,*q;
  
   swap(x,y,int);
  
   --
   You received this message because you are subscribed to the Google
  Groups
   Algorithm Geeks group.
   To post to this group, send email to algogeeks@googlegroups.com.
   To unsubscribe from 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.
 
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from 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.



[algogeeks] C Macro

2012-10-28 Thread rahul sharma
Why the following code is not able to swap two macros???although it is
easily swapping 2 variables

#includestdio.h
#define swap(a,b,c) c t;t=a,a=b,b=t


int main


int x=10,y=20;
int *p,*q;

swap(x,y,int);

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: #in macros

2012-10-28 Thread rahul sharma
And when char *opername=str(oper);

then o/p is operwhy behaviour is diff. in 2 cases

On Sun, Oct 28, 2012 at 2:53 PM, rahul sharma rahul23111...@gmail.comwrote:

 #includestdio.h
 #include str(x) #x
 #define Xstr(x) str(x)
 #define oper multiply


 int main()
 {
 char *opername=Xstr(oper);
 printf(%s,opername);
 }
 so firstly Xstr is expanded to str(oper)
 then str(oper) is expanded to #oper now i have read that

 If, however, a parameter name is preceded by a # in the replacement text,
 the
 combination will be expanded into a quoted string with the parameter
 replaced by the actual argument...and in this case actual is also oper so
 it becomes oper...so it should print oper .i thnik i am mistaken
 anyhre...correct???


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



[algogeeks] Re: LCA in BST

2012-10-28 Thread rahul sharma
how about this:-
int leastCommanAncestor(struct node* root, int n1, int n2)
{
 if(root==NULL)
 return -1;
 if(root-datan1  root-datan2)
 return leastCommanAncestor(root-left,n1,n2);
 else if(root-datan1  root-datan2)
 return leastCommanAncestor(root-right,n1,n2);
 return root-data;

}
correct if wrng

On Sun, Oct 28, 2012 at 9:40 PM, rahul sharma rahul23111...@gmail.comwrote:

 According to wiki http://en.wikipedia.org/wiki/Least_common_ancestor

 n1 is parent of n2 then n1 is lcabut according to above algo return
 -1..i have taken it from(http://www.geeksforgeeks.org/archives/1029)

 plz tell if it is corerctin 2 doubts

 1. if n1is parent of n2
 2. if n2n1

 will above algo works???I think No.

 So will add the one more condtion for n2n1..but do we require to return
 -1 if n2 is child of n1 ???or n1 itself?


 On Sun, Oct 28, 2012 at 9:25 PM, rahul sharma rahul23111...@gmail.comwrote:

 an one doubt that if we have to find lca of n1 and n2...then if say n1 is
 parent of n2..in this case we would return n1 or n1-parent.


 and if n1 is the root and n1 is child then(n1 has no parent)..we will
 return n1  or -1


 On Sun, Oct 28, 2012 at 9:18 PM, rahul sharma rahul23111...@gmail.comwrote:

 I think th efollowing code lacks one statement i.e   if(root-datan1 
 root-data n2)
 Correct me if wrng
 int leastCommanAncestor(struct node* root, int n1, int n2)
  {

if(root == NULL || root-data == n1 || root-data == n2)
  return -1;


   if((root-right != NULL) 
  (root-right-data == n1 || root-right-data == n2))
  return root-data;
if((root-left != NULL) 
  (root-left-data == n1 || root-left-data == n2))
  return root-data;

if(root-data  n1  root-data  n2)
  return root-data;
if(root-data  n1  root-data  n2)
  return leastCommanAncestor(root-left, n1, n2);
if(root-data  n1  root-data  n2)
  return leastCommanAncestor(root-right, n1, n2);
  }





-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
 ..i under stand with 6!/(3!*3!) method...
plz explain from combination point of viewi didnt get ur last linei
understand that

we need to find no. of permutaions of abcxyz s.t abc and xyz.plz
tell how to find thisi understand as someone explained above with
VVVHHH method.
please explain from thsi view that

we need to find no. of permutaions of abcxyz s.t abc and xyz.


On Sat, Oct 27, 2012 at 12:31 PM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 Since this is a small grid you can count it manually but in general
 problem is to count no. of paths from bottom-left corner to top-right
 corner (provided all the transition alphabets in the automata are distinct
 in the respective dimensions e.g. here,  xyz in one  dimension and abc in
 other)

 You can view this problem as writing all permutations of strings of 3R's
 and 3U's (for RIGHT movement and UP movement) RRRUUU which will take you to
 the top right most corner.
 All possible arrangements = (3+3)! / (3! * 3!)
 In general: (m+n)! / (m! * n!) for a mxn grid.


 On 27 October 2012 11:05, rahul sharma rahul23111...@gmail.com wrote:

 should i take it how many ways are there to reach from start to  the top
 right destination...x,y,z,a,b,c, are i/p statexyzabc one stringabc
 xyz is another...if m ryt then is dere any formulla to calute or we have to
 do it manuall


 On Sat, Oct 27, 2012 at 11:02 AM, rahul sharma 
 rahul23111...@gmail.comwrote:


 can u please elaborate...i am not able to understand the figure..plz
 explainit would be of great help

 On Sat, Oct 27, 2012 at 5:57 AM, payal gupta gpt.pa...@gmail.comwrote:

 should be 6C3 or 20 perhaps.

 On Sat, Oct 27, 2012 at 3:29 AM, rahul sharma 
 rahul23111...@gmail.comwrote:

 Finite state automata accpt string of length 6

 what is total number of strings in set..please find the attahcment

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Pre/Post L and r value

2012-10-27 Thread rahul sharma
But y post returns temp. object

On Fri, Oct 26, 2012 at 8:18 PM, Saurabh Kumar srbh.ku...@gmail.com wrote:

 i++: Post increment can't be a lvalue because Post increment internally
 returns a temporary object (NOT the location of i) hence you cannot assign
 anything to it. The result of i++ can be used only as a rvalue.
 ++i: whereas, in Pre-increment  value gets incremented and the same
 location is returned back to you, hence can be used as lvalue in an
 expression.(C++ allows this)
 Both can be used as rvalues though.

 On 26 October 2012 18:54, rahul sharma rahul23111...@gmail.com wrote:

 why pre inc. is l value and post is r value..please explain

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


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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] Sequence Point C with postincremented

2012-10-27 Thread rahul sharma
so it means after sequence point the post increment is done...after  ht
epost increment is incremented and value is reflected...m i ryt?

On Fri, Oct 26, 2012 at 8:43 PM, Saurabh Kumar srbh.ku...@gmail.com wrote:

 You're right ,  || all introduce a sequence point. In first case
 evaluation proceeds like this:
 j = (i++, i++);
   *i++* Post increment the i (i is now 11)
   *j = i++* Post increment the i (j is assigned 11 and i is now 12)

 In second case, the whole of rvalue for = operator will be evaluated
 first...
 j = a++  1;
  *a++ *a is Post incremented (a is now 1 but return value is 0)
  *0  1* = 0 (which gets assigned to j)
 Hence, j = 0, a = 1

 On 26 October 2012 18:54, rahul sharma rahul23111...@gmail.com wrote:

 Guys plz tell that postincremented variable is  incremented after
 sequence or after ;

 as we have  || comma and ; as sequence point

 so say we have
 int i=10;
 int j=(i++,i++);
 firstly i++ goes and as comma comes so ++ post inc. takes place and take
 to 11 ..now when next time the postincremented is done later after ;  and
 firstly the value 11 is assigned to j

 so after this statement we have j=11,i=12

 but if i write
 int a=0;
 int j=a++1;
 so when  comes so postincrement takes place and assign this to j...so
 at the point we reach  acc. to me a=1..But a remains 0 as this expression
 goes to false...can anybody tell me y so happens..when does the value in
 postincremented is incremented...i am sure about comm and ;...but what in
 case of  and  ||these are also sequence point...y post increment
 doesnt take place when we reach ...please explain..

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


  --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
plz help mei am thinking this the following way..
we need to find no. of permutaions of abcxyz s.t abc and xyz..
means we need to form string of 6 length s.t abc and xyz

means we have 6 places
a- can be placed at 4/6 locations
b- can be palced at 4/6 locations
c-can be placed at 4/6 locations

can we do like this?


On Sat, Oct 27, 2012 at 8:04 PM, rahul sharma rahul23111...@gmail.comwrote:

  ..i under stand with 6!/(3!*3!) method...
 plz explain from combination point of viewi didnt get ur last
 linei understand that

 we need to find no. of permutaions of abcxyz s.t abc and xyz.plz
 tell how to find thisi understand as someone explained above with
 VVVHHH method.
 please explain from thsi view that

 we need to find no. of permutaions of abcxyz s.t abc and xyz.


 On Sat, Oct 27, 2012 at 12:31 PM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 Since this is a small grid you can count it manually but in general
 problem is to count no. of paths from bottom-left corner to top-right
 corner (provided all the transition alphabets in the automata are distinct
 in the respective dimensions e.g. here,  xyz in one  dimension and abc in
 other)

 You can view this problem as writing all permutations of strings of 3R's
 and 3U's (for RIGHT movement and UP movement) RRRUUU which will take you to
 the top right most corner.
 All possible arrangements = (3+3)! / (3! * 3!)
 In general: (m+n)! / (m! * n!) for a mxn grid.


 On 27 October 2012 11:05, rahul sharma rahul23111...@gmail.com wrote:

 should i take it how many ways are there to reach from start to  the top
 right destination...x,y,z,a,b,c, are i/p statexyzabc one stringabc
 xyz is another...if m ryt then is dere any formulla to calute or we have to
 do it manuall


 On Sat, Oct 27, 2012 at 11:02 AM, rahul sharma 
 rahul23111...@gmail.comwrote:


 can u please elaborate...i am not able to understand the figure..plz
 explainit would be of great help

 On Sat, Oct 27, 2012 at 5:57 AM, payal gupta gpt.pa...@gmail.comwrote:

 should be 6C3 or 20 perhaps.

 On Sat, Oct 27, 2012 at 3:29 AM, rahul sharma rahul23111...@gmail.com
  wrote:

 Finite state automata accpt string of length 6

 what is total number of strings in set..please find the attahcment

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.




-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Finite state automata accpt string of length 6

2012-10-27 Thread rahul sharma
@payalplz explain how to slect 3 spaces for a.b.c out of 6.
we need to put them in orderso look my aboyve post and plz comment

On Sat, Oct 27, 2012 at 8:14 PM, rahul sharma rahul23111...@gmail.comwrote:

 plz help mei am thinking this the following way..

 we need to find no. of permutaions of abcxyz s.t abc and xyz..
 means we need to form string of 6 length s.t abc and xyz

 means we have 6 places
 a- can be placed at 4/6 locations
 b- can be palced at 4/6 locations
 c-can be placed at 4/6 locations

 can we do like this?


 On Sat, Oct 27, 2012 at 8:04 PM, rahul sharma rahul23111...@gmail.comwrote:

  ..i under stand with 6!/(3!*3!) method...
 plz explain from combination point of viewi didnt get ur last
 linei understand that

 we need to find no. of permutaions of abcxyz s.t abc and xyz.plz
 tell how to find thisi understand as someone explained above with
 VVVHHH method.
 please explain from thsi view that

 we need to find no. of permutaions of abcxyz s.t abc and xyz.


 On Sat, Oct 27, 2012 at 12:31 PM, Saurabh Kumar srbh.ku...@gmail.comwrote:

 Since this is a small grid you can count it manually but in general
 problem is to count no. of paths from bottom-left corner to top-right
 corner (provided all the transition alphabets in the automata are distinct
 in the respective dimensions e.g. here,  xyz in one  dimension and abc in
 other)

 You can view this problem as writing all permutations of strings of 3R's
 and 3U's (for RIGHT movement and UP movement) RRRUUU which will take you to
 the top right most corner.
 All possible arrangements = (3+3)! / (3! * 3!)
 In general: (m+n)! / (m! * n!) for a mxn grid.


 On 27 October 2012 11:05, rahul sharma rahul23111...@gmail.com wrote:

 should i take it how many ways are there to reach from start to  the
 top right destination...x,y,z,a,b,c, are i/p statexyzabc one
 stringabc xyz is another...if m ryt then is dere any formulla to calute
 or we have to do it manuall


 On Sat, Oct 27, 2012 at 11:02 AM, rahul sharma rahul23111...@gmail.com
  wrote:


 can u please elaborate...i am not able to understand the figure..plz
 explainit would be of great help

 On Sat, Oct 27, 2012 at 5:57 AM, payal gupta gpt.pa...@gmail.comwrote:

 should be 6C3 or 20 perhaps.

 On Sat, Oct 27, 2012 at 3:29 AM, rahul sharma 
 rahul23111...@gmail.com wrote:

 Finite state automata accpt string of length 6

 what is total number of strings in set..please find the attahcment

 --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.





-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Fork in c

2012-10-27 Thread rahul sharma
text 1 remains in buffer...nowwhen child reaches print f.it prints
oldbuffer+newdata...m i ryt???

On Sat, Oct 27, 2012 at 4:07 PM, saurabh singh saurab...@gmail.com wrote:

 printf is line buffered. hence text1 remains in buffer when fork is
 called.this is shared by both the child and the parent when fork is called.
 Leaving the rest for u to conclude

 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT
 blog:geekinessthecoolway.blogspot.com



 On Sat, Oct 27, 2012 at 2:25 PM, CHIRANJEEV KUMAR 
 cse.chiranj...@gmail.com wrote:

 I think the output should be :

 text1text2
 text2





 On Sat, Oct 27, 2012 at 2:22 PM, rahul sharma rahul23111...@gmail.comwrote:

 int main()  {
 printf(text1);
 fork();
 printf(text2\n);
 return 0;  }

  the output  is:

 text1text2
 text1text2

 Please explain o/p

  --
 You received this message because you are subscribed to the Google
 Groups Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.



[algogeeks] Pre/Post L and r value

2012-10-26 Thread rahul sharma
why pre inc. is l value and post is r value..please explain

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



[algogeeks] BIG O

2012-10-26 Thread rahul sharma
for k=1 to n
{
j=k;
while(j0)
j=j/2;
}
the complexity is big o is o(nlogn)
am i ryt

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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   3   4   5   6   7   8   9   >