Page of 3 ZOOM Problem 3 (20 Points): The chemical plant you work at produces co
ID: 3599327 • Letter: P
Question
Page of 3 ZOOM Problem 3 (20 Points): The chemical plant you work at produces compound A through a series of unit operations. The operating parameters and corresponding probability distributions for each unit operation are well understood, but the cumulative result of the randomness from each operation is not. Process for producing compound A: Input stream - mole fraction of A is 0 Operation 1-Catalyst that converts 50% of the input stream into A. This is a normally distributed process with a standard deviation of 5%. Operation 2-Distillation that removes 70-80% of the non-A portion of the stream (uniformly distributed) and 10-15% of compound A (uniformly distributed). Operation 3 - Addition of a second feed stream that increases the number of moles in the system by 100% while not adding any compound A. This is a normally distributed process with a standard deviation of 10% Operation 4-A second catalytic reaction that converts 65-70% (uniformly distributed) of the non- A components into compound/A Operation 5-Filtration that removes 80% of the non-A components (normally distributed with a standard deviation of 3%) and 20-30% of compound A (uniformly distributed). Simulate this process 100,000 times and plot the final mole fractions of compound A using a histogram with 50 bins (use the MATLAB function "histogram"). Follow the department graph format for full credit. Assuming your results are normally distributed, report the mean and standard deviation of the distribution of final mole fractions. You may assume that all operations that produce A are 1:1 (i.e. 1 mole of A is produced for every 1 mole of the feed stream that is used).Explanation / Answer
public class BST { private Node root; // root of BST private class Node { private Key key; // sorted by key private Value val; // associated data private Node left, right; // left and right subtrees private int size; // number of nodes in subtree public Node(Key key, Value val, int size) { this.key = key; this.val = val; this.size = size; } } /** * Initializes an empty symbol table. */ public BST() { } /** * Returns true if this symbol table is empty. * @return {@code true} if this symbol table is empty; {@code false} otherwise */ public boolean isEmpty() { return size() == 0; } /** * Returns the number of key-value pairs in this symbol table. * @return the number of key-value pairs in this symbol table */ public int size() { return size(root); } // return number of key-value pairs in BST rooted at x private int size(Node x) { if (x == null) return 0; else return x.size; } /** * Does this symbol table contain the given key? * * @param key the key * @return {@code true} if this symbol table contains {@code key} and * {@code false} otherwise * @throws IllegalArgumentException if {@code key} is {@code null} */ public boolean contains(Key key) { if (key == null) throw new IllegalArgumentException("argument to contains() is null"); return get(key) != null; } /** * Returns the value associated with the given key. * * @param key the key * @return the value associated with the given key if the key is in the symbol table * and {@code null} if the key is not in the symbol table * @throws IllegalArgumentException if {@code key} is {@code null} */ public Value get(Key key) { return get(root, key); } private Value get(Node x, Key key) { if (key == null) throw new IllegalArgumentException("calls get() with a null key"); if (x == null) return null; int cmp = key.compareTo(x.key); if (cmp < 0) return get(x.left, key); else if (cmp > 0) return get(x.right, key); else return x.val; } /** * Inserts the specified key-value pair into the symbol table, overwriting the old * value with the new value if the symbol table already contains the specified key. * Deletes the specified key (and its associated value) from this symbol table * if the specified value is {@code null}. * * @param key the key * @param val the value * @throws IllegalArgumentException if {@code key} is {@code null} */ public void put(Key key, Value val) { if (key == null) throw new IllegalArgumentException("calls put() with a null key"); if (val == null) { delete(key); return; } root = put(root, key, val); assert check(); } private Node put(Node x, Key key, Value val) { if (x == null) return new Node(key, val, 1); int cmp = key.compareTo(x.key); if (cmp < 0) x.left = put(x.left, key, val); else if (cmp > 0) x.right = put(x.right, key, val); else x.val = val; x.size = 1 + size(x.left) + size(x.right); return x; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.