This file contains hidden or 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
1 |
This file contains hidden or 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
import java.util.HashMap; | |
/* | |
The Integer Knapsack Problem (Duplicate Items Permitted). You have n types of | |
items, where the ith item type has an integer size si and a real value vi. You are trying to fill a knapsack of | |
total capacity C with a selection of items of maximum value. You can add multiple items of the same type | |
to the knapsack. | |
s = {3,1,2,4} | |
v = {4,1,3,2} | |
This file contains hidden or 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
/** | |
* Stream sample: based on an evenly distributed random sample. | |
*/ | |
public class StreamSample | |
{ | |
private static int sampleSize = 500; | |
private static int streamCount = 0; | |
private static int sampleIndex = 0; | |
private StreamElement[] streamSample = new StreamElement[sampleSize]; |
This file contains hidden or 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
import java.util.Stack; | |
public class QueueFrom2Stack<E> { | |
Stack<E> stack = new Stack<E>(); | |
Stack<E> popStack = new Stack<E>(); | |
public void push(E element) { | |
this.stack.push(element); | |
} |
This file contains hidden or 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
import java.util.Stack; | |
public class QueueFromStack<E> { | |
Stack<E> stack = new Stack<E>(); | |
public void push(E element) { | |
if (this.stack.empty()) { | |
this.stack.push(element); | |
} else { |
This file contains hidden or 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
66 public static function processUploadedFile($data) | |
67 { | |
68 $pw = new Product_Worker(); | |
69 $id = $data['ingestionId']; | |
70 error_log("ingestionId: $id"); | |
71 $pw->ia = DB_Factory::getInstance("Ingestion"); | |
72 | |
73 if (!$pw->isDataReady($id)) { | |
74 return false; | |
75 } |