Re: [algogeeks] Re: perfect square condition checking....

2013-02-07 Thread Prem Krishna Chettri
Yea Dave .. I was actually looking for your response.. Coz it generally
have some mathematical background. So, Could U provide us some least
Complexity Algo for this same old general and basic problem.


On Thu, Feb 7, 2013 at 11:08 AM, Dave  wrote:

> @Gaurav: Does it work for n = 25 or for n = 8? I think you've confused
> "perfect square" with "power of two."
>
> Dave
>
> On Wednesday, February 6, 2013 11:32:55 PM UTC-6, Gaurav Rana wrote:
>
>> if(n&(n-1)==0)
>> //perfect square
>>
>>
>> On Thu, Feb 7, 2013 at 3:01 AM, Don  wrote:
>>
>>> The following is a bit faster than the Newton's Method solution I
>>> suggest above. It uses a binary square root algorithm as seen here:
>>> http://en.wikipedia.org/wiki/**Methods_of_computing_square_**
>>> roots#Binary_numeral_system_.**28base_2.29
>>> The value is a perfect square if x ends up being zero.
>>>
>>> bool isSqr(unsigned int x)
>>> {
>>>unsigned int res = 0;
>>>unsigned int bit = 1 << 30;
>>>while(bit > x) bit >>= 2;
>>>while(bit)
>>>{
>>>   if (x >= res + bit)
>>>   {
>>>  x -= res + bit;
>>>  res = (res >> 1) + bit;
>>>   }
>>>   else
>>>   {
>>>  res >>= 1;
>>>   }
>>>   bit >>= 2;
>>>}
>>>return (x == 0);
>>> }
>>>
>>> On Dec 23 2012, 10:37 am, Anil Sharma 
>>> wrote:
>>> > please suggest some efficient solution to check perfect square
>>> condition .
>>> > no matter how much large number is... eg..i/p-8949 o/p-93
>>>
>>> --
>>> 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+...@**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.




Re: [algogeeks] size of array

2013-02-03 Thread Prem Krishna Chettri
No We cannot use that information.. Reason
1> That is implantation of the compiler dependent and moreover is NOT
expose.
2> When we use malloc to allocate memory in heap. its the base address of
the value we get.. and incase of array there is no way you are restricted
to put your values beyond your allocated size ..

On Fri, Feb 1, 2013 at 12:03 AM, Abhirup Ghosh  wrote:

> When malloc allocates memory it assigns a size field in the header to
> indicate the size of the memory it allocates at a stretch. Can we not use
> this information effectively?
> On Jan 31, 2013 11:44 PM, "Piyush"  wrote:
>
>>  it will always work if array is statically allocated
>> Not if dynamically allocated, say using malloc etc.
>>
>> On 30-Jan-13 1:55 PM, Prem Krishna Chettri wrote:
>>
>> @Piyush .. Never works..
>>
>>@All  there is no way to do the given requirement in pure C.
>>
>> On Wed, Jan 30, 2013 at 1:45 PM, Piyush  wrote:
>>
>>>  sizeof(array)/sizeof(array[0])
>>>
>>>
>>> On 28-Jan-13 3:44 PM, Anil Sharma wrote:
>>>
>>>  How to calculate the size/lenght of an int array which is passed as an
>>> ONLY argument to a function??? --
>>> 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.
>>
>>
>>
>>
>>  --
>> 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.




Re: [algogeeks] size of array

2013-01-30 Thread Prem Krishna Chettri
@Piyush .. Never works..

  @All  there is no way to do the given requirement in pure C.

On Wed, Jan 30, 2013 at 1:45 PM, Piyush  wrote:

>  sizeof(array)/sizeof(array[0])
>
>
> On 28-Jan-13 3:44 PM, Anil Sharma wrote:
>
>  How to calculate the size/lenght of an int array which is passed as an
> ONLY argument to a function??? --
> 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.




Re: [algogeeks] Pointers Usage

2013-01-02 Thread Prem Krishna Chettri
I donno what and why are you talking about.

 Follow the advise and learn the way , you want to. Coz, things are
there where we NEED pointer, its not a additional luxury we have in
programming lang, its the necessity.  So if some body wanna turn their head
off bcoz its complex, hard than there are alternative lang like Java but
when and if people are involved in project which are core technology and
they are genuine engineer, than they cannot keep ourself off from this.




On Wed, Jan 2, 2013 at 12:51 PM, shady  wrote:

> it is advised to avoid using pointers because of the overhead of accessing
> different blocks of memory. Apart from that it also results in more space
> consumption.
>
> On Wed, Jan 2, 2013 at 11:23 AM, Prem Krishna Chettri 
> wrote:
>
>> Boss.. thats kinda bit basic to ask anyways.. lemme give bit of details.
>>
>> Languages with pointer have WAY more flexibility to write a code upto any
>> segment (I mean lower layer of programming like Device Driver) as they are
>> directly talking to memory, where as if we don't have pointer we need to
>> take a help of mechanism other than pointer to talk with raw memory.
>>
>>So, basically, U can say that pointer are the basic back bone of
>> memory management in any language. Infact, If U use Java and Say if don't
>> have pointer that U are wrong , even java use pointer's but in background
>> with the help of JVM.
>>
>>  As far as my expr is concern, with pointer lang is easy to learn and
>> code but in long run you will loose the charm of coding.
>>
>>   In above comment, I would assume we are considering the programming
>> languages and not the scripting languages.
>>
>> On Wed, Jan 2, 2013 at 11:03 AM, shady  wrote:
>>
>>>  optimization of what ?
>>> can you explain your answer ?
>>>
>>>
>>> On Wed, Jan 2, 2013 at 10:31 AM, rahul  wrote:
>>>
>>>> Optimization.
>>>>
>>>> On Wed, Jan 2, 2013 at 1:35 AM, shady  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
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>>
>>>>
>>>>  --
>>>>
>>>>
>>>>
>>>
>>>  --
>>>
>>>
>>>
>>
>>  --
>>
>>
>>
>
>  --
>
>
>

-- 




Re: [algogeeks] Pointers Usage

2013-01-01 Thread Prem Krishna Chettri
Boss.. thats kinda bit basic to ask anyways.. lemme give bit of details.

Languages with pointer have WAY more flexibility to write a code upto any
segment (I mean lower layer of programming like Device Driver) as they are
directly talking to memory, where as if we don't have pointer we need to
take a help of mechanism other than pointer to talk with raw memory.

   So, basically, U can say that pointer are the basic back bone of
memory management in any language. Infact, If U use Java and Say if don't
have pointer that U are wrong , even java use pointer's but in background
with the help of JVM.

 As far as my expr is concern, with pointer lang is easy to learn and
code but in long run you will loose the charm of coding.

  In above comment, I would assume we are considering the programming
languages and not the scripting languages.

On Wed, Jan 2, 2013 at 11:03 AM, shady  wrote:

> optimization of what ?
> can you explain your answer ?
>
>
> On Wed, Jan 2, 2013 at 10:31 AM, rahul  wrote:
>
>> Optimization.
>>
>> On Wed, Jan 2, 2013 at 1:35 AM, shady  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
>>>
>>> --
>>>
>>>
>>>
>>
>>  --
>>
>>
>>
>
>  --
>
>
>

-- 




Re: [algogeeks] Linked List question

2012-12-27 Thread Prem Krishna Chettri
Those are the Cornor Test Cases.. Well we here talk about Algos and
Complexity (Atmost Pseudo code ) not about unit test cases and source
code.. :)

Ofcourse U can include those checks  either when U call the function or
inside the functions..

On Thu, Dec 27, 2012 at 4:06 PM, naveen shukla <
naveenshuklasweetdrea...@gmail.com> wrote:

> But suppose a random number generate a value 5 and your linked list has
> only four elements. In that case what would be the answer ???
>
> On Thu, Dec 27, 2012 at 4:03 PM, Prem Krishna Chettri 
> wrote:
>
>> Well my algo will be Something like this
>>
>> 1> Get a Random number. Perhaps You can have the function like
>> Randon(List *head, int Randomnumber)
>>
>> 2> Use the function argument Randomnumber to loop the list.
>> i.e. for(int count=0;count<=Randomnumber;count++ ){
>>head = head -> next;
>> }
>>
>> 3> print (head->value);
>>
>> 4> return ;
>>
>> Now as we are using byvalue when we return the value of head remains the
>> same old head value. So everytime we call we are traversing the same old
>> list.
>>
>>  The Random variable can be taken inside the function itself if the user
>> is not taking the random value.
>>  i.e. int Randomnumber = random();  and now the user can calll Simple
>> Random(head);
>>
>>
>>
>> On Thu, Dec 27, 2012 at 3:31 PM, naveen shukla <
>> naveenshuklasweetdrea...@gmail.com> wrote:
>>
>>> random node
>>
>>
>>  --
>>
>>
>>
>
>
>
> --
> With Best Wishes
>
> From:
>
> Naveen Shukla
> IIIT Allahabad
> B.Tech IT 4th year
> Mob No: 07860896972
> E-mail naveenshuklasweetdrea...@gmail.com
>
> --
>
>
>

-- 




Re: [algogeeks] Linked List question

2012-12-27 Thread Prem Krishna Chettri
Well my algo will be Something like this

1> Get a Random number. Perhaps You can have the function like Randon(List
*head, int Randomnumber)

2> Use the function argument Randomnumber to loop the list.
i.e. for(int count=0;count<=Randomnumber;count++ ){
   head = head -> next;
}

3> print (head->value);

4> return ;

Now as we are using byvalue when we return the value of head remains the
same old head value. So everytime we call we are traversing the same old
list.

 The Random variable can be taken inside the function itself if the user is
not taking the random value.
 i.e. int Randomnumber = random();  and now the user can calll Simple
Random(head);



On Thu, Dec 27, 2012 at 3:31 PM, naveen shukla <
naveenshuklasweetdrea...@gmail.com> wrote:

> random node

-- 




Re: [algogeeks] Regex tester

2012-12-23 Thread Prem Krishna Chettri
Well I can tell you Something about design pattern to  solve this case..

   What I mean is by using The State Machine Design Pattern, Anyone can
solve this. but Ofcourse it is complicated.



On Sun, Dec 23, 2012 at 11:01 PM, shady  wrote:

> that's the point, Have to implement it from scratch... otherwise java has
> regex and matcher, pattern to solve it...
>
>
> On Sun, Dec 23, 2012 at 10:28 PM, saurabh singh wrote:
>
>> If you need to implement this for some project then python and java have
>> a very nice library
>>
>>
>> Saurabh Singh
>> B.Tech (Computer Science)
>> MNNIT
>> blog:geekinessthecoolway.blogspot.com
>>
>>
>> On Sun, Dec 23, 2012 at 7:48 PM, shady  wrote:
>>
>>>
>>> http://stackoverflow.com/questions/13144590/to-check-if-two-strings-match-with-alphabets-digits-and-special-characters
>>>
>>> any solution for this. we need to implement such regex
>>> tester
>>>
>>> some complex cases :
>>> *string** regex *   ->   * status*
>>> *
>>> *
>>> reesd   re*.d  ->   match
>>> re*eed reeed ->   match
>>>
>>> can some one help with this ?
>>>
>>>  --
>>>
>>>
>>>
>>
>>  --
>>
>>
>>
>
>  --
>
>
>

-- 




Re: [algogeeks] Re: Implement Malloc and Free

2012-12-19 Thread Prem Krishna Chettri
I remember myself providing lot of codes and algo for this age old
question..

Why don't U guys check it out first b4 posting..

Regards.

On Wed, Dec 19, 2012 at 10:54 PM, Don  wrote:

> Start with a large array of bytes to use as a buffer. Keep a list of
> pointers to blocks of available memory.
>
> Malloc will look through the list for a large enough available block.
> It will actually need 4 more bytes than the size of the requested
> block and update the size of that block in the list. It will store the
> size of the block in the first four bytes and return a pointer to the
> 5th byte.
>
> Free will look through the list to determine if the freed block is
> adjacent to a block in the list. If so, it will enlarge that block.
> Otherwise it will add the block as a new element in the list. This
> makes the memory available to be used by another call to malloc.
>
> Don
>
> On Dec 19, 11:32 am, Anuj Khandelwal 
> wrote:
> > Hi,
> > How can we implement our own Malloc() and free() function ?
> >
> > --
> > Anuj Khandelwal
> > Final Year Undergraduate Student
> > Department of Computer Engineering
> > Malaviya National Institute of Technology, Jaipur
> > India
> > +91-9711088177
>
> --
>
>
>

-- 




Re: [algogeeks] Cutting a pizza

2012-12-06 Thread Prem Krishna Chettri
Problem on Greedy Algorithm.. Pretty Famous Question

On Thu, Dec 6, 2012 at 8:58 PM, bharat b wrote:

> It is like finding a line which connects most number of points.
>
> http://karmaandcoding.blogspot.in/2012/02/find-line-that-intersects-max-number-of.html
>  :
> not a good solution  .. O(n^2)
>
>
> On Thu, Dec 6, 2012 at 4:09 AM, Don  wrote:
>
>> Given a pizza with N pepperoni each specified by a location (x,y) and
>> radius r, find the largest number of pepperoni which can be cut by a
>> single straight cut.
>>
>> --
>>
>>
>>
>  --
>
>
>

-- 




Re: [algogeeks] this pointer help c++

2012-10-09 Thread Prem Krishna Chettri
Well Lemme try few more hand here..

Basics First Guys :-

  this :-  is a hidden pointer to a class (Agree ?). So whats
so special about it.. Answer is its compaction when the object of the class
is being created. Why? Here it goes. As object memory allocation (I hope
everyone knows) have memory structure such that the first parameter always
starts with arg[1]. so why not arg[0] as array always indexes with "0"? The
Answer is here.. Coz every time the object of a class is generated the
Zeroth index is alwayz occupied by this "*this*" pointer. So if do you
follow me up to here properly that you know the significance of this now..
Coz its object refference lies to the value of offset 0 to the base address
of the class's object, giving the flexibility to express any member of the
class by directly accessing via its base address and this also explains why
this has to be a pointer and not a normal member variable.

   Now here comes the other part of question.why we need *" ** *
this"*  where *"this"* should give the base address of the object of the
class we wanna refer. The Answer is partly "YES" coz as we discuss
"*this" *knows
almost everything about the class or rather an object of a class within a
class scope  but here is the catch we are telling someone to get a bowl of
rice from my private house. So how will he be able to get it? Until I tell
him my house structure, which in programming language like C++ is
reference.

   I am saying sir, I have created a house (object) and here is the
layout (referring to what I have created) so inorder to tell him about my
layout I have to generate the return value which is NOT the house (object)
but the reference to the house ( "pointer" pointing to what I have created
).

 Now I am almost done here.. So Why  " ** this *" and not "*this*"
is coz  "*this"*  gives the object directly to the the party who is calling
me and the reference means a copy not the object itself whereas " **
this *"  is
presenting you what you were looking for.

  I hope now people are clear about all the above aspects.. I mean the
very last question about returns full object or wat?? if you get all this..
U got all this.. :)

Ciao,
Prem






On Wed, Oct 10, 2012 at 12:23 AM, rahul sharma wrote:

