I. Find the acute angle between the minute and hour needle of a clock for a given time H:M?
Minute needle angle, m = M * (360/60) = 6M
Hour needle Angle, h = H * (360/12) + M * ( (360/12) / 60) = 30H + M/2
Solution 1:
Acute Angle = arccos(cos(h-m))
Hint: Cos() will bring all angle from -1 to 1 range and arccos() will bring that to 0 to 180(pi)
Solution 2:
Difference in angle, d = |h-m|
or
d = (h-m)%360
Opposite angle, od = 360 - d
Acute angle = 180 - x
Obtuse angle = 180 + x
where x = |(od - d)/2| = |180 - d|
i.e, Acute Angle = 180 - |180-d|
II. Given a circular queue of size n (0..n-1). Other variables are front and rear of the queue. Find a formula to find number of elements in queue from n, front and rear?
Solution:
number of elements = (rear - front) % n
That is the magic of mod operator.
Subscribe to:
Post Comments (Atom)
Linux Command Line and Shell Scripting Bible
Linux Command Line and Shell Scripting Bible, 4th Edition, by Richard Blum and Christine Bresnahan is a complete guide for software profess...
-
Linux Command Line and Shell Scripting Bible, 4th Edition, by Richard Blum and Christine Bresnahan is a complete guide for software profess...
-
Its an award winning documentary depicting the new world order, the latest phenomenon of our age, the new world citizen - The corporation. T...
-
This novel in Malayalam is from an eminent writer and activist Sara Joseph. It has got Kendra Sahithya Academy award. The characters illustr...
No comments:
Post a Comment