In descending order.
$2^{\lg^* n}$ $\lg^* n$ $\lg (\lg^* n)$
We consider
func (l *Log) MInsertIndex(day string) int { | |
lBound := 0 | |
uBound := len(l.Measurements) | |
for uBound > lBound { | |
mid := (uBound + lBound) / 2 | |
cmpResult := cmp.Compare(l.Measurements[mid].Day, day) | |
if cmpResult <= 0 && lBound == mid { | |
lBound += 1 |
There is a part in CLRS chapter 3 where they have
a. Restrict the domain to powers of 2, so
We have
$$ \begin{align}
class Table | |
def initialize(n, firstValue) | |
@m = {} | |
(0...n).each do |i| | |
@m[i] = {} | |
(0...n).each do |j| | |
@m[i][j] = firstValue | |
end | |
end | |
end |
#!/usr/bin/ruby | |
#require 'test/unit' | |
require 'test/unit/testcase' | |
class TestBST < Test::Unit::TestCase | |
# ... tests omitted... | |
def test_no_crashes |
using System; | |
class EnemyTowers | |
{ | |
const int INF = int.MaxValue; | |
public int sim( int s, int h, int a, int t) | |
{ | |
int ret = 0; | |
int p = h; | |
while( s > 0 && t > 0 ) { |
// requires prototype for some of its synctactic sugar | |
var Undiscovered = 0; | |
var Discovered = 1; | |
var Processed = 2; | |
var time = 0; | |
var scc_count = 0; | |
var states = {}; | |
var et = {}; | |
var low = {}; |