Returns the number of occurrences of num in interval [start, end] in the list >>> root = build_tree(test_array) >>> rank(root, 6, 3, 13) 2 >>> rank(root, 2, 0, 19) 4 >>> rank(root, 9, 2 ,2) 0 >>> rank(root, 0, 5, 10) 2
(node: Node | None, num: int, start: int, end: int)
| 98 | |
| 99 | |
| 100 | def rank(node: Node | None, num: int, start: int, end: int) -> int: |
| 101 | """ |
| 102 | Returns the number of occurrences of num in interval [start, end] in the list |
| 103 | |
| 104 | >>> root = build_tree(test_array) |
| 105 | >>> rank(root, 6, 3, 13) |
| 106 | 2 |
| 107 | >>> rank(root, 2, 0, 19) |
| 108 | 4 |
| 109 | >>> rank(root, 9, 2 ,2) |
| 110 | 0 |
| 111 | >>> rank(root, 0, 5, 10) |
| 112 | 2 |
| 113 | """ |
| 114 | if start > end: |
| 115 | return 0 |
| 116 | rank_till_end = rank_till_index(node, num, end) |
| 117 | rank_before_start = rank_till_index(node, num, start - 1) |
| 118 | return rank_till_end - rank_before_start |
| 119 | |
| 120 | |
| 121 | def quantile(node: Node | None, index: int, start: int, end: int) -> int: |
nothing calls this directly
no test coverage detected