> @saurabhif i look from the way that i need to return a referencei.e. i
> mean object...i will ryt *this for this..i knew thisbut
> i have read that reference is a const pointer so if i look from this
> prespective then do i need to return pointer(this)..
> int * fun()//return pointer to int
>
> then what does return by reference mean if i return ( *this)..then what
> actually returns...full object???or pointer to object...mix
> questions ...plz clear me..
>
>
> On Tue, Oct 9, 2012 at 11:26 PM, Saurabh Kumar wrote:
>
>> >> as we know reference is a const pointer
>> That is Not quite true.
>>
>> >> our aim is ony to return pointer to circle
>> No. our aim is to return a reference to circle.
>>
>> When you've to define a reference you do something like: *Circle &ref =
>> c;*
>> you *don't* do: *Circle &ref = &c;* Right ?
>>
>> Same is the case here, at the receiving end where the call was initiated
>> a reference is waiting there to be initialized, so you pass the Object
>> (*this) itself and NOT the pointer (this).
>> [Also remember if you've a complex object, no copy constructors etc. are
>> called when an object is sent for *reference receiving,* so no need of
>> worries there.]
>>
>> References are not quite exactly same as pointers, they were introduced
>> much later as a wrapper to pointers but there are some subtle differences
>> between them when it comes to writing code, behaviorally, yes they are more
>> or less the same.
>>
>> On 9 October 2012 22:54, SAMM  wrote:
>>
>>> This used for the following situation when   a=b=c=d  (Consider then as
>>> the  objects of a particular class say X ).
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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 mor

Re: [algogeeks] 5 tyres 10000 Kilometers..

2012-08-28 Thread Prem Krishna Chettri
@Dave.. Yeah that correct .. Its fairly simple to get in the
interviews. A bit trickier one for me is to get the corrupted link
list correction... I have seen but not concentrated enough during the
hours..

On Tue, Aug 28, 2012 at 10:02 PM, Aditya Virmani
wrote:

> If there are total 5 tyres, including the 4 attached ones...
> you can change do a rotation, change tyre after every 2000 kms( or the
> factors of 2000), in that case, the journey by each one would be 8000.
> i think there can be several interpretations of the qn. IF for five extra
> tyres, wud mean equal use of the 5 new tyres, nt considering the old ones,
> even in that case, the above wud be true.
>
> On Tue, Aug 28, 2012 at 9:39 PM, Prem Krishna Chettri 
> wrote:
>
>> Guys Something good to share here..
>>
>> Query :-  Tomorrow I am Planning to take my car for a ride of 1 ( Ten
>> Thousands )  Km. As the journey will be rough so I am planning to pack 5
>> new tyres..  Now being very conservative, I want to use each of them such
>> that they all wear equally.. Now the question is how shall I achieve it and
>> what will be the total journey traveled by each on of them.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] 5 tyres 10000 Kilometers..

2012-08-28 Thread Prem Krishna Chettri
Guys Something good to share here..

Query :-  Tomorrow I am Planning to take my car for a ride of 1 ( Ten
Thousands )  Km. As the journey will be rough so I am planning to pack 5
new tyres..  Now being very conservative, I want to use each of them such
that they all wear equally.. Now the question is how shall I achieve it and
what will be the total journey traveled by each on of them.

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



Re: [algogeeks] what is priority inversion ?

2012-08-08 Thread Prem Krishna Chettri
Read Mar's PathFinder Case Failure It would illustrate it .. Infact
the case was observed first on PathFinder Mission itself.

On Wed, Aug 8, 2012 at 4:41 AM, Hraday Sharma wrote:

> i just read about priority inversion , how does it take place ?
> i read it in Galvin , it wasnt clear there.
>
> --
> 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/-/5aVHrwEsiewJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] amazon online test question

2012-08-05 Thread Prem Krishna Chettri
Wow.. You got this question... Lucky Fellow so easy.. I remember SISO
asking such question long back.. its way below Amazon Standard...

Basically they want to make Sure U understand the question.. Implementation
is jst a copy of the content of the current SLL Node and rewiring the rest.

On Sun, Aug 5, 2012 at 6:39 PM, vaibhav shukla wrote:

> Given a singly linked list with a random pointer pointing to any node(can
> be even null).
> Create a clone of the list.
>
> node structure can be :
> struct node {
> struct node *next;
> struct node *random;
> int value;
> }
>
> The next pointer points to next node in the list while random pointer may
> point to anywhere.
> We have to Clone the list.
>
> --
> best wishes!!
>  Vaibhav
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Amazon CodeSprint

2012-08-04 Thread Prem Krishna Chettri
Well, I donoo the TO cost Impact on this question. If we need to get the
solution within the given interview time , we can go for the permutation
approach.. i.e permute all the operators and calculate.

But the T(O) and S(O) is seriously jeopardize.

Anyone got better ones??

On Sat, Aug 4, 2012 at 8:03 PM, Navin Kumar  wrote:

> Given the array of digits, you have to calculate the least positive
> integer value of the expression that could *NOT *have been received by
> you.
> The binary operators possible are *, +, -, / and brackets possible are (
> and ).  Note that / is an integer division i.e. 9/5 = 1.
> For ex- 6 6 4 4 the answer is 18
>
> 1 = 6 /6 + 4-4
>
> 2 = 6/6 + 4/4
>
> 3 = 6  +( 6/4) -4
>
> 4 = (6+6+4) / 4
>
> ……..
>
> 18 cannot be formed
>
>
>  --
> 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/-/cxnY9WEACTIJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Java Design Question..

2012-08-02 Thread Prem Krishna Chettri
One Line Answer..

  Check Factory Design Pattern.

On Thu, Aug 2, 2012 at 10:13 PM, teja bala wrote:

>  I had a java class(acts as a database class) which got a method which
> returns the respective object of the class based on given data(instance
> variable) .. eg: given customer id and 3 classes clerk,manager,salesperson
> like that .. method should return the instance associated with the customer
> id..
>  can anyone suggest how to approach this??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Facebook Interview Question

2012-07-30 Thread Prem Krishna Chettri
Well as far as I Knw this is the typical question which Amazon was know to
ask frequently ... the reason behind this is simple to see how is the
peoples approach. However the right answer of this question is yet to found
... its under research...


On Mon, Jul 30, 2012 at 6:46 PM, Lucifer  wrote:

>
> @above..
> In case the no of nodes that are placed at the certain height from the
> start node are growing at an extremely fast rate, we can instead use a
> dfs approach as well.
>
> On 30 July, 18:13, Lucifer  wrote:
> > @Mahendra Sengar..
> >
> > We can solve it by interpreting it as a graph problem (as N and K are
> > small).
> >
> > Lets say that :-
> > a) Each node in the graph defines a particular state of the disks and
> > the pegs.
> > b) Each edge in the graph defines a valid transition from one state to
> > another and weight of each edge is 1.
> >
> > Now, we can choose to do a on-the-fly bfs to find the minimum path
> > from start node to the end node, where end node is nothing but the
> > state of the final configuration.
> > The on-the-fly approach works fine because we know that a solution
> > exists and is < 7, that the the total path cannot be >=7. and hence we
> > don't need to initially generate all the valid states of the
> > (disks,pegs) and then create a graph out of it. Rather, we can select
> > the start node and then figure out the nodes that a 1-edge far from
> > it, to carry on with the bfs approach.
> >
> > On 30 July, 15:17, Mahendra Sengar  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > There are K pegs. Each peg can hold discs in decreasing order of radius
> > > when looked from bottom to top of the peg. There are N discs which have
> > > radius 1 to N; Given the initial configuration of the pegs and the
> final
> > > configuration of the pegs, output the moves required to transform from
> the
> > > initial to final configuration. You are required to do the
> transformations
> > > in minimal number of moves.
> >
> > > A move consists of picking the topmost disc of any one of the pegs and
> > > placing it on top of anyother peg.
> > > At anypoint of time, the decreasing radius property of all the pegs
> must be
> > > maintained.
> >
> > > Constraints:
> > > 1<= N<=8
> > > 3<= K<=5
> >
> > > Input Format:
> > > N K
> > > 2nd line contains N integers.
> > > Each integer in the second line is in the range 1 to K where the i-th
> > > integer denotes the peg to which disc of radius i is present in the
> initial
> > > configuration.
> > > 3rd line denotes the final configuration in a format similar to the
> initial
> > > configuration.
> >
> > > Output Format:
> > > The first line contains M - The minimal number of moves required to
> > > complete the transformation.
> > > The following M lines describe a move, by a peg number to pick from
> and a
> > > peg number to place on.
> > > If there are more than one solutions, it's sufficient to output any
> one of
> > > them. You can assume, there is always a solution with less than 7
> moves and
> > > the initial confirguration will not be same as the final one.
> >
> > > Sample Input #00:
> >
> > > 2 3
> > > 1 1
> > > 2 2
> >
> > > Sample Output #00:
> >
> > > 3
> > > 1 3
> > > 1 2
> > > 3 2
> >
> > > Sample Input #01:
> >
> > > 6 4
> > > 4 2 4 3 1 1
> > > 1 1 1 1 1 1
> >
> > > Sample Output #01:
> >
> > > 5
> > > 3 1
> > > 4 3
> > > 4 1
> > > 2 1
> > > 3 1
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

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

2012-07-26 Thread Prem Krishna Chettri
This question has been answered by Me.. Long back.. Check the thread..

On Thu, Jul 26, 2012 at 8:47 PM, jatin  wrote:

> Implementation/Definition of malloc(),realloc() in  . any idea on
> how is it working? thanks.
>
> --
> 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/-/jefNFFxuPl0J.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: output

2012-07-25 Thread Prem Krishna Chettri
Well Guys,

M here just to show wats hpning.. Have your own views..

1>  Everything is right till While loop.. I mean p1 pointing to the heap of
the address of the String "Name" , P1 getting 20 bytes of memory chunk and
so on.. So here we go now.
  As this Stupid looking while is culprit here as it is coping the
content of one pointer to other as well as moving itself forward. So What
happened when While exits, is p1 points to NULL and is copied successfully
to p1 but due to post incrementation of p1 and p2 both are momentary lost
and wen't beyond the '\0' character.. So when U print it it goes printing
all the rest of 20 character bytes losing it front values. hope U guys have
u r clear picture now.

2> Is compiler dependent but can be kinda predictable.
 Reason:-
1> STL says the two point rule as someone stated above. Coz they
feared if this rule does not followed that big chaos might happen but here
its simple and kinda predictable.
2> Anyone who have worked or know a bit of Embedded can easily tell
how the hardware operated on this equation.

Prem


On Wed, Jul 25, 2012 at 9:10 PM, deepikaanand wrote:

> @ jatin
> then there is something wrong I executed d same prog which I have pasted
> here...it was giving me the correct answer and for the second qs  has no
> absolute answer it depends on compiler
>
>
>   --
> 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/-/TOSg6xbES24J.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: trie display

2012-06-28 Thread Prem Krishna Chettri
Haha.. I got the query.. U wanna check this Google
Suggestion implemention.. :)

Well, the code seems fairly true.. use recursive approach.. (thats how G
generally uses )

Here it is..

Search (struct trie *node)
   {
 for(i=0;i<26;i++)
   {
   if(!node->islast) {
  Search(current->CHILDREN[i]);
   }

cout<<"  "letter;
 }
}



On Thu, Jun 28, 2012 at 1:58 PM, deepikaanand wrote:

> @Prem
> I know the implementation of trie...But I have doubt that say I have
> struct trie * current..
> and input = "abc"...The last character matched with head->CHILDREN[i]-
> >letter will be 'c'... now "current" points to c
>
>
>
>
> next step- there will be 4 branches from
> 'c'..."de","xyz","efgh","pqr"...
> Now  if write
> for(i=0;i<26;i++)
> {
> if (current->CHILDREN[i]!=NULL && current->islast==0)
> {
> cout<<"  "letter; //d   e
> current = current->CHILDREN[i];//head now points to 'e'
> }
> }
>
>
>
>
> The problem I am facing is how to take back current pointer to
> 'c'
> so that now I get "efgh" as output...and secondly how can I make sure
> that this time 'd' node is not selected again???
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] trie display

2012-06-28 Thread Prem Krishna Chettri
Well it Seems like problem is the DS here.

if U have the DS of trie as

  struct trie {
  char letter;// Not being general
  boolean islast;
  int startindex;
  struct trie *next;
  };

I am sure  you won't have any issue. coz now what u have to do is to start
searching the code which matches the "startindex" with the given input and
search till the "islast" is not equal to true. Well thats how trie works if
ppls are unaware..

BR,
Prem

On Thu, Jun 28, 2012 at 12:23 PM, deepikaanand wrote:

> If there is a trie of following strings(say URLs)
> "abcde","abcegh","abcpqr","abcxyz","xyz"
>
> if input = abc
> then output should be = de,egh,pqr,xyz
>
> How can I code for this ???
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Precedence or Associativity

2012-06-17 Thread Prem Krishna Chettri
Hello Dear..

  This Age Old question is Still Haunting Ppls.. In fact this ain't a
question at all.. this Should be known while we start writing first of the
C/C++ programming..

Well.. Just to make some ppls Life easier here it goes AGAIN..

++i=++0=1 so it will be one..
Now as OR means. either of the half must not be 0 and so || says, I hv got
statement true (Which in case of OR is NOT EQUAL TO 1 by evaluating left
portion only)
So. OR Says well, I got wat I wan't  Don't need to check the other
expression and so it won't execute.

At that instance the value of the variable are
i as I said becomes 1
j and k no execution and
x is assigned to 1 as the total expression evaluates as success ( Remember
Success means 1 and it not the value of i which is assigned to x )

and so the output will follow as it is.

Prem

On Sun, Jun 17, 2012 at 12:50 PM, enchantress  wrote:

> Consider the following code:
>
> int i=0,j=0,k=0;
> int x = ++i || ++j && ++k;
>
> O/P: x=1,i=1,j=0,k=0
>
> Now, the logic operators are evaluated left to right and if the output is
> determined by left hand side expression right hand side is not evaluated.
> But the precedence of && > || hence ++j&&++k should be dealt with
> first.The output says once ++i evaluates to 1 further expression is not
> considered.
> Can anyone explain this anomaly?
> As of i know associativity is considered when precedence of operators is
> the same eg:
> x*y/z will be evaluated left to right.
>
> --
> 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/-/rr41g1Q8q38J.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Can anyone explain this strange behavior ?

2012-06-11 Thread Prem Krishna Chettri
Easy Buddy.. this is primary thing.. Surprise to know that ppls still don't
knw abt this..

for OR:-
 if left expr evaluate non zero it won't compute right side.

For And:-
if left expr evalute zero , it won't compute right side

Prem

On Tue, Jun 12, 2012 at 11:10 AM, sengar.mahi  wrote:

