[algogeeks] is given number is lucky..?

2012-08-03 Thread Divesh Dixit
 Write a funtion 
boolean is_lucky(int x ) {}
a number is said to lucky 
http://en.wikipedia.org/wiki/Lucky_numbe...

O(n)  solution is required...? 

-- 
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/-/kipmgqadXrYJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from 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] MicroSoft Interview Question-9 February 2011

2011-02-09 Thread Divesh Dixit
1. write a function to convert a decimal no. to Roman no.  (10 marks)
2. Design a elevators system for 50 storied hotel.
  condition are... at least one left should be available on ground
flore. Min. time is expected ot reach the any floore...  (5 marks)
3. Design all the test case for function
String  stringReverse("i am a good boy") ---> out put is (boy
good a am i) ;
4. Do the boundary level and partition equivalence testing for the
following specification.
   below 18 years  too young to get insured
   between 18 to 30 both inclusive get insured with 20% Discount.
   above 30 get insured.
5.  output
   a = 10;
   b=a+++a;
   what is a and b ?   a = 11 and b=20
6. foo(int x)
   {   if(x>0)
  foo(--x);
   printf("%d",x);
   }
  int main()
   { foo(5);
   }
output = 0,0,1,2,3,4,5
7. char m[16]="MicroSoft";
 a = 2 ; will the folloing code will compile if yes then output?
Printf("%d%d",(a+3)m,m(2)) some thing like but the answer was
"sf"
8. one network objective quetion.. which layer is responsible for the
reliable delivery of packets..
Transport Layer
9. one mathematical quetion on realibilty is 90% and MTTF(mean time to
failure) = 200 days. if
   it would be 95%. and 5 day for repair.. then what MTTF
   {a.200 b.205 c. 500 d.700 }
