inf2d all
1 / 49
Term:
Definition:
Show example sentence
Show hint
Keyboard Shortcuts
  • Previous
  • Next
  • F Flip card

Complete list of Terms and Definitions for inf2d all

Terms Definitions
NNRTI efavirenz
Tetracyclines minocycline
Beta-lactamaseInhibitors clavulanatesulbactamtazobactam
protease Inhibitors ritonavir
antifungal drugs tolnaftate
Beta-lactamase inhibitor tazobactam
Antiviral drugs-influenza rimantadineosteltamivir
Antimalarial drugs chloroquineprimaquinemefloquine atovaquone- proguanil
Tx of Herpes keratitis trifluridine
What is a hash method?
Hashing: Code a HashTable <T,U> class (no operations), which includes the inner "node" class and the hash function
Hashing: What are 3 popular examples of Hash Functions?
Doubly Linked List: Code inserting a node in a doubly linked list HINT: This will require 4 pointer operations (versus a singly linked list which required two.
Hashing: Code the search method of a hashtable (using separate chaining and records):
Binary Tree: Insert a new key, when there is no "extra space" in the adjacent siblings
Draw and example of a circular doubly linked list w/ a dummy node
B-Trees: How do you delete a key from a B-Tree (case 2 where k is NOT in a leaf)? (There are two cases - k may or may not be in a leaf)
*IMP* The Comparable Generic Interface: Code a class that extends the Comparable Generic Interace and it's one method. The generic interface Comparable <T> requires just one method: public int compareTo(T obj) FIRST MUST CODE INTERFACE: public Interface Comparable<T> { int compareTo(T t); } NOW CODE GNODE EXTENDING COMPARABLE: public class GNode<T extends Comparable<T>> { T t1, t2; if(T2.compareTo(t2) < 0) { //do something } }
Recursion: Code the factorial recursive example in JAVA Int factorial (int n) { If (n==1) //you have reached smallest “trivial” problem Return 1; Else Return n*factorial(n-1); }
Hashing: What is the sequence for double hashing to work? (h1(key) + i*h2(key))%SIZE NOTES: oSIZE must be a prime oRequire h2(key) < SIZE, for every key and h2(key) != 1 oDONE! Problem solved (double hashing solves the cluster problem)
What is a generic type? The generic type parameter indicates that the method depends on some particular class but the programmer is not going to specify exactly what the class is. NOTE: the generic type parameter always appears in angle brackets right before the return type of the method. EXAMPLE: static <T> T middle(T[] data)....
Hashing: What are the advantages of separate chaining? Advantages: -The table is never full -fast (as long as you don’t have overly long synonym chains – this is the fastest) -EASY (even if you don’t use array, and just use linked lists – you can implement this in less than a page of code)
Hashing: What are some examples of collision resolution methods? 1. Separate Chaining 2. Open Addressing 3. Linear Probing (which causes another issue: clustering).
What are two popular self balancing trees? 1. Red-black trees 2. AVL Trees
Code the delete operation for the BST table implementation //return whether successful Public Boolean delete (K k) { Return tree.delete(new Entry<k,v>(k, null)); }
What is the code for the array implementation of a queue? (Generic with just the constructors) public class ArrayQueue<E> implements Cloneable { private E[] data; private int manyItems; private int front; private int rear; public ArrayQueue() { final int INITIAL_CAPACITY = 10; //queue is empty and has an initial capacity of 10 manyItems = 0; data = (E[]) new Object[INITIAL_CAPACITY]; //we dont care about front and rear for an empty queue } public ArrayQueue(int InitialCapacity) { if(initialCapacity < 0) throw new QueueException("initial capacity is negative: " + initialCapacity); manyITems = 0; data = (E[]) new Object[InitialCapacity]; //dont care about front and rear as mentioned before.
Hashing to Buckets: Now when we want to insert a key and the bucket h(key) is full - what happens? • Possibilities: oCould put key in the next bucket (etc.) -I.e. “bucket linear probing” (bucket version of linear probing) -Similar issues to linear probing will arise… -Could do “bucket double hashing” -Set up a separate hash table for “overflow keys” -Most common solution: •Set up (unordered) overflow buckets -When first bucket overflows: •Allocate one overflow bucket and put key in it
Graphs: What is a path? A path is a sequence of joined edges
Graphs: What is an empty graph? When both sets (Vertices and edges) are empty, thus there are no vertices and no edges
Hashing: What are the advantages of linear probing? 1. Conceptually simple 2. Easy to code
Code the insert operation for the BST Table Implementation: //return whether operation was successful Public Boolean insert(K k, V v) { Return tree.insert(new Entry<k,v>(k,v)); //true if successful, false if not }
Code the declaration from the IntNode Class, including the declaration of two nodes in a Program: Note: This will declare the two instance variables: an instance variable to hold the element and a second instance variable that is a reference to another public class IntNode { private int data; //element stored in this node private IntNode link; //refers to the next node in the list //Now declaring two nodes: IntNode head; IntNode tail; .... }
Code the declaration from the IntNode Class, including the declaration of two nodes in a Program: Note: This will declare the two instance variables: an instance variable to hold the element and a second instance variable that is a reference to another CLASS CODE EXAMPLE: public class StrNode { private String Data; //element stored in this node (note it's //string not int) private StrNode next; //refers to the next node in the list (note //in class prof uses "next" instead of "link" }
What is a generic method? A method that is written with the types of the parameters not fully specified.
How do you throw a new stack exception? Code an example: //inside D Stack class Public double top() { //this will read the top of stack and return it w/o removing it //need to make sure the stack is not empty //first check to see if stack is empty: If(sp == -1) //stack empty? Throw new stackUnderFlowException(); Returnhold[sp]; }
Provide a summary of what "recursion" is Recursion: take a large problem, do a small (easy) part and pass a slightly smaller version onto yourself…continue until reach a trivial problem.
What does the setLink() mutator method require (what parameters) and what is the postcondition? Code an example. The purpose of the setLink() mutator method is to set the reference to the next node after this node. The parameters are: "newLink" - a reference to the node that shoudl appear after this node in the linked list (or the null reference if there should be no node after this node) The postcondition: the link to this node after this node has been set to newLink. Any other node (that used to be in this link) is no longer connected to this node. Book Code Example: public void setLink(IntNode newLink) { link = newLink; //remember link was declared in initial variables.. } Class Code Example (note the difference in "link" in class we use "next" and "newLink" is "P"): public void setNext(StrNode p) { next = p; }
Hashing: What is the open addressing method? The idea of open addressing is to store the keys IN the array a[]. In open addressing, collisions are resolved by placing the object in the next OPEN spot of the array (using linear probing).
What is a binary tree in JAVA? A binary tree is a linked structure where each node has 2 pointers (left and right), each node except one (called root) has ONE node pointing to it. No node points to root.
What is the definition of a "leaf" in a binary tree structure A node with no children is a leaf
Heap: Write the pseudocode of a pushdown PSEUDOCODE: o pseudoCode example: pushDown(node N) { If(value at N is out of heap order) Swap it with the larger of the children values. If(the child Is now out of order) “Continue swapping down the tree” }
Heap: Write the pseudocode of a pushdown o Takes as a parameter one of the nodes of the tree: pushdown(node N) //assumes as a precondition that the left and right subtrees at N are already //heap ordered //BUT: the value at N may be out of heap order. //pushDown will extend heap order to N – we will “push the value at N down” //(pushDown) the tree until its in its proper place
CODE inserting a new node in a BST What if the tree is empty? CODE: Public Boolean insert(Tt) { If(root == null) { //inserting into empty tree Root = new BSTNode<T>(t); Return true; } //now insert into non-empty tree Return insert (t, root); //start recursive calls }
Code the declaration of the doubly linked list class ("DStrNode"): NOTE: With a doubly linked list you are now declaring TWO fields for linking ("prev" and "next")
Graphs: When is a graph connected? How about not connected? o A graph is connected if every pair of vertices can be joined by a path. -A (connected) component of a graph is a maximal connected subgraph (a graph that is contained in another) • Think of islands:
How do you delete a BST node? HINT: there are three cases To delete t from tree -search for t, if not found “not in the tree error” (could use a Boolean method) -if found: CASE 1: make the pointer to t's parent null CASE 2: //now we cant make the pointer null, b/c you would break the pointer to t’s children. Thus – make pointer from t’s parent point to t’s (only) child, just bypass the node that held t. CASE 3: Trick: let “l” be the LARGEST value in t’s left subtreee, “l” is in node “L” And replace t with “l”. Notice that L has no right child (b/c if it did that child would be larger). So delete L (by case 1 or case 2). Q: How do we find the largest value in t’s left subtree? A: From t, go left once (into Left SubTree “LST”), then go right as far as you can to get to the largest value.
What is the ADT Table? What are it's three operations? And what can be used to implement it? Table – is an ADT which stores key/value pairs (called records) Where each record is uniquely identified by its key (keys are unique) -3 Operations: 1. value search (key k) takes key as parameter and returns corresponding value 2. Boolean insert(key k, value v) //inserts record (k,v) into table If k is already in the table return false (“duplicate key error”) Do not insert new (k,v) 3. Boolean delete (key k) //removes record with key k //if not in table return false You can use a BST to implement a table.
What is the JAVA code to solve the problem of Hanoi (pseudo code is fine) /** * Solve the problem of moving the number of disks specified * by the first parameter from the stack specified by the * second parameter to the stack specified by the third * parameter. The stack specified by the fourth parameter * is available for use as a spare. Stacks are specified by * number: 0, 1, or 2. */ static void TowersOfHanoi(int disks, int from, int to, int spare) { if (disks == 1) { // There is only one disk to be moved. Just move it. System.out.println("Move a disk from stack number " + from + " to stack number " + to); } else { // Move all but one disk to the spare stack, then // move the bottom disk, then put all the other // disks on top of it. TowersOfHanoi(disks-1, from, spare, to); System.out.println("Move a disk from stack number " + from + " to stack number " + to); TowersOfHanoi(disks-1, spare, to, from); } }
How do you insert a new key k into a B-Tree? (if THERE IS extra space in an adjacent sibling) (All X Steps) 1. First search for k, if found, duplicate key error 2. else, locate the LEAF where we want to insert k (this involves several other steps!) 3. First see if an adjacent sibling has an "extra space" 4. IF yes (an adjacent sibling has an extra space): 4a. Move lowest/highest key from full node into parent's separator key (between the siblings) 4b. move the seperator key from parent into non-full sibling ("rotate through parent node")