> Nope ,the output is correct.as I had studied somewhere ,i don't remember
> where exactly but
> in (x||y) type condition's,if x evaluates to true( non zero) then value of
> y doesn't matter and is not evaluated and condition turns out to be true
> anyhow without even checking y ,control never goes to y and y is never
> executed;
> now in your case m=++i || ++j && ++k;
> since precedence of && is more than or,so we can take it as m=++i || (++j
> && ++k);
> now expression evaluates to true just by checking i++ which is -2 now(non
> zero) and value of ++j && ++k is not even checked nor changed ,hence both j
> and k remain unchanged.
> This is a correct explanation u can rely an this.
> thank you :)
>
>
> On Tue, Jun 12, 2012 at 2:19 AM, Dave  wrote:
>
>> This is the result of short-circuit evaluation. See, e.g.,
>> http://en.wikipedia.org/wiki/Short-circuit_evaluation, or this topic in
>> your language reference.
>>
>> Dave
>>
>> On Monday, June 11, 2012 2:28:52 PM UTC-5, ((** VICKY **)) wrote:
>>
>>> #includeint main(){int i,j,k,m,l;
>>> i=-3;
>>> j=2;
>>> k=0;m=++i || ++j && ++k ;printf 
>>> ("\n%d 
>>> %d %d %d",i,j,k,m);return 0;}
>>>
>>> o/p: -2 2 0 1
>>>
>>>
>>> k should be 1 right
>>>
>>>
>>> --
>>> Cheers,
>>>
>>>   Vicky
>>>
>>>  --
>> 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/-/8PoAya7NqjYJ.
>>
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Hahaha.. Xcellent question Dude.. People Who Know can easily explain.. So
for who don't here it is..

It has nothing to do with Endianess Mr.Yogesh.. Actually the bit patter
happens to be reside such that ob.ch[0] fills with all ones ..

Now as we knw the sign bit concept , here compilers goes mad thinking that
the first 1 of 8 consecutive 1's for 255 number as the Sign bit and does
the required operation of transforming to equivalent positive integer which
happen to be 1..

So as I said no endian here.. if u change the machine than U'll get other
-1 .i.e. ch[1]=-1 and again ch[0]=0..

BR,
Prem

On Thu, Jun 7, 2012 at 11:14 AM, s yogeesh  wrote:

> A: 556
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Well Thanks Rajni but I don't see any BETTER EXPLANATION of endianess here
, as you are completely relying on library function like htonl() to provide
data manipulation for you. The use case mentioned is absolutely valid and
very promising although.

 Yeah both guys are on the spot .. :)

Br,
Prem

On Thu, Jun 7, 2012 at 1:12 PM, ranju  wrote:

> #include
> int main(void)
> {
>   int i=0xff00ff11;
> printf("%x\n", i);
> i = htonl(i);
> printf("%x\n", i);
> }
>
> I feel endianness better explained by this code
>
> In networking domain , this has importance . This code segment is used
> when a data is planning to send a big endian machine from a little endian
> machine
>
> Regards
> RNP
>
>
> On Thu, Jun 7, 2012 at 1:05 PM, atul anand wrote:
>
>> @Abhishek : correct 
>>
>>
>> On Thu, Jun 7, 2012 at 1:03 PM, Abhishek Sharma wrote:
>>
>>> oh ,now i see. 300 = 000100101100
>>> first 8 bits = 0001
>>> last 8 bits = 00101100
>>>
>>> in case of big-endian machine, when we assign 2 to next location, last 8
>>> bits become 0010 (2 in decimal), first 8 bits remain same.
>>> in case of little-endian machine, when we assign 2 to next location,
>>> last 8 bits become 0010 (2 in decimal), last 8 bits remain same.
>>>
>>> Am i right ?
>>>
>>> On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma 
>>> wrote:
>>>
 @prem, i don't get it.could you please elaborate the interesting part
 of this solution ?


 On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma 
 wrote:

> Is there any online compiler which gives output for both little/big
> endian machines ?
> or it is fine to convert value from one form to another using a small
> c program ?
>
> On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra wrote:
>
>> 556 if the machine is little endian
>> 258 if machine is big endian
>>
>> On Jun 6, 11:57 pm, g4ur4v  wrote:
>> > main()
>> > {
>> > int i=300;
>> > char *ptr = &i;
>> > *++ptr=2;
>> > printf("%d",i);
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > }
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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 Sharma
> Under-Graduate Student,
> PEC University of Technology
>
>


 --
 Abhishek Sharma
 Under-Graduate Student,
 PEC University of Technology


>>>
>>>
>>> --
>>> Abhishek Sharma
>>> Under-Graduate Student,
>>> PEC University of Technology
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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: What would be the output for the following code fragment?

2012-06-07 Thread Prem Krishna Chettri
Try decode how the final value of 556 or 228 end up there.. it alwayz
compiles to those values .. try finding how compiler end up to these
values..

On Thu, Jun 7, 2012 at 12:53 PM, Abhishek Sharma wrote:

> @prem, i don't get it.could you please elaborate the interesting part of
> this solution ?
>
>
> On Thu, Jun 7, 2012 at 11:39 AM, Abhishek Sharma wrote:
>
>> Is there any online compiler which gives output for both little/big
>> endian machines ?
>> or it is fine to convert value from one form to another using a small c
>> program ?
>>
>> On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra wrote:
>>
>>> 556 if the machine is little endian
>>> 258 if machine is big endian
>>>
>>> On Jun 6, 11:57 pm, g4ur4v  wrote:
>>> > main()
>>> > {
>>> > int i=300;
>>> > char *ptr = &i;
>>> > *++ptr=2;
>>> > printf("%d",i);
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > }
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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 Sharma
>> Under-Graduate Student,
>> PEC University of Technology
>>
>>
>
>
> --
> Abhishek Sharma
> Under-Graduate Student,
> PEC University of Technology
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: What would be the output for the following code fragment?

2012-06-06 Thread Prem Krishna Chettri
Does anybody know's Why the Value is like this So... Seems simple but when
I decoded it.. its very interesting... U all should look into this simple
question which can reveal some internal manipulation.

Good One !!!

BR,
Prem

On Thu, Jun 7, 2012 at 1:13 AM, Garima Mishra  wrote:

> 556 if the machine is little endian
> 258 if machine is big endian
>
> On Jun 6, 11:57 pm, g4ur4v  wrote:
> > main()
> > {
> > int i=300;
> > char *ptr = &i;
> > *++ptr=2;
> > printf("%d",i);
> >
> >
> >
> >
> >
> >
> >
> > }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] want to create a table of words having 2 columns seperate for name and surname

2012-06-05 Thread Prem Krishna Chettri
More than a programming, I believe  this is a logical question. Some of the
assumption you can take into consideration is how many names a particular
person can possibly have. say, John F Kennedy, So, your array now can't
hold 3 names in two dimension, so what you wanna do, increase an array of
one more dimension? or make John F in one and kennedy in other.

 Now programming is fairly easy after you hv fixed your approach, alll you
have to do is make sure what goes in first dimension and what in second or
so.. and accordinly push it.

Also I got confusion here are you expecting command like argument . as givn
in sample input, than use argv / argc .. why cout/cin !!! Anyway.. try your
luck !!

BR,
Prem

On Tue, Jun 5, 2012 at 2:35 PM, daksh_ddt  wrote:

> #include
> #include
> using namespace std;
> int main()
> {
> char crew[2][2][10];
> cin>>crew[0];
> cout< cin>>crew[1];
> cout< getch();
> return 0;
> }
>
> now if I give input jack sparrow robert langdon
> crew[o][o] should be jack
> crew[0][1] should be sparrow
> crew[1][0] should be robert
> crew[1][1] sbould b2 langdon
> but this is incorrect
>
> --
> 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/-/1skPXOE7zboJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] importance of heaps

2012-06-05 Thread Prem Krishna Chettri
Each DS has its own importance. So before you approach a problem , it is
better to understand the advantage of each DS. Infact, the Fibonacci heap
is having an big advantage of O(1) time searching element, which is
extremely significant as even the DS like Trie can't afford to do so.. All
in all, if I would take a call, it would like to grap a bit of possible DS
that can be helpful.

So, if you are looking for Google/Facebook/Amazon etc, they expect you to
have a bit of info. I remember one of my colleague getting the significant
question from heap itself which he can't answer properly !!!

BR,
Prem

On Tue, Jun 5, 2012 at 12:26 PM, Jeevitesh wrote:

> From interview perspective i think min-max heaps are enough.
> You should be able to identify situations where you can apply them.
>
> I do not think other heaps are of any use.
>
>
> On Tue, Jun 5, 2012 at 11:40 AM, Abhishek Sharma wrote:
>
>> can anyone please tell me how important are heaps as compared to other
>> data structures (from interview's point of view). i am not talking about
>> simple min/max heaps, but advanced ones like fibonacci heaps and binomial
>> heaps
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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,
> Jeevitesh Shekhar Singh.*
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] classic problem to tree to circular doubly linked list

2012-05-24 Thread Prem Krishna Chettri
As the code is already shared in  the given link. I just wanna try explain
how it is ..

Struct Node  {
   Data d;
   Struct Node *right;
   Struct Node  *left;
   };

 Thats the basic structure of the Link List. Now  say U have a tree T with
root as the start node. Now we know the Simple Inorder traversal, which as
depicted in diagram, when reached to the left most child, Create a Node N (
and Hold its address and head ) , Copy data to this Node and visit its
parent. Create parent Node P and Now N->right=P and P->left=N. Again Create
Node N2 and visit its left child ( as inorder traversal) , so now
P->right=N2 and N2->left=P. it works excellent in a recursive way.
   So when U reached to the last Node (i.e rightmost right when U break the
recursion) , jst  make additional pointer modification. N(last
node)->right=head and head->left=N(last node)..

Just draw the pictorial representation. this is excellent problem yet not
that hard to resolve..

On Thu, May 24, 2012 at 11:20 PM, rahul r. srivastava <
rahul.ranjan...@gmail.com> wrote:

> hey people
>
> can anyone explain the logic and solution(in simple words) behind the
> classical problem of converting binary tree to circular doubly linked list
> in inorder fashion.
>
>  stanford language seems to be way above my head
> http://cslibrary.stanford.edu/109/TreeListRecursion.html
>
> thnx...
>
> --
> 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/-/IyQsfiqEmdUJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Algorithm Question

2012-05-23 Thread Prem Krishna Chettri
First thing on my Mind External Sorting.

On Wed, May 23, 2012 at 7:21 PM, Decipher  wrote:

> Given N files on disk of sizes < 16 GB, containing integers in sorted
> order, one integer per line. Create a single file with all the integers in
> sorted order.
> Usage : sortEM (file1, file2)
> file1 has list of input files, one name per line
> file2 is the name of file into which the output has to be written
>
>
> --
> 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/-/Os-z5dP0O7wJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Amazon Q

2012-05-23 Thread Prem Krishna Chettri
This is an Age Old Amazon Question ..

int main(void)
  {
int card[52];
int n;
srand(time(0));
for(int i=0;i<52;i++)
card[i]=i;
while(cin>>n) {
for(int i=0;i<(52-i);i++) {
int r=i+(rand()%(52-i));
int temp=card[i];
card[i]=card[r];
card[r]=temp;
}
for(int c=0;c wrote:

> Write a method to shuffle a deck of cards. It must be a perfect shuffle -
> in other words, each 52! permutations of the deck has to be equally likely.
> Assume that you are given a random number generator which is 
> perfect.
>
> --
> 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/-/kNoMc6CLVb4J.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Google Q: longest word made of subwords within the list

2012-05-22 Thread Prem Krishna Chettri
Thank you to understanding Me..

  Well For Trie.. I don't hv to say much more to say except the basic need
which says "Collect Common Prefix" . If it didnt ring the bell.. than Hv a
look at strings MADAM and MADAMIAMADAM stored in your TRIE .. Just draw a
pictorial representation.



On Wed, May 23, 2012 at 12:20 AM, atul anand wrote:

> yes ,longest word can be found while inserting each word it the TRIE.
>
>  *By tracking Second and First Longest word found** -- *confused me
> ...what you were trying to say.
> tracking can be done but become little difficult if input is something
> like this :-
>
> best
> bestest
> test
> testbest
> testbesttest
>
> btw TRIE containing only distinct word i.e words not made up of sub words
> would be enough to solve the problem
>
> On Tue, May 22, 2012 at 11:40 PM, Prem Krishna Chettri  > wrote:
>
>> Haha,, Do I hv to respond Here.. Anyways Guys And Specially Mr.Atul. Here
>> is the Long way to Make you understand..
>>
>> Yes 2 ptr is Alwayz Enuf now Why??
>>
>>  Yes Words can be a assembly of words.. Like say you sample
>> "testtesttest..n time".. So Lets go back to Simple recursion.. Tell me how
>> U calculate recursive Factorial (n) ?? similarly to get testtest...n there
>> must be one string called testtest...(n-1) and the other test right !!! So
>> 2 ptr is alwayz enuf to resolve this.
>>
>>   Now as we all know the smart way to update these valuable pointers are
>> keep looking for possible next level words.. So I've put.(*Updating
>> Otherwise Accordingly)*
>>
>> For your second condescending question.
>>
>>   It is well known if U remember DWAG/TRIE that they have
>> nodes which *MAY *contains Alphabets.. as we move down using branches
>> alwayz. so. if U are Considering Node as Alphabets (Narrow way of thinking)
>> than yes, but I would like to be more general and so will like to put as
>> N=Number of Nodes to be visited.
>>
>> BR,
>> Prem
>>
>>
>> On Tue, May 22, 2012 at 10:41 PM, atul anand wrote:
>>
>>> @krishna : tracking just second and first longest word would be enough??
>>>
>>> what if input has word which is made by repeating small word again and
>>> again
>>> test
>>> tester
>>> testertest
>>> testing
>>> testingtester
>>> testtesttesttesttest  // added word
>>>
>>> and by saying O(n) .. n= total number of alphabets in the file rite??
>>>
>>> On Tue, May 22, 2012 at 7:17 PM, Prem Krishna Chettri <
>>> hprem...@gmail.com> wrote:
>>>
>>>> Yea this is a Straight Cut Trie Question No Doubt.. Perhaps DWAG may be
>>>> taken into consideration..
>>>>
>>>> T(O)=O(n) can be done easily.. ( By tracking Second and First Longest
>>>> word found soFar and updating otherwise accordingly)
>>>>
>>>> Can someone do it better?
>>>>
>>>>
>>>> On Tue, May 22, 2012 at 6:15 PM, Ashish Goel  wrote:
>>>>
>>>>> write a program to find the longest word made of other words. For
>>>>> instance, If my file has the following words (sorted):
>>>>> test
>>>>> tester
>>>>> testertest
>>>>> testing
>>>>> testingtester
>>>>>
>>>>> The longest word should be testingtester. Trie is the solution, what
>>>>> is the best Order possible?
>>>>> Best Regards
>>>>> Ashish Goel
>>>>> "Think positive and find fuel in failure"
>>>>> +919985813081
>>>>> +919966006652
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from 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.
>>>> F

Re: [algogeeks] Google Q: longest word made of subwords within the list

2012-05-22 Thread Prem Krishna Chettri
Yea this is a Straight Cut Trie Question No Doubt.. Perhaps DWAG may be
taken into consideration..

T(O)=O(n) can be done easily.. ( By tracking Second and First Longest word
found soFar and updating otherwise accordingly)

Can someone do it better?


On Tue, May 22, 2012 at 6:15 PM, Ashish Goel  wrote:

> write a program to find the longest word made of other words. For
> instance, If my file has the following words (sorted):
> test
> tester
> testertest
> testing
> testingtester
>
> The longest word should be testingtester. Trie is the solution, what is
> the best Order possible?
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Google Q : all anagrams next to each other

2012-05-22 Thread Prem Krishna Chettri
What I Could possibly think of is

 For each string S1 that is an anagram of some string S, use Map and Store
the Key Value as (S1,S). Now there is a trick here abt how to reduce Time
Complexity here...

 Now its easy to put all string which has correspondence S next to each
other. This is Simple one.

Inplace.. Hv to think abt .. I doubt, as we need some space to get the
anagrams Dude..

Prem

On Tue, May 22, 2012 at 5:18 PM, Ashish Goel  wrote:

> Write a method to sort an array of strings so that all the anagrams are
> next to each other.
>
> What i could think of is preparing a multi linked list( multimap) whereby
> the key for each string is the sorted representation of the string(eg if
> string is gac, its sorted representation is acg). Walk of all lists of this
> multimap to give all anagrams.
>
> Is there any other better solution for this problem?
> Can this be done *inplace*?
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Partition the array with equal average

2012-05-18 Thread Prem Krishna Chettri
Are U asking the Code Again ?? :)

On Fri, May 18, 2012 at 2:19 PM, saurabh singh  wrote:

>
> Saurabh Singh
> B.Tech (Computer Science)
> MNNIT
> blog:geekinessthecoolway.blogspot.com
>
>
>
> On Thu, May 17, 2012 at 11:40 PM, Prem Krishna Chettri  > wrote:
>
>> I guess this is Subset minimization problem's Modification..
>>
>>
>> Algo..
>>
>> 1> Get all the Subset of the particular array. Best Algo O(n2).
>>
>  ''
> How?
>
>
>> 2> Now try to find the subsets having similar average. Again best algo
>> known is O(n2).
>>
>>
>> Anyone have better options??
>>
>> BR,
>> Prem
>>
>>
>> On Fri, May 18, 2012 at 12:05 PM, payal gupta wrote:
>>
>>>  How do you partition an array into 2 parts such that the two parts
>>> have equal average?...each partition may contain elements that are
>>> non-contiguous in the array...
>>>
>>>  --
>>> 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/-/fSAXqe-gkJcJ.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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] Partition the array with equal average

