Re: [algogeeks] Re: HOW TO CALCULATE THA size of union

2012-12-10 Thread ashish mann
 union A{
  long int y[5];
  union B{
   double g;
   union C{
int k;
union D{
  char ch;
  int x[5];
 };
};
 };
};

just removed the instances of unions from the given declaration and
tested on dev
A 20
B 8
C 4
D 20


On Sat, Dec 8, 2012 at 6:39 PM, shiv narayan narayan.shiv...@gmail.comwrote:

 but when i compile it on Dev C it gives 24..whats the reason ?


 On Fri, Dec 7, 2012 at 7:19 AM, Don dondod...@gmail.com wrote:

 The actual size is system dependent because the language doesn't
 specify the size of int or long int.
 I'll assuming the common convention that sizeof(int)=4 and sizeof(long
 int)=8.
 The size of a union is the size of the largest element in the union.
 So sizeof(D) = 5*sizeof(int)=20
 C and B will be the same, because there is nothing bigger in any of
 them.
 sizeof(A) will be 40 which is the size of an array of eight long ints.
 Don


 On Dec 7, 5:42 am, zerobyzero narayan.shiv...@gmail.com wrote:
  what will be the size of union A ,B,C and D. also please explain the
 logic.
 
  * union A{*
  *  long int y[5];*
  *  union B{*
  *double g;*
  *union C{*
  *  int k;*
  *  union D{*
  *char ch;*
  *int x[5];*
  *  }s;*
  *}a;*
  *  }b;*
  *}*p;*

 --





 --
 Shiv Narayan Sharma
 Jt. Secretary CSI-DTU
 +919971228389
 www.jugadengg.com



  --






-- 
Regards,
Aashish Mann

-- 




[algogeeks] LOGIC!!!

2012-08-30 Thread ashish mann
Q. A company organizes two foreign trips for its employees yearly. Aim of
the trip is to increase interaction among the employees of the company and
hence company wants each of his employee to see new people on the trip and
not even a single person with whom he has worked in past. Therefore it is a
rule in company that in any of the trips, all the employees should be new
to each other and no two of them should have worked together in past.


Given the work history of each employee (which people he has worked with
sometimes in past), you have to tell whether all of the employees can be
accommodated within trips without violating the above rule or not. Each
employee is given a unique integer ID by which they are recognized. You can
also assume that each employee has worked with at least one other employee
in past.



*Note: *No employee can be in both trips and every employee must be part of
one trip.


*Example: *

i) Suppose the work history is given as follows: {(1,2),(2,3),(3,4)}; then
it is possible to accommodate all the four employees in two trips (one trip
consisting of employees 1 3 and other having employees 2  4). Neither of
the two employees in the same trip have worked together in past.

ii) Suppose the work history is given as {(1,2),(1,3),(2,3)} then there is
no way possible to have two trips satisfying the company rule and
accommodating all the employees.

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

2011-07-18 Thread ashish mann
A little better way would be
x + y = p = (n*(n+1))/2 - (sum of all elements of array).
x * y  = q = n! / (product of all elements of the array).

now solve the quadratic eqn.
z^2 - (sum of the roots)z + (product of the roots)  = 0

On Mon, Jul 18, 2011 at 5:27 PM, varun pahwa varunpahwa2...@gmail.comwrote:

 make two equations as .
 suppose numbers to be x,y
 x + y = p = (n*(n+1))/2 - (sum of all elements of array).

 x^2 + y^2 = q = (n*(n+1)*(2n+1))/6 - (sum of square of all elements of
 array).

 so 2*x*y can be calculated as (p^2 - q);

 so, a quad equation is formed as you now (x + y) and (2*xy).

 P.S. :: overflow is not handled.

 Please comment.

 On Mon, Jul 18, 2011 at 5:01 PM, TUSHAR_MCA tusharkanta.r...@gmail.comwrote:

 Given an array of size n. It contains numbers in the range 1 to n.
 Each number is present at least once except for 2 numbers. Find the
 missing numbers ?

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




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

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

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




-- 
Regards,
Aashish Mann
Software Engineer
Vihaan Networks Ltd.,Gurgaon

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