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.
Showing posts with label computer science. Show all posts
Showing posts with label computer science. Show all posts
Wednesday, August 6, 2008
Subscribe to:
Comments (Atom)
Ka’aba
Here’s a condensed summary of all your reflections and frameworks, designed as a weekly reflection checklist to revisit and realign your l...
-
Linux Command Line and Shell Scripting Bible, 4th Edition, by Richard Blum and Christine Bresnahan is a complete guide for software profess...
-
I am better informed of American history after reading this book than before. This book covers breadth, but examines certain topics deep eno...
-
Life without a company of woman is really tough, especially if we miss one. I have just completed a novel on a similar theme. But what I wan...