2012-05-17 Thread Prem Krishna Chettri
I guess this is Subset minimization problem's Modification..


Algo..

1> Get all the Subset of the particular array. Best Algo O(n2).
2> Now try to find the subsets having similar average. Again best algo
known is O(n2).


Anyone have better options??

BR,
Prem

On Fri, May 18, 2012 at 12:05 PM, payal gupta  wrote:

>  How do you partition an array into 2 parts such that the two parts have
> equal average?...each partition may contain elements that are
> non-contiguous in the array...
>
>  --
> 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/-/fSAXqe-gkJcJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: storing URL's

2012-05-17 Thread Prem Krishna Chettri
For the cases where Storing the Value is the only Concern and (Not the
Retrieval efficiency), I would Suggest Something called DFA Subset
minimization.. Google for it ... and after the final subset as said U can
use something called DAWG for the most Most Optimal solution..

On Thu, May 17, 2012 at 2:58 PM, Prakash D  wrote:

> We can still improve this trie idea..
>
> say we have urls like
> www.google.com
> www.goodbye.com
> www.google.com/transliterate
> www.goodstrain.com/good
>
> we can subdivide everything under "www.goo"
> I mean we can store each character as a node in a trie and call it
> like a "URL dictionary"
>
>
> On Wed, May 16, 2012 at 5:43 PM, omega9  wrote:
> >
> >
> > On May 16, 10:33 am, atul anand  wrote:
> >> @amit :
> >>
> >> here is the reason :-
> >>
> >> each url sayhttp://www.geeksforgeeks.org
> >>
> >> you will hash following urlshttp://www.geeksforgeeks.orghttp://
> www.geeksforgeeks.org/archiveshttp://www.geeksforgeeks.org/archives/19248http://www.geeksforgeeks.org/archives/http://www.geeksforgeeks.org/archives/19221http://www.geeksforgeeks.org/archives/19290http://www.geeksforgeeks.org/archives/1876http://www.geeksforgeeks.org/archives/1763
> >>
> >> "http://www.geeksforgeeks.org"; is the redundant part in each url .
> it
> >> would unnecessary m/m to save all URLs.
> >>
> >> ok now say file have 20 million urls . .now what would you do.??
> >>
> >
> > I think the trie suggestion was good. Have each domain (with the
> > protocol part) as a node and then have the subsequent directory
> > locations as a hierarchy under it.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from 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: Find Power(N,N),

2012-05-16 Thread Prem Krishna Chettri
Yes U are Correct.. in Such cases the Compiler itself has overcome ( or
tried to overcome)  the architecture limitations to some extends but what
will happen if U need say 128 or 256 or more values??

  Again U hv your compiler restricted limitation right?   So that what I am
talking about is.. Write a code which accept all the value yet fits in
8/16/32 bit compiler and architecture...

Yes I am talking more optimistic way as I am talking about embedded
technologies.But there will be one limitationl which can't be overcome and
that is the maximum registers available.

When your code finally runs it will be using assembly language.. where the
operation like R1=M[SP+8] kinda operation happens.. Now the more advance
processors will hv this register of 32 bit ( Guess intel i7 ships 64 bit as
well). but these registers are limited..unlike memories in heap.


So if M talking about 8085/6 processor, there are 8/16 of these 8 bit
registers.. So the max U can really force your calculation to have is
8*8=64 bit operation or 8*16=128 bit operation. singly.

but with latest intel i7's it can go much higher.. that why these
processors are expensive :)


On Thu, May 17, 2012 at 10:41 AM, pankaj joshi  wrote:

> @Victor: - hi i have tried with 2 array but the complexity will increases
> as the n grows.
> So can you please share your code, if you have done this
> already.
> @Prem:- Actually the ALU does only 32 bit calculation, but if i am telling
> about VC++(or can be any compiler)
>   support the calulation long long (8 byte , 64 bit), then the
> compiler will do the calculation such a way that
>   the result of the calculation save in two memory locations.
> ( i think, please correct me if i am wrong),
> @don: - Don actually the problem wants the full value not the truncated
> double values .
> but anyway thanks for exp(log(n)*n) :)
>
> On Thu, May 17, 2012 at 4:52 AM, Don  wrote:
>
>> How about
>>
>> exp(log(n)*n);
>>
>> Don
>>
>> On May 14, 10:58 pm, pankaj joshi  wrote:
>> > Hi All,
>> >
>> > I have written a program to find out n^n(n power n),
>> >
>> > long long unsigned int power(int n, int i)
>> > {
>> > if(i == 1)
>> > {
>> > return n;}
>> >
>> > else
>> > {
>> > if(i%2 != 1)
>> > {
>> > long long unsigned int mul;
>> > mul = power(n,i/2);
>> > return mul*mul;}
>> >
>> > else
>> > {
>> > return (power(n,i-1)*n);
>> >
>> > }
>> > }
>> > }
>> >
>> > This program is working fine for power(15,15), but it is overflow for
>> > power(16,16), as long long unsigned int is 2^64.
>> >
>> > Please tell me how to store the values more than 2^64,
>> > i had thing to store in array.
>> > Please suggest me .
>> >
>> > thanks ..
>> >
>> > --
>> >  Regards,
>> >
>> > Pankaj Kumar Joshi
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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,
>
> Pankaj Kumar Joshi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: finding anagrams in a list of words

2012-05-16 Thread Prem Krishna Chettri
Well this is an Age old question yet there seems to have a lots of room for
further modification..

1> Comparison of String Individually.  Effective yet O(n2)
2> Why dont we let some function do the job say
   if( Sort(String 1)==Sort(String 2))
   Anagram;
  All Work is Done by Sorting function. Use efficient Sort Say
qsort/heapsort and get the O value to O(nlogn) from O(n2) as we saw earlier

NOW IS that all we Computer Scientist do for this age old problem??

Naa.. here comes trie (Perhaps patricia trie sound better)

3> Bit Complex to implement/Hard to understand and use but highly efficient
.

  Struct Trie {
 char p;// Are we talking about String or Char?
 Struct Trie *child[26];
 bool End;
};

Yea this is the one for us. but As U can see each node holds 26
additional pointer overhead. Can some one try to rectify this structure ..


Well how abt this one
  Struct Trie {
   char letter;
   bool end;
   int startChildIndex;
   int noof Child;
 };


 And that pushes all our refereces to  array. So NO POINTERs.. here u guys
find how we can use the characteristic of array as pointer for efficency.

Anyway its coding time and as u all know wat to do next..

 Please do your home work..

and have the most efficient Anagram Algo.. I guess its O(n) altogether..
but not only that it has the very small constant factor which means more
additional efficency..

HAPPY CODING


On Mon, May 14, 2012 at 8:06 PM, Piyush Khandelwal <
piyushkhandelwal...@gmail.com> wrote:

> @ deepikaanand:
> I would like to paraphrase Gaurav's approach:
> what u have to do is take array a[26]={2,3,5,7,11. first 26
> prime numbers }
>
>  Now if ur words are EAT and ATE:
> for EAT..
> val1= a[ 'E' - 'A' ] * a [ 'A' - 'A' ] * a[ ' T '- 'A' ];
>
> for ATE:
> val2= a[ 'A' - 'A' ] * a [ 'T' - 'A' ] * a[ ' E '- 'A' ];
>
> Now if ( val1 == val 2) --> anagrams
> This will work in all the cases.
> Hope this will help u... all the best
>
>
>
> On 13 May 2012 19:07, GAURAV CHAWLA  wrote:
>
>> @deepikaanand:
>>
>>
>> 1 is not a prime no. and also ignore 2 as chosen prime no,.
>>
>> On Sun, May 13, 2012 at 6:31 PM, deepikaanand wrote:
>>
>>>
>>> @gaurav
>>> the approach suggested as : to have an array of 25 prime nos..How is
>>> it supposed to work ;
>>> cz(this is wat i have understood) if a :0 ,b:1,c:3,d:5,e:7
>>> then be = b + e = 1+7 =8
>>> and  dc = d + c =5 +3 = 8..
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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,
>> GAURAV CHAWLA
>> +919992635751
>> +919654127192
>>
>>
>>
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> *Piyush Khandelwal**
> *Mobile No: 91-8447229204
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Algo for Search in a 2D Matrix

2012-05-16 Thread Prem Krishna Chettri
Well I hv got Something running in my mind buy ofcse need some cornor case
tuning.

  If we take sqrt() of the number (say K) than we can  avoid looking into
sqrt(k)-1 and sqrt(k)+1 rows and column entirely, which literally means
that the final solution is possible in constant time (the time independent
of k or matrix values), which ofcourse can go upto O(n) in worst case where
N is the Matrix of N Rows and 1 Column as we cannot use the intelligence of
sqrt function to corner the value.

  Its seems okei logically to remove those rows and columns as we are
certain that they are sorted in both ways and avoid unnecessary time
looking for the place where it won't belong.

Now the issue is so clear that we can say (sqrt(k)-1)*(sqrt(k)-1) wrote:

> Vikas, can you suggest the logic of this also? I am a bit unclear on how
> the 2D arr is being used as a heap and how recursion is used to solve this
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
>
> On Thu, Oct 13, 2011 at 11:37 PM, vikas wrote:
>
>> @Sunny, good catch, k X k approach wont work
>>
>> lets try to use matrix itself as heap
>>
>> heapify(int cr, int cc, int Nr, int Nc){
>>   mr = cr; mc = cc;
>>  if(cr+1 < Nr)
>>mr = cr+1 mc = cc;
>>  if(cc + 1 < Nc && min > A[cc+1][cr])
>> mr = cr; mc = cc+1;
>>  if(A[cr][cc] > A[mr][mc]){
>>   swap(&A[cr][cc] ,&A[mr][mc]);
>>   heapify(mr, mc, Nr, Nc);
>> }
>>
>> extract_min(){
>> swap(&A[0][0], &A[hr][hc]);
>> if(hc > 0) hc--;
>> else if(hr > 0){
>>  hr --;
>>  hc = N;
>> }
>> if(hr | hc)
>>  heapify(0, 0, hr, hc);
>> }
>>
>>
>> }
>>
>>
>> On Oct 13, 12:18 pm, sunny agrawal  wrote:
>> > Nopes
>> > Still it does not ensure that duplicates will not be there in the
>> priority
>> > queue
>> >
>> > what i mean is you cannot write directly
>> >
>> > do k times{
>> > data = pop()
>> > // let i,j are row and col of data
>> > push(i+1,j);
>> > push(i,j+1);
>> >
>> > }
>> >
>> > you need to add the following checks
>> >
>> > if((i+1,j) is not in the heap) push(i+1,j)
>> > if((i,j+1) is not in the heap) push(i,j+1)
>> > because heap does not automatically check for duplicates
>> >
>> > and to check for duplicates we need an extra data structure other than
>> heap,
>> > which stores that which (i+1,j) are already there in the heap map can
>> also
>> > be used so overall complexity will go O(k* lg^2K)
>> >
>> > On Thu, Oct 13, 2011 at 12:26 PM, anshu mishra <
>> anshumishra6...@gmail.com>wrote:
>> >
>> >
>> >
>> > > struct data
>> > > {
>> > > int row, col,
>> > > int val;
>> > > };
>> >
>> > > priority_queue heap;
>> >
>> > > now fine?
>> >
>> > >  --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Algorithm Geeks" group.
>> > > To post to this group, send email to algogeeks@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > algogeeks+unsubscr...@googlegroups.com.
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/algogeeks?hl=en.
>> >
>> > --
>> > Sunny Aggrawal
>> > B.Tech. V year,CSI
>> > Indian Institute Of Technology,Roorkee
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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

2012-02-07 Thread Prem Krishna Chettri
This is a simple implementation to Factory Design Pattern. What you have to
do is make an arbitrary class (Your Adapter) and always call this. However,
the implementation of  this class should be smart enough to route your call
accordingly. As suggested by DON , its the c++ implementation of Factory
Class. However , if you are designing in any other language, It is
alwasyz advisable to have a sample implementation of  Factory design
pattern.



On Tue, Feb 7, 2012 at 11:23 PM, Don  wrote:

> Provide an interface class for the client to access. The client needs
> to know the name of the method in the interface, but only the
> interface needs to know the name of the function in the server.
> Don
>
> On Feb 7, 8:38 am, Aman Kumar  wrote:
> > Hii to all
> >
> > If client want to make a function call to a server(vice versa), but it
> > doesn't know exact name . so we need a adapter.
> >
> > for this i have to design a adapter (middleware)  so that client can
> > make a call and adapter make that call to exact match.
> >
> > please help me for same.
> >
> > how to design adapter?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] how many times you can write that word using subsets of the string

2011-12-28 Thread Prem Krishna Chettri
Well. this seems interesting question.

1> You have to break the string to the lowest possible subset. I know O(log
n) algo for this.

2>  Number of possibilities of creating a second sentence from this subset.
This is subset formation and I guess will take O(nlogn) atleast for n
possible elements.



On Wed, Dec 28, 2011 at 2:55 PM, Tamanna Afroze  wrote:

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

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Detect a loop with just head ptr given

2011-12-08 Thread Prem Krishna Chettri
I appreciate everyone effort here but guy's the question here is to Not Use
any More pointer (Rather Space Utilization)..
  I Donno , if there is a any way to detect without any further space..
Else my First Solution works neatly...


Br,

On Thu, Dec 8, 2011 at 11:34 PM, himanshu kansal <
himanshukansal...@gmail.com> wrote:

