Skip to main content
nkvns's user avatar
nkvns's user avatar
nkvns's user avatar
nkvns
  • Member for 4 years, 8 months
  • Last seen more than a month ago
accepted
Loading…
answered
Loading…
comment
My tic tac toe minimax implementation
@JDługosz: You are correct. Regular bool won't help as it can hold only two states. But we can use std optional<bool>. Or enum class will three values.
answered
Loading…
comment
Detect loop in rectilinear path
@Reinderien: No restriction on range assumed.
comment
Detect loop in rectilinear path
Coordinates are guaranteed to be integers. No restriction on number of points.
comment
Detect loop in rectilinear path
@MartinR: There is an assumption that overlapping segments will be merged during sanitization step before calling into check_loop. So in your example, input should become (3, 0) -> (3, 1) ->(0, 1)->(0, 0)->(3, 0). It will become a loop.
asked
Loading…
comment
A priority based timer using priority queue
Again priority queue is a utility. It needn't know details about its user. User need to send data over which it wants prioritised view.
comment
Serialize and deserialize binary search tree
I think you meant replace serialize_tree by print_tree
comment
A priority based timer using priority queue
Caller of CreateNode should send correctly populated nodedata as void*. It means caller will create TimerInfo, set refTime and pass this as void* to CreateNode. CreateNode needn't look inside nodedata.
comment
A priority based timer using priority queue
@xyf: Added comparator. TimerInfo will keep reftime, which will set when corresponding node is pushed to the queue.
revised
A priority based timer using priority queue
added 1327 characters in body
Loading…
awarded
comment
A priority based timer using priority queue
+1 @G.Sliepen. Keeping separate struct for priority_queue and priority_queue_node will help reduce memory overhead because of comparator
comment
A priority based timer using priority queue
Yes, I am referring to binary heap.
comment
A priority based timer using priority queue
@xyf: Purpose of priority queue is to give nodes based on increasing/decreasing priority. But priority is not defined by queue. It is property of nodedata. So, priority queue will need a comparator to come up with sorted order. Comaprator may know all relevant details about nodedata and its internal properties. So in current example, comparator needs to know about expiry time and priority value (Because if expiry time is same, we pick timer based on priority).