Skip to content

Commit

Permalink
Merge pull request #178 from artkpv/patch-1
Browse files Browse the repository at this point in the history
Ex. 14.3-3 change
  • Loading branch information
Zhenchao Gan authored Nov 23, 2017
2 parents 9a1b73a + e8abbb5 commit 8da4287
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions C14-Augmenting-Data-Structures/14.3.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ Describe an efficient algorithm that, given an interval i, returns an interval o

### `Answer`

MIN-INTERVAL-SEARCH(T, i)
x <- root[T]
res <- INT_MAX
while x != nil[T]
if i overlap int[x]
res <- min(res, low[x])
do if left[x] != nil[T] and max[left[x]] >= low[i]
then x<-left[x]
else x<-right[x]
return x
MIN-INTERVAL-SEARCH(T,i):
x = T.root
while x != T.nil:
if x.left != T.nil and i.low <= x.left.max:
x = x.left
elif x.int overlaps i:
break
else
x = x.right
return x


### Exercises 14.3-4
***
Expand Down

0 comments on commit 8da4287

Please sign in to comment.