ڈسکریٹ میتھ کی مشق

Algorithms / Offline Sorting Sweep

Least You Need to Know: Offline Sorting, Event Sweeps, and Ordered Processing

Offline processing sorts updates, queries, or events by a key so work can be done in one monotone sweep. The key insight is to answer many questions by **maintaining a moving frontier** rather than restarting from scratch for each query.

جو کم از کم جاننا ضروری ہے

اہم علامتیں

event update or query processed in the sweep order
sweep key sorted coordinate or threshold used to order events
active set information currently maintained while sweeping

مختصر حل شدہ مثال

  • Suppose queries ask how many intervals start before position `x`.
  • Sort interval starts and queries by position.
  • Sweep left to right, adding intervals as they become active.
  • Each query is answered from the current maintained state instead of rescanning all intervals.

عام غلطیاں

اس قسم کے سوال کو کیسے پہچانیں

مشق شروع کریں