> @sayan: take a singley linked list (not circular) with a loop in ittry
> to reverse it.you will get why i gave this algo...it can be
> reversedand it always ends up landing at original head of list if it
> contains a loop
> give it a try...
>
>
> On Thu, Dec 8, 2011 at 11:30 PM, sayan nayak  wrote:
>
>> @Himanshu: How can u reverse a linked list which has only the
>> beginning(head) but no tail...
>>
>> And even if I consider that by some means u have reversed it..then also
>> there is no guarantee that u reach the head..
>> Because the LinkedList is not necessarily circular..a circular Linkedlist
>> and a linkedlist with loop are not same...Cicular is one specific case of
>> Loop.
>>
>> Pls correct me If I have misunderstood your explanation.
>>
>> Regards,
>> Sayan
>>
>>
>>
>> On Thu, Dec 8, 2011 at 10:27 PM, himanshu kansal <
>> himanshukansal...@gmail.com> wrote:
>>
>>> if u cant create new ptrsthen i think horse and tortoise strategy
>>> will fail.
>>> then you can only modify the linked lists to detect the loop.
>>>
>>> one other strategy could be to reverse the linked list.after
>>> reversing the linked list, if you arrive at the head itself then the list
>>> contains the loop
>>>
>>> i know reversing of list will require additional three ptrsbt this
>>> is also one of the way
>>>
>>>
>>> On Thu, Dec 8, 2011 at 9:43 PM, hary rathor wrote:
>>>
>>>> take two pointer
>>>> run first with one speed and another with two until they meet,
>>>> now take a first pointer and assign with head of list .
>>>> now move again both same speed (only one forward at a time )
>>>> now as they meet at point that will be your  starting pointer of loop.
>>>>
>>>> On 12/8/11, Deepak Nettem  wrote:
>>>> > If you allow storing an extra bit with every node (to mark whether a
>>>> node
>>>> > has been visited), you can do it with just one pointer. But that's
>>>> less
>>>> > space efficient (O(n)) than using two pointers of varying speeds.
>>>> >
>>>> > On Thu, Dec 8, 2011 at 9:04 AM, Ankur Garg 
>>>> wrote:
>>>> >
>>>> >> U cant create any new ptrs .Just use this ptr :)
>>>> >>
>>>> >>
>>>> >> On Thu, Dec 8, 2011 at 6:30 PM, Prem Krishna Chettri
>>>> >> wrote:
>>>> >>
>>>> >>> Ofcourse we can..
>>>> >>>
>>>> >>>U knw the head address now U start visit the list what is the big
>>>> >>> deal?? Jst u gotto create two pointer say fast and slow with two
>>>> diff
>>>> >>> speed
>>>> >>> of action..
>>>> >>>
>>>> >>> On Thu, Dec 8, 2011 at 6:27 PM, Ankur Garg 
>>>> wrote:
>>>> >>>
>>>> >>>>  Can we detect if a loop is present in Linked List if only head
>>>> ptr is
>>>> >>>> given
>>>> >>>>
>>>> >>>> --
>>>> >>>> You received this message because you are subscribed to the Google
>>>> >>>> Groups "Algorithm Geeks" group.
>>>> >>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> >>>> To unsubscribe from 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
>>>> >>&g

Re: [algogeeks] Detect a loop with just head ptr given

2011-12-08 Thread Prem Krishna Chettri
Ofcourse we can..

   U knw the head address now U start visit the list what is the big deal??
Jst u gotto create two pointer say fast and slow with two diff speed of
action..

On Thu, Dec 8, 2011 at 6:27 PM, Ankur Garg  wrote:

> Can we detect if a loop is present in Linked List if only head ptr is
> given
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] virtual destructor problem

2011-12-07 Thread Prem Krishna Chettri
The Output would be only  the base class object destructor would be called
so output :-

derivedClass2 Des called

Now why ..

  It is no more than just a base parent concept here, so base pointer
capable if holding its derived object address get's derived object as new
derivedClass2() creates only derived object. However,  by deleting that
pointer would results in destructing of this object which is the object of
the derived class type "derivedClass2".


Well,  I Guess what would be more interesting if you have a main something
like this :-

int main() {

baseClass *aPtr = new derivedClass1();
baseClass *bPtr = new derivedClass2();
delete aPtr;
delete bPtr;
}


On Wed, Dec 7, 2011 at 2:51 PM, deepak kumar wrote:

> Hi All,
> I am sharing  with you all a problem . The problem is as follow
>
>
> class baseClass {
> public :
>   ~baseClass() { cout<< "baseClass Des called"<< endl; }
> };
>
> /*Derived class*/
>
> class derivedClass1 : public baseClass {
> public:
> *virtual *~derivedClass1() {cout <<"derivedClass1 Des called"<< endl;}
> };
>
> /*Derived class*/
>
> class derivedClass2 : public baseClass {
> public:
> ~derivedClass2() {cout <<"derivedClass2 Des called"<< endl;}
> };
>
>
> int main() {
>
> baseClass *bPtr = new derivedClass2();
> delete bPtr;
> }
>
>
> Can anyone tell me what will be the output and why ?
> Note: the virtual destructor in derivedClass1.
>
>
> --
> Thanks and Regards
> Deepak Kumar
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Soritng

2011-11-22 Thread Prem Krishna Chettri
This is  a Great Question ..


Answering My Opinion as Follows :-

1> Its QuickSort :-  Coz we compare on the basis of pivotal element so , we
are reducing half (or More ) of the total comparison by picking the the
pivot as a bench mark. All rest of the sorting do the full
element comparison.
2> Its Selection Sort :-  coz we swap picked up element only when we are
sure when I need to place it.
3> Sorry I didn't get the question properly as I am not aware of this cost
related information.

Thanks for sharing this question.


On Mon, Nov 21, 2011 at 11:34 AM, kumar raja wrote:

>
> if we have set of n elements then
>
> 1) which sorting method uses least number of comparisons??
>
> 2) which sorting method uses least number of swaps??
>
> 3) suppose the array is 2 8 4 6 5 9
> if we want to swap 8  and 5 the cost is 2(5-2)=6   .here 5 and 2 are
> indices of 5 and 8.
> so what sorting method minimizes the cost, i want the answer in general
> case ,not for this particular array. it is also called least distance
> sorting
>
> --
> Regards
> Kumar Raja
> M.Tech(SIT)
> IIT Kharagpur,
> 10it60...@iitkgp.ac.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 post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] Query: Function returning void pointer

2011-11-21 Thread Prem Krishna Chettri
Ofcrse yes... hvnt you use Malloc ??

On Tue, Nov 22, 2011 at 1:23 PM, Aniket  wrote:

> Can a function return a void pointer ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Searching In a large file

2011-10-27 Thread Prem Krishna Chettri
Clearly this is an external sorting question..
  Merge sort Can Be Used..

On 10/27/11, shiva@Algo  wrote:
> Given a file containing roughly 300 million social security
> numbers(9-digit numbers), find a 9-digit number that is not in the file.
> You have unlimited drive space but only 2megabytes of RAM at your
> disposal.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Hash Table

2011-10-27 Thread Prem Krishna Chettri
One sentence answer to your query is all Hash DataStructure is suppose
to provide Constant Time Complexity .i.e.O(1). However as an when
HashTable fills up,Data Value collision occurs becoz,common key will
generated by HashFunction.Thats where HashFunction dependibility comes
into picture..
 Well the Worst Case of Time Complxity extremgely poor hash function
may go upto O(n). Which is very rare and when data is hash table is
fully filled with all colliding values..

On 10/27/11, kumar raja  wrote:
> I am asking for the above quesiton
>
> On 27 October 2011 07:38, kumar raja  wrote:
>
>> @Prem :
>> So is the time complexity is O(1) or O(log n) or O(n)???
>>
>>
>> On 27 October 2011 07:28, Prem Krishna Chettri  wrote:
>>
>>> Well, if we talk abt space complexity in Hash.. M srry we require O(n)
>>> for Hash Datastructure... As each Bucket can contain at most one data
>>> value of Key Value pair,thats where key is gonna hash your value..
>>>
>>> However, when we talk abt time complexity, its alwayz, the Hash
>>> Function dependable question...
>>>
>>> On 10/27/11, ligerdave  wrote:
>>> > I am a bit confused. Are you talking about the runtime of hash function
>>> > itself or to find the position.
>>> > Agree on the efficient hash function design. However, no function could
>>> be
>>> > designed to fit all cases. A key to make a particular hash function
>>> > efficient is to know the potential data size.
>>> >
>>> > --
>>> > 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/-/G_0Wm4NQIyIJ.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > algogeeks+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> >
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Regards
>> Kumar Raja
>> M.Tech(SIT)
>> IIT Kharagpur,
>> 10it60...@iitkgp.ac.in
>>
>>
>>
>
>
> --
> Regards
> Kumar Raja
> M.Tech(SIT)
> IIT Kharagpur,
> 10it60...@iitkgp.ac.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 post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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: Hash Table

2011-10-27 Thread Prem Krishna Chettri
Well, if we talk abt space complexity in Hash.. M srry we require O(n)
for Hash Datastructure... As each Bucket can contain at most one data
value of Key Value pair,thats where key is gonna hash your value..

However, when we talk abt time complexity, its alwayz, the Hash
Function dependable question...

On 10/27/11, ligerdave  wrote:
> I am a bit confused. Are you talking about the runtime of hash function
> itself or to find the position.
> Agree on the efficient hash function design. However, no function could be
> designed to fit all cases. A key to make a particular hash function
> efficient is to know the potential data size.
>
> --
> 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/-/G_0Wm4NQIyIJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Hash Table

2011-10-27 Thread Prem Krishna Chettri
If N Element is already hashed and when you insert next element , Does
hashing will take log N time to find the next available position? Actually
the next insertion typically does not have any co-relation to pre-existing
table content (Until your Hash function is badly designed to hash always on
the same key everytime). So, its actually the design of Hash that has to be
efficient.Hence every operation cannot be mapped to the number of data which
is present in the existing table.

On Thu, Oct 27, 2011 at 12:49 AM, ligerdave  wrote:

> from high level and with a very few collisions, it's O(1).
>
> there isn't much to prove because this is based on a common sense.
>
> for example, have the world as a hashtable and all countries as the keys of
> it. boxes(storage) marked by different country names(key) and you know where
> to locate them. now, you are given a mail and asked to put it into the box
> which goes to its destination country.
> so how many operations does it take you to put a mail in the box? 1
> if you realized the mail wasn't misplaced and you need to take it out, how
> many operations does it take you to take the mail out of the box?
>
> i hope this helps a bit
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/ZamCyJETdscJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Find all possible combination of integers for a given sum

2011-10-25 Thread Prem Krishna Chettri
Its a subset Manipulation Problem.. Very simple logic.. Can Use
Recursion for even more simplicity..
Call Recursion one with that element and once wdout..

On 10/25/11, Meng Yan  wrote:
> Hi, my question is
>
> given sum=N and combination constraint=M (the number of elements), how to
> find all possible combinations of integers?
>
> For example, given sum=6, combination=3; how to get the result as following:
> 1+1+4;
> 1+2+3;
> 2+2+2;
>
> We don't care about order of the elements, which means 1+1+4 and 1+4+1 are
> considered as same combination.
>
> Thanks a lot!
>
> Meng
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Adobe final interview question : small change

2011-09-23 Thread Prem Krishna Chettri
This is Simple query related to Factory Design Pattern... Have a look at the
Auto Registration of Factory Design pattern..


:)
Prem


On Fri, Sep 23, 2011 at 3:02 PM, algo geek  wrote:

> You have a library provided by the vendor. All you have is header files and
> library files.
> Library contains the class Shape and there is whole hierarchy tree (i mean
> classes which derive from this base class).
> Now you want to add some function "getArea" (not originally present in the
> class or any of its derived class) in the class "Shape" , you dont have the
> source code.
>
> Using this library, you have written a lot of code. Now you have to make
> some changes so that, any object of Shape class (or its derived class) will
> be able to call this function.
> With your strategy, you should be able to override the definition of this
> function in the derived class.
>
> I think it is related to design patterns, not sure.
> I gave the solution that : we will use MyShape , and use composition. i.e.
> will create the object of Shape class inside this "NewShape" class and
> interface can be made. Internally, we can call the functions of "Shape"
> object. That will work fine. But we have to do this for the whole design
> hierarchy. Secondly, if there is some changes by the vendor in future in the
> library, i have to change my new design tree.
> e.g.
> class Shape {
>public : void draw();
>   void clear();
> }
> class Circle : public Shape{
>public : void draw();
>   void clear();
> }
> class Rectangle: public Shape{
>public : void draw();
>   void clear();
> }
>
>
> class NewShape{
> private Shape * obj;
>public : void draw(){ obj->draw(); }
>   void clear() { obj->clear(); }
>   int getArear(){
>  //implementtation of getArea function
>   }
> }
>
> class NewCircle : NewShape{
>public : void draw(){ (Circle*)obj->draw(); }
>   void clear() { (Circle*)obj->clear(); }
>   int getArear(){
>  //implementtation of getArea function specific to
> circle
>   }
> }
> class NewRectangle : NewShape{
>public : void draw(){ (Rectangle*)obj->draw(); }
>   void clear() { (Rctangle*)obj->clear(); }
>   int getArear(){
>  //implementtation of getArea function
>   }
> }
>
> I know this solution is not good.. please provide a better approach for
> this.
> Please let me knw if anything is not clear.
>
>
>
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] plzzzzzzzz heeeppppp!!!!!!!!!!1

2011-09-14 Thread Prem Krishna Chettri
Its an open ended question for the New Guys..
 So.. here its some analysis..
   If its project is R&D with high profile org like Amazon.. Google.. SDET
is Developer in Test  (Framework Developer for TESTING) but QA is a Complete
Tester (Mostly No Code Work).. So SDET will develop in basically in Some
Scripting Languages like Ruby.. Python .. Shell etc..
   However Development is not only writing feature in Complied Languages
like C/C++ and Java but also maintenance and bug Fix..


  So, for High profile org.. its always a great wk Exp in any of these filed
. but for medium org its always Dev on top (few Exception)..

Now its your Choice.


Prem

On Thu, Sep 15, 2011 at 12:10 PM, siddharam suresh
wrote:

> testing is very broad area of s/w development.
> first get clear about the job,
>
> when i was giving interview with MS for SDET, they said its developing test
> s/w for already build s/w.   my view, testing requires more skills than
> developer, to find out the flaws in the code.
>
> Thank you,
> Sid.
>
>
>
> On Thu, Sep 15, 2011 at 11:42 AM, vivek goel 
> wrote:
>
>> hello  nikhil,
>>
>>suppose if we currently opt  for testing OR consultant
>>  profile
>>
>> then  Is it possible to switch to Software Development profile   later
>> on.
>> plss tell me...
>>
>> On 9/15/11, Nikhil Kumar  wrote:
>> > Testing profile : You have to test the features developed by
>> others.Kinda
>> > bruteforce work , you will be given a set of commands and a large no. of
>> > test cases.All you have to do is run commands and validate test cases
>> again
>> > and again.Boring.Only periodic growth.
>> >
>> > Developers: Much better. You have to develop new features yourself.You
>> will
>> > apply concepts to mould the product.Growth chances are good.Growth basis
>> is
>> > your talent and capability.
>> >
>> >
>> >
>> > On Thu, Sep 15, 2011 at 11:07 AM, abhinav gupta
>> > wrote:
>> >
>> >> in my opinion developer profile is better than testing...one
>> >>
>> >>
>> >> On Thu, Sep 15, 2011 at 10:57 AM, rahul sharma
>> >> wrote:
>> >>
>> >>> hey guys plz tell the difference b/w testing n develp.  profile ??? n
>> >>> joing i n testing profile has growth as much as in develpoer???plz
>> >>> tell soon..?should i go in testing profile in lagre industry or in
>> >>> developer in medium scale...plz hepl
>> >>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google
>> Groups
>> >>> "Algorithm Geeks" group.
>> >>> To post to this group, send email to algogeeks@googlegroups.com.
>> >>> To unsubscribe from 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.
>> >>
>> >
>> >
>> >
>> > --
>> > Nikhil Kumar , Software Engineer @ Ciena Gurgaon.
>> > B.E.( Information Technology ) ,
>> > NSIT Delhi , 2007-2011
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Algorithm Geeks" group.
>> > To post to this group, send email to algogeeks@googlegroups.com.
>> > To unsubscribe from 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: Stack problem

