The Learning Curve
programming ..!
Sunday, July 28, 2013
Segment Tree
This is an amazing tree, simple but yet extremely elegant for find min/max in of a range $[a, b]$.
Problem
Given an array of number $A[1...n]$ (unsorted), what is the fastest way to answer the following query:
1) min_query(i, j): return the minimum value between indexes $(i, j)$ where $0 \leq i \leq j \leq N$
2) max_query(i, j): return the minimum value between indexes $(i, j)$ where $0 \leq i \leq j \leq N$
The naive approach to this problem would be: loop through all element from a to b and update the max (or min):
Tuesday, March 29, 2011
Study Habits - Avoiding the Last Minutes Blues
Virtually every topic is interesting to someone, somewhere. I'm not particularly interested in the sex life of the South American tree fog. However, a biologist might be fascinated. (Another tree frog might be, too.) If you wait for teachers to "make" their courses interesting, you are missing the point. Interest is a matter of your attitude. It's mistake to blame poor performance on events "beyond your control". Students who believe that success is based on effort tend to do better in the long run (Noel et al, 1987).
Cool, Dennis. Essential of Psychology Exploration and Application - 8th Edition. Wadsworth, Thomson Learning. 2000. Print.
Saturday, March 19, 2011
Subscribe to:
Posts (Atom)