-
a. b.
-
No. Suppose k = 1, then in this case it would take B as the only successor and force BC as the path to the goal even though AC is better.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* q1: *) | |
fun insert (v, []) = [v] | |
| insert (v, (h::t)) = | |
if (v < h) then v::(h::t) | |
else h::(insert (v,t)); | |
(* q2: *) | |
local | |
fun helper [] acc = acc | |
| helper (h::t) acc = helper t (insert (h, acc)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
) | |
// This is our type which matches the JSON object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in {1..100} | |
do | |
vars=`expr $RANDOM % 20` | |
vars=`expr $vars + 2` | |
tests=`expr $RANDOM % $vars` | |
tests=`expr $tests + $RANDOM % $vars` | |
tests=`expr $tests + $RANDOM % $vars` | |
tests=`expr $tests + $RANDOM % $vars` | |
tests=`expr $tests + $RANDOM % $vars` | |
tests=`expr $tests + $RANDOM % $vars` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (String word : list) { | |
if (!otherTrie.matchPrefix(trie.getPrefix(word))) | |
System.out.println("matchPrefix Error for word " + word + " "); | |
List<String> otherTrieResult = otherTrie.findCompletions(word); | |
List<String> trieResult = trie.getAllPrefixMatches(word); | |
if (!(otherTrieResult.containsAll(trieResult) && trieResult | |
.containsAll(otherTrieResult))) { | |
throw new RuntimeException("autocomplete " + word + " "); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package a2posted; | |
import java.util.HashMap; | |
public class UnitTester { | |
public static void main(String... args) { | |
HashMap<String, Boolean> testCases = new HashMap<String, Boolean>(); | |
testCases.put("foo=23", true); | |
testCases.put("foo= 23", false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class REPL { | |
private $stream; | |
public function __construct($streamPath = 'php://stdin'){ | |
$this->stream = fopen($streamPath, 'r'); | |
} | |
public function begin(){ |