2011-09-06 Thread Prem Krishna Chettri
@ Shravan :-  Thank for the Code but there are couple of issue with that..

 1> Please try to provide the algo approach. Coz I feel
here we discuss irrespective of language , the technique of approach.
 2> Your Code implementation of whatever your approach
is WRONG..

 Please Run through these sample Inputs
Values :-  233556263

 You need to make grow both the
stack Simultaneously.



   Well Guys the Algo I presented above is my understanding as I feel its
simple topic being highly exaggerated. Please feel free to break it if I
have missed something..


On Tue, Sep 6, 2011 at 6:26 PM, Shravan Kumar  wrote:

> void push(int num){
> if(stk1.isEmpty()){
> stk1.push(num);
> stk2.push(num);
>  }
>else{
>if(num>stk2.top())stk1.push(num);
>else{stk1.push(num);stk2.push(num)}
>   }
> }
>
> int pop(){
> int num=stk1.pop();
> if(num==stk2.top())stk2.pop();
>     return num;
> }
>
> On Tue, Sep 6, 2011 at 6:12 PM, Prem Krishna Chettri 
> wrote:
>
>> Guys What the Issue Here?? I think its straight forward.
>>
>> If I hv two Stack
>>First :-  Keep pushing and Popping the incoming values
>>Second :- Keeping track of the so far min element in the First Stack.
>>
>>
>> Now maintaining second stack is bit tricky.
>>   PUSH :-  If the element is first element Push the Same
>> element in Second Stack what we Pushed in Stack 1.
>> Else compare the last Second.top with Current
>> Element
>>   Push which ever
>> is smaller (or Equal).
>>
>>  POP :-  POP both the stack simultaneously.
>>
>>
>>
>>
>> On Tue, Sep 6, 2011 at 5:52 PM, Don  wrote:
>>
>>> @HARISH:
>>> Push 20 1 3 1 5 1 6 1 2 1
>>> Pop
>>>
>>> Now in your algorithm min will return 20, even though 1 and 3 and
>>> other smaller numbers are still in the stack.
>>>
>>> Don
>>>
>>> On Sep 6, 6:25 am, "HARISH S.C"  wrote:
>>> > Have a separate stack for minimum. While pushing, insert the number in
>>> > minimum stack only if the given number is less that or equal to the
>>> number @
>>> > the top of min stack. While removing, remove the value from min stack
>>> only
>>> > if its equal to the value thats popped.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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: Stack problem

2011-09-06 Thread Prem Krishna Chettri
Guys What the Issue Here?? I think its straight forward.

If I hv two Stack
   First :-  Keep pushing and Popping the incoming values
   Second :- Keeping track of the so far min element in the First Stack.


Now maintaining second stack is bit tricky.
  PUSH :-  If the element is first element Push the Same element
in Second Stack what we Pushed in Stack 1.
Else compare the last Second.top with Current
Element
  Push which ever is smaller (or
Equal).

 POP :-  POP both the stack simultaneously.




On Tue, Sep 6, 2011 at 5:52 PM, Don  wrote:

> @HARISH:
> Push 20 1 3 1 5 1 6 1 2 1
> Pop
>
> Now in your algorithm min will return 20, even though 1 and 3 and
> other smaller numbers are still in the stack.
>
> Don
>
> On Sep 6, 6:25 am, "HARISH S.C"  wrote:
> > Have a separate stack for minimum. While pushing, insert the number in
> > minimum stack only if the given number is less that or equal to the
> number @
> > the top of min stack. While removing, remove the value from min stack
> only
> > if its equal to the value thats popped.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: probability ques

2011-08-29 Thread Prem Krishna Chettri
Hi Guys,

  Comment required from NIT Warangal ppls.   Who is this guy?? Who claims
this ...

http://timesofindia.indiatimes.com/tech/careers/job-trends/Facebook-hires-NIT-Warangal-student-for-Rs-45-lakh/articleshow/9793300.cms

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

2011-08-25 Thread Prem Krishna Chettri
Its true that in Java String are immutable. Even in the code given its
immutable.. Its actually the code executed like this..

String s="java"; // S holds to java.
s+="c c++"; //

 Here S = S + "c c++"
   "Java" + "c c++"  which is now assigned to the new variable which
here is s itself.

 So S is evaluated first so its java and then concatenated and then finally
assigned to variable.





On Fri, Aug 26, 2011 at 12:16 PM, tech coder wrote:

> in java a tring object is immutable
>
> but in following code
>
>   String s="java";
> s+="c c++";
> System.out.print(s);
>
> the output is " javac c++"
>
> why this is so
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: amazon q

2011-08-23 Thread Prem Krishna Chettri
Its Both of the BST and Heap...

Prem

On Tue, Aug 23, 2011 at 5:01 PM, sagar pareek  wrote:

> I m surprised that ur whole explanation is for me :-o
> Check ur previous post and then last post...
> i think u r confused
>
>
> On Tue, Aug 23, 2011 at 3:10 PM, WgpShashank 
> wrote:
>
>> @sagar,
>>
>> A self-balancing balancing binary search tree(Its *BST not BT )*containing n 
>> items allows the lookup, insertion, and removal of an item in
>> O(log n) worst-case time. Since it’s a BST, we can easily find out minimum
>> element in O(nlogn). please note that if it would have been simple BST not
>> Balnced BST then our complexity to lookup will changes to O(n) in worst case
>> when tree is skewed but as question say balanced BST (check out AVL/RB Tree)
>> they gureentte that look-up will O(logn) only why its true & will work you
>> need to go through tree rotation (thats used to make tree balanced & reduce
>> height ).
>>
>> Since Heap is a balanced binary tree (or almost complete binary tree but
>> not balanced BST ), insertion complexity for heap is O(logn). Also
>> complexity to get minimum in a min heap is O(logn) because removal of root
>> node causes a call to 
>> heapify(after
>>  removing the first element from the array) to maintain the heap tree
>> property. But a heap cannot be used for the above purpose as the question
>> says – insert an element if it is not already present because of this
>> constraint we can't use min-heap as well . For a heap, we cannot find out in
>> O(logn) if an element is present or not as its balanced Binary Tree(BT) , we
>> have to search all the elements e.g.in both  left & right sub-tree up-to
>> leaf so in worst case it will take O(n) time to search an element weather
>> ist present or not , then its present leave it  else insert as a last node &
>> call heapify (take O(logn)) so tottal time complexity will be O(n)+ O(logn)
>> =O(n)
>>
>>   search+heapify =O(search)
>>
>> so why correct answer is only Balanced Binary Search Tree
>>
>> Do Notify me if i missed something or wants more clarification ?
>>
>>
>> *Thanks
>> Shashank Mani
>> Computer Science
>> Birla Institute of Technology Mesra*
>>
>> --
>> 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/-/65k0xGJY6ZoJ.
>>
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Re: question on fork()

2011-08-23 Thread Prem Krishna Chettri
I Can See 10 Green and 10 Red Process.. Can Someone Compile to verify
this...

Prem

On Tue, Aug 23, 2011 at 1:24 AM, gmagog...@gmail.com wrote:

> Infinite times
> Yanan Cao
>
>
>
> On Mon, Aug 22, 2011 at 2:43 PM, Don  wrote:
>
>> // DO NOT RUN THIS! By inspection, how many times will it print "Hello
>> world"?
>> // If you find out by running it, that is cheating. Don't do it!
>> int main()
>> {
>>  int i=0, j=0;
>>  for(i = 0; i*j < 20; ++i)
>>  {
>>if (fork() > 0) ++j;
>>else i = j =  0;
>>printf("Hello world\n");
>>  }
>>  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.
>

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



Re: [algogeeks] Puzzle

2011-08-18 Thread Prem Krishna Chettri
Only N is Married.. as if L is not married that n Must be married .. Again
for M to marry N must not Marry. but as N is Married.. so.. M cannot
marry...



On Fri, Aug 19, 2011 at 9:24 AM, Dheeraj Sharma  wrote:

> M and N are married
>
>
> On Fri, Aug 19, 2011 at 5:19 AM, Abhishek Sharma 
> wrote:
>
>> M (hint: replace ü and û with their actual meaning.. u 'll understand)
>>
>>
>> On Fri, Aug 19, 2011 at 4:10 AM, payal gupta  wrote:
>>
>>> was there anything more specified
>>> Regards,
>>> PAYAL GUPTA
>>>
>>>
>>> On Fri, Aug 19, 2011 at 3:29 AM, Aditya Virmani <
>>> virmanisadi...@gmail.com> wrote:
>>>
 If ü - Married
 û - Not Married and
 M-ü N-û
 N-ü L-û
 L-û M-ü
 Who is married?

 qn was put up in this way, asked in Deloitte 2004.

 --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.
>>
>
>
>
> --
> *Dheeraj Sharma*
> Comp Engg.
> NIT Kurukshetra
> +91 8950264227
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: Memory Leak

2011-08-17 Thread Prem Krishna Chettri
Well to answer U SAMM.. M not a fresher so in my interview they wont ask me
this Rather they ask me Design Valgrind.. :D

So... I told U guys tool name Implementation is Something U can think of..

My Recommendation is Use of Stack..

Prem

On Tue, Aug 16, 2011 at 8:35 PM, SAMMM  wrote:

> If u were asked this question in an interview , wht would be your
> answer ?
>
> Using Valgrind .  If the interviewer ask without using other
> software , then wht ???
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Memory Leak

2011-08-16 Thread Prem Krishna Chettri
Use valgrind..

On Mon, Aug 15, 2011 at 10:39 AM, Ankur Khurana wrote:

> @rajeev  +1 . great software .
>
>
> On Mon, Aug 15, 2011 at 9:33 AM, rajeev bharshetty 
> wrote:
>
>> Valgrind is an effective open source tool to detect memory leaks and many
>> more bugs in the program.
>>
>> http://valgrind.org/
>>
>>
>> On Mon, Aug 15, 2011 at 6:31 AM, *$*  wrote:
>>
>>> use 
>>>
>>> _crtdumpmemoryleaks() .. will work only in debug version.
>>>
>>>
>>> On Mon, Aug 15, 2011 at 4:01 AM, Ankur Garg wrote:
>>>
 Where ever u have allocated dynamic memory that qualifies to be a
 culprit for causing memory leak ...Scan through the code if the memory 
 block
 has been deallocated or not ...


 Regards
 Ankur


 On Sun, Aug 14, 2011 at 6:03 PM, SAMMM wrote:

> How to detect in which line the Memory Leak has occured ?? I want the
> line number where the Memory leak occurs ??? Give every wild answer u
> can think off 
>
> --
> You received this message because you are subscribed to the Google
> Groups "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
  --
 You received this message because you are subscribed to the Google
 Groups "Algorithm Geeks" group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.

>>>
>>>
>>>
>>> --
>>> Thx,
>>> --Gopi
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards
>> Rajeev N B 
>>
>> "*Winners Don't do Different things , they do things Differently"*
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Ankur Khurana
> Computer Science
> Netaji Subhas Institute Of Technology
> Delhi.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] an array question

2011-08-12 Thread Prem Krishna Chettri
Amazing ,

  Kindly Follow me up :-


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

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

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




On Fri, Aug 12, 2011 at 6:16 PM, Nitin Nizhawan wrote:

> radix sort the digits wrong way (left most digit first), and then
> concatenate
>
>
> On Fri, Aug 12, 2011 at 6:12 PM, Yasir  wrote:
>
>> Kindly  check it with both the examples. It won't work.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/VlT1DNH-vPkJ.
>>
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] an array question

2011-08-12 Thread Prem Krishna Chettri
1> Sort the Array
2> Put it to the String Accordingly..


Prem

On Fri, Aug 12, 2011 at 6:04 PM, Yasir Imteyaz  wrote:

> An array of integers is given and you have to find the largest possible
> integer by concatenating all elements:
>
> example:
> array:  87  36  52
> answer:  875236
>
> array: 87 9 52
> answer: 98752
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/_lJJOlRG_ukJ.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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: amazon help

2011-08-12 Thread Prem Krishna Chettri
@ Shashank :-> Amazing one.. thx for Share.. :)

Prem










On Fri, Aug 12, 2011 at 4:15 PM, WgpShashank wrote:

> @Akshmkj , A Blog For Geeks , Fresher Might Stuck !!!
>
> http://shashank7s.blogspot.com -" Cracking The Code " You Might Enjoy
>
>
>
> Regards
> Shashank Mani
> Computer Science
> Birla institute of Technology Mesra
>
>  --
> 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/-/RNWXT-3cNusJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Pointer Question

2011-08-12 Thread Prem Krishna Chettri
Ideally Speaking all of the option here seems not matching as this is the
function pointer not an ordinary pointer.

So the closest match is b but actually its not pointing to any 2 D or 3 D
array or somewhat but rather it points to the block of memory starts from
the dynamic address of row and onwards which depends upon the function stack
on which its been pointing.



On Fri, Aug 12, 2011 at 1:42 PM, Sachin Jain wrote:

> Explanation please
>
>
> On Fri, Aug 12, 2011 at 9:33 AM, Dipankar Patro wrote:
>
>> b.
>>
>>
>> On 11 August 2011 23:20, arvind kumar  wrote:
>>
>>> b.
>>>
>>>
>>> On Thu, Aug 11, 2011 at 11:18 PM, Mani Bharathi >> > wrote:
>>>
 int(* fun()) [row][ Col];
 What should be the statement the for the above declarations
 a.fun() points to a two dimensional array
 b.pointer *fun() points to a two dimensional array
 c.pointer *fun() points to 1-dimensional array

 --
 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/-/3xkodl3aLvcJ.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from 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.
>>>
>>
>>
>>
>> --
>>
>> ___
>>
>> Please do not print this e-mail until urgent requirement. Go Green!!
>> Save Papers <=> Save Trees
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] how o/p is coming

2011-08-11 Thread Prem Krishna Chettri
Yep,

  Ideally, if() statement evaluates the last push stack value from the stack
and apparently here the last value evaluates to be 0 resulting the failure
of the if condition.

Please verify the compilation. :)

Prem

On Thu, Aug 11, 2011 at 4:21 PM, hary rathor  wrote:

> print nothing , your output is wrong
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] suggest simple code for

2011-08-08 Thread Prem Krishna Chettri
int Height (struct Tree *Node )
 {

  if(Node==NULL)

 }

On Mon, Aug 8, 2011 at 6:33 PM, jagrati verma
wrote:

>  finding the depth or height of a tree.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] realloc and malloc

2011-08-08 Thread Prem Krishna Chettri
If U Knw the inner DS of MM.. I can help U ...


MALLOC :->

Jst retrun the add of the pointer from where U shoud start the
Allocation to the point upto where U want.


Say :- > Memeory is a chuck of space which can be represented by my global
array like char Heap[1000]; Considering 1000 is the total heap size. Now I
wll take a counter variable like int Count=0; to calculate the data being
occupied.


Now here is your malloc :-


void * malloc ( int size)
   {
 void * loc = (void *) &Heap[Count];
 Count=Count + size;
 retrun loc;
   }


Now there is many flavour and check which I can explain U but probably this
is not the better way to give Demo..


enjoy ..


On Mon, Aug 8, 2011 at 5:23 PM, Aditya Virmani wrote:

