**Source:**Quant interview at Religare Technova

**Problem:**Write a C program to compare two integers without using relational operators (== != < <= > >=)

A collection of ~225 Puzzles with Solutions (classified by difficulty and topic)

Let

Update (31 January 2011)

Given a permutation *p* of length *n*, let *c(p)* be the number of cycles in *p*. Suppose *p* is drawn uniformly from the set of all permutations. Show that

Expectation of 2 raised to the power of number of cycles is *n+1*, i.e E[*2^c(p)*]=*(n+1)*

1) There is no high funda group theory/number theory involved. I could solve this in 15 minutes \m/ \m/

2) After you are done, you might want to read this (*Spoiler Alert*)

Hint posted by Nikhil Garg (CSE, IIT Delhi third year undergraduate student) in comments! Solution posted by Kalyan in comments! Kalyan's comment explained in detail by me in comments! A simpler solution posted by Gaurav Sinha (chera) (CSE IITK 1996 Alumnus, Indian Revenue Service) in comments!

Update: (23 January 2011)

Note that we solved a similar problem and got the value of E(n,1) some time back in this problem.

Subscribe to:
Posts (Atom)