GATE Computer ScienceHardGATE CS (PYQ pattern)
Graham scan or Andrew's monotone chain is used on the points (0,0), (4,1), (2,2), (6,3), (3,5), (8,6), (5,7), (1,8), (7,3), (4,4), (2,6), (9,4), (5,0), (0,5). How many points lie on the convex hull (no input point lies on a hull edge between two hull vertices)?
- A. 6
- B. 8
- C. 9
- D. 7
Correct answer: D. 7
The hull is (0,0), (5,0), (9,4), (8,6), (5,7), (1,8), (0,5); every other point is strictly inside. Counter-clockwise turns are tested with the cross product, popping points that make a clockwise or collinear turn.
More Algorithms questions
- A Fenwick tree (binary indexed tree) over positions 1–100 performs update(i) by visiting i, then i + (i & −i), and so on while the index…
- The Z-array of a string s has Z[i] = length of the longest common prefix of s and s[i..]. (Z[0] is taken as 0.) What is the sum of all Z…
- What is the length of the longest palindromic substring (contiguous) of xabcbaxyzzyxabcdcbay?
- Consider the congruence 46x ≡ 18 (mod 240). How many solutions x does it have in 0…239, and what is the smallest one?
- How many integers in 1…1000 are coprime to 360?
- A dynamic array has capacity 1 initially. An append to a full array doubles the capacity (copying all n current elements); after a…