> implementing these functions is not tht an easy task...google it...u ll
> find malloc for sure...thr r diff versions available.
>
>
> On Mon, Aug 8, 2011 at 10:56 AM, Aman Kumar  wrote:
>
>> Hiii
>>
>>
>> tell me how to implement own realloc and malloc and free function?
>>
>> any link for this??
>>
>> If anybody is implemented it,give code ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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: amazon question

2011-08-08 Thread Prem Krishna Chettri
When Process executed fork(). It create the Same Structure as the main
process.The only difference is the return value of the child fork process is
0 and that of parent is the PID of its Child process.
 Now you can draw the pictorial representation of the fork processes during
the execution and its corresponding values.

On Mon, Aug 8, 2011 at 12:49 PM, Kamakshii Aggarwal
wrote:

> then please elaborate?
>
>
> On Mon, Aug 8, 2011 at 12:34 PM, Pradex  wrote:
>
>> get it..!! :) :)
>>
>> On Aug 7, 10:49 pm, Shachindra A C  wrote:
>> > 8 one's and 8 two's. The order in which they get printed might vary.
>> >
>> > On Mon, Aug 8, 2011 at 11:11 AM, Kamakshii Aggarwal
>> > wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > what will be the o/p of the following program:
>> >
>> > > main()
>> > > {
>> > > int ret;
>> > > ret=fork();
>> > > ret=fork();
>> > > ret=fork();
>> > > ret=fork();
>> >
>> > > if(!ret)
>> > > printf("one");
>> > > else
>> > > printf("two");
>> > > }
>> >
>> > > --
>> > > Regards,
>> > > Kamakshi
>> > > kamakshi...@gmail.com
>> >
>> > > --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Algorithm Geeks" group.
>> > > To post to this group, send email to algogeeks@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > algogeeks+unsubscr...@googlegroups.com.
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/algogeeks?hl=en.
>> >
>> > --
>> > Regards,
>> > Shachindra A C
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Regards,
> Kamakshi
> kamakshi...@gmail.com
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] plz help with this

2011-08-02 Thread Prem Krishna Chettri
Well This is Certainly lacks logic behind the Coder.

Please remember EVERY RECURSIVE PROGRAM Need Break for certain condition.

here mid keep updating without knowing when to finish the recursion so the
code never goes below line seven..


I appreciate this way of Creating LOOP although its a good CPU hogging
program..


Keep Working... :P

On Tue, Aug 2, 2011 at 2:30 PM, Gayathri Anandan <
gayathriananda...@gmail.com> wrote:

> I didnt get any output for this pgm. I think its keep on running and
> got struck in the 6th line. Plz help with this.
>
> 1 #include
> 2 #include
> 3 int max(int a[10],int s,int e)
> 4 {
> 5 int res,res1,res2,mid=(s+e-1)/2;
> 6 res1=max(a,s,mid+1);
> 7 res2=max(a,mid+1,e);
> 8 res=res1>res2?res1:res2;
> 9 return res;
> 10 }
> void main()
> {
> int a[]={2,4,1,2,3,8,7,6,9},maxval;
> maxval=max(a,0,9);
> printf("%d",maxval);
> getch();
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] ITS NOT FAKE... Plz read and forward it.( From Micosoft Bill Gates)

2011-08-01 Thread Prem Krishna Chettri
This is Really Junk. Guys Dont Send Spam

Thx

On Mon, Aug 1, 2011 at 11:00 PM, Vamsi Achyuth wrote:

> - Forwarded Message 
> *From:* Dileep Kumar Gangunta 
> *To:* mdbedu_dil...@yahoo.co.in
> *Sent:* Mon, 1 August, 2011 11:37:59 AM
> *Subject:* Fw: Plz read and forward it.( From Micosoft Bill Gates)
>
>
> Thanks and Have a Nice day.
>
> Dileep Kumar.Gangunta
> BCP India Design Center
> Caterpillar India Private Ltd
> Melnallathur, Thiruvallur Dist - 602004
> TamilNadu, India.
> - Forwarded by Dileep Kumar Gangunta/1Z/Caterpillar on 08/01/2011 11:37
> AM -
>   *Krishnan Munirathinam/1Z/Caterpillar*
>
> 07/29/2011 04:46 PM
>To
> Senthil Kumar Rajendran/1Z/Caterpillar@Caterpillar, kichakr...@yahoo.com,
> Ramesh Babu Sakthivel/1Z/Caterpillar@Caterpillar, Jagadeesan
> Subramanian/1Z/Caterpillar@Caterpillar, Sriram
> Vellimalai/1Z/Caterpillar@Caterpillar, Deepak Arockiaraj
> Narsitty/1Z/Caterpillar@Caterpillar, Dileep Kumar
> Gangunta/1Z/Caterpillar@Caterpillar
> cc
>
>  Subject
> Fw: Plz read and forward it.( From Micosoft Bill Gates)
>
>
>
> Caterpillar: Confidential GreenRetain Until: 08/28/2011
>
>
>
> fyi
>
> Regards,
> Krishnan Munirathinam
> Team Leader - CCE
>
> BCP India Design Center, Caterpillar India Private Ltd, Thiruvallur-602004,
> India.
> Direct : + 91 44 4760 0648
> - Forwarded by Krishnan Munirathinam/1Z/Caterpillar on 07/29/2011 04:44
> PM -
>   *"Nagesh, Eattiyappan - PD" *
>
> 07/29/2011 04:42 PM
>To
>
>  cc
>
>  Subject
> FW: Fw: Fwd: Plz read and forward it.( From Micosoft Bill Gates)
>
>
>
> Caterpillar: Confidential GreenRetain Until: 08/28/2011
>
>
>
>
>
>
>
> Regards,
>
> *E.Nagesh*
> PD - Prototype
> Ext No - 186 *
> Mobile: 9944406450*
>
> This e-mail message is intended only for the use of the named recipient(s)
> and contains information which may be confidential or privileged. If you are
> not the intended recipient, be aware that any distribution, or use of the
> contents of this information is prohibited. If you have received this
> electronic transmission in error, please notify the sender and delete the
> material from the computer.
>
>
>
>
>
>
> --
> *From:* MURALI R.SURESH [mailto:suresh9...@gmail.com] *
> Sent:* Friday, July 29, 2011 4:19 PM*
> To:* a_ramesh94...@yahoo.in; aak1...@rediffmail.com; ABDUL HAKKEEM;
> abhinandan987; abuse; adept_itech; advbeebhoo; adzmedia.net;
> aiaa_n...@yahoo.com; aith_help2...@yahoomail.com; aj3...@makefortunes.com;
> akgola_1...@yahoo.co.in; aksmo...@rediffmail.com; alageshgo...@gmail.com;
> alakeshdas2...@rediffmail.com; allcantalk; aloksur_...@rediffmail.com;
> alpssoft...@yahoo.com; amalas...@hotmail.com; anandmorey;
> andyxo...@gmail.com; angaravijayasek...@yahoo.co.in;
> anjikumar...@gmail.com; antersu...@rediffmail.com; apaki...@yahoo.co.in;
> apa...@acop.com; ark_ark_...@indiatimes.com; aruka...@gmail.com;
> arulsiva1...@rediffmail.com; asha.ta...@gmail.com;
> as...@reddipoguymail.com; ashokde...@yahoo.com; avinashasabe;
> ayyapparaju_i...@yahoo.in; ayyapparajui...@yahoo.com; balapodhu; bdgs63;
> bharath...@gmail.com; blrselvaraj; brian.arrindell; bvjagan2009;
> chulbulpand...@yahoo.com; cibyja...@abcofwealth.net; complaint; contact;
> cool.irshad_a...@rediffmail.com; c...@ymail.com; crpasha;
> customerc...@idbibank.com; dpgmur...@gmail.com; d...@kpm.sfl.co.in;
> d...@kpmsfl.co.in; Nagesh, Eattiyappan - PD; english.lecturer.learner;
> finein...@rediffmail.com; gnandakumar108; gokul5620; Gopinath
> Jothiramalingam; govardhannaidu_m; hi2vijay; hivijay;
> hkharikrishn...@gmail.com; i...@fineindia.net; i...@soliquea.com;
> jaiindi...@gmail.com; Jakob Lueck; jassi; Joy Benson; kadiresanr;
> kiranjanakam; kriis...@yahoo.com; krish_t...@yahoo.com; krish...@gmail.com;
> Krishnamurthy N; kshypananth; mail2.abhiku...@gmail.com;
> mainpal...@yahoo.co.in; mainpal...@yahoo.co.in; make4u@gmail.com;
> manaruddin.sk; manoharanr86; manojk495; mariappantnp; mehul1212; micheal
> benjamin; michkae...@yahoo.com; mmadan1...@gmail.com; Mohammad Nasser;
> mpchandrareddy; msakthivel1969; msanke...@gmail.com; mukeshpd.asn;
> murali19...@gmail.com; murali251069; myservi...@relianceada.com;
> nandu1958; naveena.ck; networkerswelfaretrust; ngramachandra;
> NitinRajSale; padmalochanmohanta; pawans0203; pradeepsungs...@gmail.com;
> pranab_barman2...@rediffmail.com; prvnraaj; ptgeorgekerala; pvc786;
> r.jaganat...@ymail.com; rabifine2009; Rajesh Kamdar;
> rajesh.1...@rediffmail.com; rajesh.c1...@rediffmail.com;
> rajeshcoolka...@gmail.com; rajkamal.k2008; rajv...@in.com; ramkv03;
> ramk...@rediffmail.com; ramk...@yahoo.com; ravi071002; ravijai1959;
> reachsal...@yahoo.com; ref...@fineindia.net; rekha.thaku...@gmail.com;
> rmpvravi; rprakash17; sabirbasha63; saicool_sun...@hotmail.com;
> sa...@efmmail.com; salujasac...@hotmail.com; sandymishra8...@gmail.com;
> sanju23.1...@rediaffmail.com; sanju23.1...@rediffmail.com; saravanan.m;
> sce.prepr...@gmail.com; selvamala4..

Re: [algogeeks] DS representation.

2011-07-29 Thread Prem Krishna Chettri
For all Folks..

  DS question answer cannot be simple yes no. it is always the tradeoff of
Space and time Complexity.


On Fri, Jul 29, 2011 at 3:26 PM, rajeev bharshetty wrote:

> You can use a Hash map which maps the coefficients of the
> equation and their exponents.
> Is this feasible ??
>
>
> On Fri, Jul 29, 2011 at 3:10 PM, sunny agrawal wrote:
>
>> Array that that stores A,B,C,D,E.
>>
>> it looks like u r on some telephonic interview :P
>>
>> On Fri, Jul 29, 2011 at 3:06 PM, Puneet Gautam 
>> wrote:
>>
>>> Hi,
>>>
>>> pls tell me which data structure has following representation::
>>>
>>> A+Bx+Cx(^2)+Dx(^3)+...+Nx(^n-1).??
>>>
>>> reply asap...!!
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> Sunny Aggrawal
>> B-Tech IV year,CSI
>> Indian Institute Of Technology,Roorkee
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Regards
> Rajeev N B 
>
> "*Winners Don't do Different things , they do things Differently"*
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] DS representation.

2011-07-29 Thread Prem Krishna Chettri
SLL... Bit Field (best optimisation)...

On Fri, Jul 29, 2011 at 3:06 PM, Puneet Gautam wrote:

> Hi,
>
> pls tell me which data structure has following representation::
>
> A+Bx+Cx(^2)+Dx(^3)+...+Nx(^n-1).??
>
> reply asap...!!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] swapping 2 variables without using temporary variables

2011-07-29 Thread Prem Krishna Chettri
http://en.wikipedia.org/wiki/XOR_swap_algorithm

Answer as well as broaden you guys Concept on Memory..

Have a look

On Fri, Jul 29, 2011 at 12:54 PM, tech rascal wrote:

> can u give an explanation for ...how xor method fails for same values??
> I think it will work right...
>
>
> On Fri, Jul 29, 2011 at 12:26 PM, Prem Krishna Chettri  > wrote:
>
>> Replying to all the Above Code.
>>
>> 1> XOR operation to swap variable are not a solution as it fails for
>> swapping of same value results 0.
>>
>> 2> the Short and Sweet looking various modification of code fails to swap
>> data when U swap data between two different data type.
>>
>>
>> So I suggest you all guys to use void pointer concept to get data Swap.
>>
>>
>> Thx..
>>
>>
>> On Fri, Jul 29, 2011 at 11:35 AM, tech rascal wrote:
>>
>>> @reynald:  this won't work for floatsis there any other case u
>>> can think of, where this method won't work??
>>>
>>>
>>> 2011/7/29 A for ♥ღAakasHღ♥ 
>>>
>>>>
>>>> a=(a+b)-(b=a);
>>>>
>>>>
>>>> *Aakash Abhishek Pradhan**
>>>> **MCA Final Year,
>>>> NIT Durgapur*
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from 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] Logical operator question

2011-07-29 Thread Prem Krishna Chettri
Short and Easy..


&& Operation Check both side (if not Zero) B4 verifying the result
|| operation Check only either side.Depends on the precedence on which it
applies.

Now Work it Out.

On Fri, Jul 29, 2011 at 12:44 PM, Vijay Khandar wrote:

> Yes , so can u explai me plz, i m little bit confusing..Vijay
>
>
> On Fri, Jul 29, 2011 at 12:39 PM, Prem Krishna Chettri  > wrote:
>
>> 1
>>
>> and
>>
>> -3 -3 -4..
>>
>>
>> Verify the Compilation..
>>
>> Regards
>>  Prem
>>
>>
>> On Fri, Jul 29, 2011 at 12:35 PM, Vijay Khandar 
>> wrote:
>>
>>> Thanks, but also one small doubt
>>> If x=y=z=-4 then plz tell me o/p of
>>>  pf(++x&&++y||++z) and pf(x,y,z) these two statements.
>>>
>>>
>>> On Fri, Jul 29, 2011 at 10:52 AM, jagrati verma <
>>> jagrativermamn...@gmail.com> wrote:
>>>
>>>> vijay   x=y=z=-1
>>>>
>>>> so for ++x&&++y||++z
>>>> ++x=0
>>>> so 1st condition will get false so no increment on y's value(=-1) so
>>>> ++x&&++y=0
>>>> and ++z=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.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] Logical operator question

2011-07-29 Thread Prem Krishna Chettri
1

and

-3 -3 -4..


Verify the Compilation..

Regards
 Prem

On Fri, Jul 29, 2011 at 12:35 PM, Vijay Khandar wrote:

> Thanks, but also one small doubt
> If x=y=z=-4 then plz tell me o/p of
>  pf(++x&&++y||++z) and pf(x,y,z) these two statements.
>
>
> On Fri, Jul 29, 2011 at 10:52 AM, jagrati verma <
> jagrativermamn...@gmail.com> wrote:
>
>> vijay   x=y=z=-1
>>
>> so for ++x&&++y||++z
>> ++x=0
>> so 1st condition will get false so no increment on y's value(=-1) so
>> ++x&&++y=0
>> and ++z=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.
>

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

2011-07-28 Thread Prem Krishna Chettri
Replying to all the Above Code.

1> XOR operation to swap variable are not a solution as it fails for
swapping of same value results 0.

2> the Short and Sweet looking various modification of code fails to swap
data when U swap data between two different data type.


So I suggest you all guys to use void pointer concept to get data Swap.


Thx..

On Fri, Jul 29, 2011 at 11:35 AM, tech rascal wrote:

> @reynald:  this won't work for floatsis there any other case u can
> think of, where this method won't work??
>
>
> 2011/7/29 A for ♥ღAakasHღ♥ 
>
>>
>> a=(a+b)-(b=a);
>>
>>
>> *Aakash Abhishek Pradhan**
>> **MCA Final Year,
>> NIT Durgapur*
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from 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] Logical operator question

2011-07-28 Thread Prem Krishna Chettri
Thx Kavi.. :)

On Thu, Jul 28, 2011 at 2:59 PM, kavitha nk  wrote:

> @prem::ya its rite..
>
>
> //BE COOL//   kavi
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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 output

2011-07-28 Thread Prem Krishna Chettri
Well, this is quiet obvious even the least follower of C struct can answer
it but the good part is why does compiler is design to do so..

Hope ppls do follow me in this activation rec..

 yy *q
 struct yy (defined in somewhere)
 x..

 Guys above notation is in stack so srry again for no Whiteboard..

and yy is now not to be found as the struct is defined inside of xx whose
scope is lost as soon as we come out of this activation stack but look the
joke of this code.

there is redefinition of yy inside xx and xx have no idea about the lost
activation rec regarding yy.. so xx (lol) is lost in some inconsistency and
ask compiler to answer it..

Compiler like a BAD tech lead say Dude.. M gonna throw u out and keeps
posted with this nasty error..

Make Sense.

Regards
 Prem



On Wed, Jul 27, 2011 at 9:52 PM, Aman Goyal  wrote:

> #include‹stdio.h›
> main()
> {
> struct xx
> {
> int x;
> struct yy
> {
> char s;
>   struct xx *p;
> };
> struct yy *q;
> };
> }
>
> ouput: compiler error.
>
> Any logical reasons?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] Small Doubt

2011-07-28 Thread Prem Krishna Chettri
Hey.. good To have your Question . Well lemme try to elaborate things here
as i cannot use WhiteBoard . So Srry guys... :(

Well partly you have answered your question and some part can even be
reflected in the above thread of virtual - physical mem mapping. using MMU..
So I wont go beyond MMU.

Here it goes.

Well if you write a prg.. when it bcme process, OS assign a  bunch of ID as
Address which it can use in sense. However, this address are not what is
real add.there is what MMU kicks in...

So if 0xff U think is assigned its not actually its is mapped with something
like this .. PID + 0x0ff = xyzxyx( Hell anything let the OS answer it). that
MMU issue.

So, the question here is wat the case if the house you want is not in your
area. Dude you are not a kind to cry infront of your parent to get one for
U..

Similarly, OS will not give you the access directly to physical Mem ( under
his control ) hence, the pointer allocation may fail.

Now here comes the compiler of whatever type say g++ which may silently say
dude that house you want is unavailable or may keep quiet... but complains
when you are in need to stay in that house , or rather when you try to put
something within it.

So, the direct answer to your question is definitely your design of
Compiler. but rather I would like to say, the pointer allocation fails to
prove your address allocation.

Does that makes sense. lemme know for more without whiteboard.. :)

Regards
 Prem




On Thu, Jul 28, 2011 at 1:26 PM, MANNU  wrote:

> @Prem: Each program is provided with a pool of address, which consist
> of heap, stack etc.
> My question is that if I write an address 0xff which is
> not provided to that program then
> what will be the output?
>
> On 7/28/11, Prem Krishna Chettri  wrote:
> > First of all this is a good Question as this is use regularly in Device
> > Driver kind of Development Mode and hence there is no question of Not
> > Possible.
> >
> > So how to Do it is Question. which is as follows :-
> >
> > Point your pointer to mem add that U want and Now this Mem Add is HEX
> guys
> > (Not 4 or 5 or any base 10 val) , so put it as 0x(whatever U want).
> >
> > Do whatever  U want to do on that address using that pointer now.
> >
> > The Code above is correct but the implementation is wrong so...
> >
> >
> > #include
> > int main()
> > {
> >int *p = (int *)0xff;
> >   // *p = 4; /** Dude can U put hex val here .. Oh its already
> assigned
> > to 0xff..  **/ Now print it cout< >return 0;
> > }
> >
> > Regards
> >  Prem
> >
> > On Thu, Jul 28, 2011 at 10:44 AM, Tyler Durden <
> abhishek.khattr...@gmail.com
> >> wrote:
> >
> >> @Ankita: So when is 4000 memory address is allotted?? I mean what use
> does
> >> int *p = 4000 serve here??
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To view this discussion on the web visit
> >> https://groups.google.com/d/msg/algogeeks/-/0OU6tMQudMoJ.
> >>
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from 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] Logical operator question

2011-07-27 Thread Prem Krishna Chettri
Can SomeOne verify the Compilation as ..

1
211
1
221
1
222
0
0-10
0
00-1
0
0-1-1

Thx..

On Thu, Jul 28, 2011 at 11:47 AM, sagar pareek wrote:

> +1 @ankur  :)
>
>
> On Wed, Jul 27, 2011 at 11:23 PM, Ankur Khurana 
> wrote:
>
>> one request : dont use trubo C
>>
>>
>> On Wed, Jul 27, 2011 at 10:23 PM, Vijay Khandar 
>> wrote:
>>
>>> I m getting o/p
>>> 1
>>> 2 1 1
>>> 1
>>> 2 2 1
>>>  but on wards when x=y=z= -1
>>> then i m getting something different o/p.
>>>
>>> On Wed, Jul 27, 2011 at 10:18 PM, Jnana Sagar 
>>> wrote:
>>>
 what do u mean by o/p..actually what r u asking for..sorry to ask
 so..i couldn't get u..

 On 7/27/11, Vijay Khandar  wrote:
 > #include
 > #include
 > void main()
 > {
 > clrscr();
 > int x,y,z;
 > x=y=z=1;
 > printf("\n %d",++x||++y&&++z);
 > printf("\n %d %d %d ",x,y,z);
 > x=y=z=1;
 > printf("\n %d",++x&&++y||++z);
 > printf("\n %d %d %d",x,y,z);
 > x=y=z=1;
 > printf("\n %d",++x&&++y&&++z);
 > printf("\n %d %d %d",x,y,z);
 > x=y=z=-1;
 > printf("\n %d",++x&&++y||++z);
 > printf("\n %d %d %d",x,y,z);
 > x=y=z=-1;
 > printf("\n %d",++x||++y&&++z);
 > printf("\n %d %d %d",x,y,z);
 > x=y=z=-1;
 > printf("\n %d",++x&&++y&&++z);
 > printf("\n %d %d %d",x,y,z);
 > getch();
 > }
 >
 > plz anyone provide the o/p for this program.I m very much
 > confusing
 >
 > --
 > You received this message because you are subscribed to the Google
 Groups
 > "Algorithm Geeks" group.
 > To post to this group, send email to algogeeks@googlegroups.com.
 > To unsubscribe from 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.
>>>
>>
>>
>>
>> --
>> Ankur Khurana
>> Computer Science
>> Netaji Subhas Institute Of Technology
>> Delhi.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> **Regards
> SAGAR PAREEK
> COMPUTER SCIENCE AND ENGINEERING
> NIT ALLAHABAD
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

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



Re: [algogeeks] Small Doubt

2011-07-27 Thread Prem Krishna Chettri
First of all this is a good Question as this is use regularly in Device
Driver kind of Development Mode and hence there is no question of Not
Possible.

So how to Do it is Question. which is as follows :-

Point your pointer to mem add that U want and Now this Mem Add is HEX guys
(Not 4 or 5 or any base 10 val) , so put it as 0x(whatever U want).

Do whatever  U want to do on that address using that pointer now.

The Code above is correct but the implementation is wrong so...


#include
int main()
{
   int *p = (int *)0xff;
  // *p = 4; /** Dude can U put hex val here .. Oh its already assigned
to 0xff..  **/ Now print it cout< wrote:

> @Ankita: So when is 4000 memory address is allotted?? I mean what use does
> int *p = 4000 serve here??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/0OU6tMQudMoJ.
>
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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] The Google Resume

2011-07-27 Thread Prem Krishna Chettri
Anyone got this book?? pdf.. or URL link is highly appreciated.

Thx..

On Tue, Jul 26, 2011 at 8:37 PM, Ankur Garg  wrote:

> +1
> Me too looking out for the same :(
>
>
> On Tue, Jul 26, 2011 at 7:10 PM, Saravanan T wrote:
>
>> +1
>>
>> Pls send to my email id as well..
>>
>>
>> On Tue, Jul 26, 2011 at 7:09 PM, Akshata Sharma <
>> akshatasharm...@gmail.com> wrote:
>>
>>> Anyone having the Google Resume book pdf?
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from 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: size of self referential structure

2011-07-26 Thread Prem Krishna Chettri
Its Cos that is pointer and all pointers is 4 bytes address..

On Tue, Jul 26, 2011 at 7:11 PM, Puneet Gautam wrote:

> @everyone:
> I have this mind strangling doubt..!!!
>
> Why is "char *s[5]" of 20 bytes...?
>
> yes the output is 28...
>
> On 7/26/11, Don  wrote:
> > A reasonable guess would be 28 bytes. But the size of a structure is
> > implementation dependent, and therefore, some other result could be
> > correct as well.
> > Don
> >
> > On Jul 26, 7:40 am, Puneet Gautam  wrote:
> >> #include
> >> #include
> >> struct node{
> >>int a;
> >>char *b[5];
> >>struct node *link;
> >>};
> >> main()
> >> {
> >>   int a;
> >>   a=sizeof(struct node);
> >>   printf("%d",a);
> >>   getchar();
> >>   return 0;
> >>   }
> >>
> >> Whats the output..?
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from 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: doubt in evaluating in expression

2011-07-25 Thread Prem Krishna Chettri
Well Guys,

  Jst to through some light on last Query.i.e y=++x + (++x + ++x) ;

if you check the current activation record there is space allocated for only
one variable that goes on changing till you dont violate the pint Rule.

So you both are correct.. it will print 18 and yeah the value is computed as
(++x + ++x ) and than + to ++x.. its only cox all the variables are same x
which will get evaluated finally as 6 before final addition.


Please feel free to comment on my understanding.. ;)

Prem


On Mon, Jul 25, 2011 at 3:50 PM, Arun Vishwanathan
wrote:

> well I dint expect that value for y:)!! thot it wud be 16 again..but since
> u ask me to guess i wud say that as we go left to right , the first
> preincrement causes x to be 4 and the ones within the bracket cos it to be 5
> and then 6:Now first addition within the braces is 6+6=12 and then this is
> added to 6(since x was already incremented earlier) to be 18..hey it is a
> totally wild guess
> what is the right approach here?:)
>
>
>
> On Mon, Jul 25, 2011 at 12:10 PM, sagar pareek wrote:
>
>> yeah u are right   :)
>> try this one:-
>>
>> x=3;
>> y=++x + (++x + ++x);
>>
>> answer is y=18   guess why ?
>>
>>
>> On Mon, Jul 25, 2011 at 2:27 PM, Arun Vishwanathan <
>> aaron.nar...@gmail.com> wrote:
>>
>>> thanks sagar!
>>> so just to confirm ,what i get from above is that the x value before the
>>> first addition is first updated from 3 to 5( due to 2 pre increments) and
>>> then 5 and  5 is added to make the 10.This is then added to 6( as before the
>>> second addition x is updated again)
>>>
>>> if y = x++ + ++x + x++
>>> then will the value seem like for the first addition(x++ + ++x ) as
>>> 4+4?(since the single pre increment increases the value of x by 1) ,and then
>>> for the next addition it would be 8+4(since post increment here so x doesnt
>>> change)?finally the value of x is 6?
>>> pls correct me if wrong ...
>>>
>>>
>>>
>>>
>>> On Mon, Jul 25, 2011 at 10:21 AM, sagar pareek wrote:
>>>
 Well its not like that
 first u have x=3;
 now u have to do
 y=++x + ++x + ++X;
 before doing first addition
 y=(++x + ++x) + ++x;
^  ^

 above spotted x will increase , before their addition
 and then
 y= 5+5 + ++x;
 now
 y=10+ 6
 y=16;

 hope u now get it :)


 On Sun, Jul 24, 2011 at 2:30 PM, Arun Vishwanathan <
 aaron.nar...@gmail.com> wrote:

> *x= 3 initially
>
>
> On Sun, Jul 24, 2011 at 11:00 AM, Arun Vishwanathan <
> aaron.nar...@gmail.com> wrote:
>
>> if that is the case as u say, then wont it be 3+ 4+ 5 when x +3
>> initially?..and then x increments by one later due to the single post
>> increment
>>
>>
>> On Sun, Jul 24, 2011 at 10:15 AM, sagar pareek > > wrote:
>>
>>> nope compiler read it from left to right
>>>
>>>
>>> On Sun, Jul 24, 2011 at 12:05 AM, Arun Vishwanathan <
>>> aaron.nar...@gmail.com> wrote:
>>>
 @sagar: if what u said previously holds as in when u say y=x++ + ++x
 is evaluated as 4+4 since ++x results in 4 and 4 is used in x++ too 
 (cos
 post increment increments x later) then for y=x++ + ++x + ++x with x
 beginning as 3 shud the expression not be evaluated as 5+5+4( from rhs 
 ++x
 does a 3 to 4 and another ++x does 4 to 5 and 5 is used in x++) .later 
 x
 becomes 6 ?




 On Sat, Jul 23, 2011 at 2:39 PM, sagar pareek <
 sagarpar...@gmail.com> wrote:

> sorry for above...typo mistake :-
>
>  yup
> but what about this
> x=3;
>  y= x++ + ++x + ++x; // it is executed as:-
>
> during first addition, increase the value of x, now first addition
> will be 4+4 + ++x;
> now for second addition it will be like
> 8+5
> hence final value of y=13;
> do it by urself
>
> On Sat, Jul 23, 2011 at 6:09 PM, sagar pareek <
> sagarpar...@gmail.com> wrote:
>
>> yup
>> but what about this
>> x=4;
>> y= x++ + ++x + ++x; // it is executed as:-
>>
>> during first addition, increase the value of x, now first addition
>> will be 4+4 + ++x;
>> now for second addition it will be like
>> 8+5
>> hence final value of y=13;
>> do it by urself
>>
>> On Sat, Jul 23, 2011 at 2:54 PM, shady  wrote:
>>
>>> @sagar
>>> would it get evaluated like this ?
>>> supposing x = 3;
>>>
>>> y = x++ + ++x; becomes y = (x=x+1) + (x=x+1);
>>> then x=x+1;
>>>
>>> so x = 5, y = 8;
>>>
>>> On Sat, Jul 23, 2011 at 2:48 PM, sagar pareek <
>>> sagarpar...@gmail.com> wrote:
>>>
 @Venga
 if u are doing this
 y

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Prem Krishna Chettri
Values will be Pushed to the Stack from left to right and Evaluated to be
finally printed from the Stack.

On Fri, Jul 22, 2011 at 4:01 PM, rShetty  wrote:

> #include
>
>  int main()
>  {
>
> int i=1;
> printf("%d%d%d%d",++i,++i,++i,i++);
>
>  return 0;
>
> }
>
> Explain how it will be evaluated ?? and the output obtained ..
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from 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]

2011-07-21 Thread Prem Krishna Chettri
If u check the real call Stack .. rather Activation record you will
understand the details ..
but as of now I can see that a *a is one value in stack and a *b is another
..
So when U call any value with b object its b value.. so a wont be
effected... but yeah its depends on Memory Model as well as far as the
return value is concern.

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