10. Output of Sql query
 Translate((Replace(Ltrim(Rtrim("$$JUNK##"),#),
$)JU,**),*,'trouble');

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



[algogeeks] Re: add two numbers using bitwise operators

2010-12-31 Thread Divesh Dixit
@rajeev
it is a Full Adder (digital electronics) .. code..

On Dec 31, 6:05 pm, Manmeet Singh  wrote:
> Go through gates in Electronics, code will be easy to visualize.
>
> On Fri, Dec 31, 2010 at 6:33 PM, juver++  wrote:
> > Yeah, add bits one by one from right to left, as for ordinary addition of
> > two numbers in 10-th radix
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.

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



[algogeeks] Re: puzzle

2010-12-31 Thread Divesh Dixit
@vanadana
why are you calculating 3 complete... use minimized distance..
min.{ sqrt(4^2+x^2)+sqrt(3^2+(5-x)^2)};

so final answer is 8.6023144 units..

On Dec 31, 4:30 pm, Vandana Bachani  wrote:
> The ant needs to cover: 9.403 units. It will need to pass the diagonal of
> the side (4 by 5) and go up or down the side 3 units.
> 3+ sqrt(16+25)
>
> On Fri, Dec 31, 2010 at 4:16 PM, bittu  wrote:
>
> > 2nd puzzle
>
> > An ant has to crawl from one corner of a room to the diametrically
> > opposite corner as quickly as possible. If the dimensions of the room
> > are 3 x 4 x 5, what distance does the ant cover?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.

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



[algogeeks] C output... ???

2010-12-14 Thread Divesh Dixit
#define SIZE 10
  void size(int arr[SIZE])
  {
  printf("size of array is:%d\n",sizeof(arr));
  }

  int main()
  {
  int arr[SIZE];
  size(arr);
  return 0;
  }

the out put should be 40 considering 4 byte integer...

but out put is only 4... how this is possible...
and again if we modify it
#define SIZE 10
int main()
  {
  int arr[SIZE];
  printf("size of array is:%d\n",sizeof(arr));
  return 0;
  }
we are getting the desired output as 40 byte...

thankyou 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Swap the LSB and MSB within themself of given no.

2010-11-20 Thread Divesh Dixit
assuming all are 8bit no.
input = 0x46  (0100   0110)
 output = 0x26 ( 0010  0110 )
input = 0x75 (0111  0101)
output = 0xFC (1110  1010 )

Algorithm..???

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



[algogeeks] Re: Algorithm to determine the largest number of envelopes that can be nested inside one another.

2010-09-29 Thread Divesh Dixit
@Sathaian
Please explain
"Then find the longest increasing sequence of yi's -> nlog(n) "
how to find this...??
Ex. (1,2) (2,13) (5,10) (7,9)(9,1)
 xi are sorted  what will be the algo.. next??

On Sep 29, 8:55 am, Sathaiah Dontula  wrote:
> I think we can do like this,
>
> 1. Sort all the xi's in ascending order -> nlog(n)
> 2. Then find the longest increasing sequence of yi's -> nlog(n)
> 3. complexity will be nlog(n).
>
> Thanks,
> Sathaiah Dontula
>
> On Tue, Sep 28, 2010 at 11:37 PM, Prashant Kulkarni <
>
> prashant.r.k...@gmail.com> wrote:
> > i think it is similar to finding max in a list  O(n) or sorting algorithm
> > O(n log n)
>
> > -- Prashant Kulkarni
>
> > On Tue, Sep 28, 2010 at 11:33 PM, Rahul Singal 
> > wrote:
>
> >> A possible solution  i can think is create a directed graph where each
> >> vertex is a envelope and edges are from a bigger envelope to smaller
> >> envelope ( one which can fit in bigger envelope ) . Now the problem is
> >> reduce to finding longest path in the graph .
>
> >> Regards
> >> Rahul
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algoge...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/algogeeks?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.

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



[algogeeks] Algorithm to determine the largest number of envelopes that can be nested inside one another.

2010-09-28 Thread Divesh Dixit
You are given an unlimited number of each of n different types of
envelopes. The dimensions of envelope type i are xi × yi.(i is in sub
script) In nesting envelopes inside one another, you can place
envelope A inside envelope B if and only if the dimensions A are
strictly smaller than the dimensions of B.
Algorithm to determine the largest number of envelopes that can be
nested inside one another.

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



[algogeeks] find out the mid point of a single linked list

2010-09-28 Thread Divesh Dixit
Given a singly-linked, find out (just give the basic logic) the mid
point of a single linked list in a single parse of the list. Assume
the program would be loaded in read-only memory so no manipulation of
the list is allowed.

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



[algogeeks] finding largest and second largest elements

2010-09-23 Thread Divesh Dixit
finding largest and second largest elements from a set of n elements
by means of
  Minimum comparison of  n+celling(log n) +2

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



[algogeeks] decimal to binary and binary to decimal.....conversion algorithm

2010-09-23 Thread Divesh Dixit
can some one suggest Algo
a>  n-bit  binary number to decimal;

b>  n-bit decimal to binary.

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



[algogeeks] help required...

2010-09-22 Thread Divesh Dixit
Among n people, a celebrity is defined as someone who is known to
everyone, but who knows no
one. Design and analyze to identify the celebrity, if one exists, by
asking only questions of the
following form: "Excuse me, do you know person x?" You will get a
binary answer for each such
question asked. Find the celebrity by asking only O(n) questions.

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



[algogeeks] Print 1 to n one per each line on the standard output

2010-09-22 Thread Divesh Dixit
Write an algorithm that will print 1 to n, one per each line on the
standard output, where n is
a integer parameter to the algorithm. An algorithm should not use
while, for, do-while
loops, goto statement, recursion, and switch statement.

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



[algogeeks] Re: Amazon Interview

2010-09-22 Thread Divesh Dixit
These a reverse of binary search
1. iteration would be 1,2,4,8,16,32...
2. ex.   array a has the infinity 0's . Let it be n(very
large)
   count=1;
   for(i=1;i wrote:
> A file is given with many 0s stored in continuous way , store it in
> another file such that when you store try saving the space by using
> minimum amount of space. When you want to create the original file ,
> you should be able to do so with the new file created

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



[algogeeks] Re: Linux

2010-09-22 Thread Divesh Dixit
@Dave
  ya i got it heat -10 output through pipe tail -6.  but can u
explain "foo"??


On Sep 21, 10:25 pm, Dave  wrote:
> If you can use both, it would be
>
> head -10 foo | tail -6
>
> It doesn't do the right thing if the file has fewer than 10 lines,
> though.
>
> Dave
>
> On Sep 21, 4:04 pm, Divesh Dixit 
> wrote:
>
> > How to get  line no. 5 to line no. 10  only from a file.. using tail
> > or head command.?

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



[algogeeks] Linux

2010-09-21 Thread Divesh Dixit
How to get  line no. 5 to line no. 10  only from a file.. using tail
or head command.?

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