194 Pages

ICOM4015-lec18-f06

Course: ICOM 4015, Fall 2009
School: UPR Mayagüez
Rating:
 
 
 
 
 

Word Count: 7026

Document Preview

Data Advanced Structures Advanced Programming ICOM 4015 Lecture 18 Reading: Java Concepts Chapter 21 Chapter Goals To learn about the set and map data types To understand the implementation of hash tables To be able to program hash functions To learn about binary trees To be able to use tree sets and tree maps Continued Chapter Goals To become familiar with the heap data structure To learn how to...

Register Now

Unformatted Document Excerpt

Coursehero >> United States >> UPR Mayagüez >> ICOM 4015

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Data Advanced Structures Advanced Programming ICOM 4015 Lecture 18 Reading: Java Concepts Chapter 21 Chapter Goals To learn about the set and map data types To understand the implementation of hash tables To be able to program hash functions To learn about binary trees To be able to use tree sets and tree maps Continued Chapter Goals To become familiar with the heap data structure To learn how to implement the priority queue data type To understand how to use heaps for sorting Sets Set: unordered collection of distinct elements Elements can be added, located, and removed Sets don't have duplicates A Set of Printers Figure 1: A Set of Printers Fundamental Operations on a Set Adding an element Adding an element has no effect if the element is already in the set Removing an element Attempting to remove an element that isn't in the set is silently ignored Containment testing (does the set contain a given object?) Listing all elements (in arbitrary order) Sets We could use a linked list to implement a set Adding, removing, and containment testing would be relatively slow There are data structures that can handle these operations much more quickly Hash tables Trees Continued Sets Standard Java library provides set implementations based on both data structures HashSet TreeSet Both of these data structures implement the Set interface Set Classes and Interface in the Standard Library Figure 2: Set Classes and Interfaces in the Standard Library Iterator Use an iterator to visit all elements in a set A set iterator does not visit the elements in the order in which they were inserted An element can not be added to a set at an iterator position A set element can be removed at an iterator position Code for Creating and Using a Hash Set //Creating a hash set Set<String> names = new HashSet<String>(); //Adding an element names.add("Romeo"); //Removing an element names.remove("Juliet"); //Is element in set if (names.contains("Juliet") { . . .} Listing All Elements with an Iterator Iterator<String> iter = names.iterator(); while (iter.hasNext()) { String name = iter.next(); Do something with name } // Or, using the "for each" loop for (String name : names) { Do something with name } File SetTester.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: import import import import /** This program demonstrates a set of strings. The user can add and remove strings. */ public class SetTester { public static void main(String[] args) { Set<String> names = new HashSet<String>(); Scanner in = new Scanner(System.in); Continued java.util.HashSet; java.util.Iterator; java.util.Scanner; java.util.Set; File SetTester.java 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: boolean done = false; while (!done) { System.out.print("Add name, Q when done: "); String input = in.next(); if (input.equalsIgnoreCase("Q")) done = true; else { names.add(input); print(names); } } done = false; while (!done) { Continued File SetTester.java 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: System.out.println("Remove name, Q when done"); String input = in.next(); if (input.equalsIgnoreCase("Q")) done = true; else { names.remove(input); print(names); } } } /** Prints the contents of a set of strings. @param s a set of strings */ private static void print(Set<String> s) { Continued File SetTester.java 53: 54: 55: 56: 57: 58: 59: 60: 61: } 62: 63: System.out.print("{ "); for (String element : s) { System.out.print(element); System.out.print(" "); } System.out.println("}"); } Continued File SetTester.java Output Add name, Q when done: Dick { Dick } Add name, Q when done: Tom { Tom Dick } Add name, Q when done: Harry { Harry Tom Dick } Add name, Q when done: Tom { Harry Tom Dick } Add name, Q when done: Q Remove name, Q when done: Tom { Harry Dick } Remove name, Q when done: Jerry { Harry Dick } Remove name, Q when done: Q Self Test 1. Arrays and lists remember the order in which you added elements; sets do not. Why would you want to use a set instead of an array or list? 2. Why are set iterators different from list iterators? Answers 1. Efficient set implementations can quickly test whether a given element is a member of the set. 2. Sets do not have an ordering, so it doesn't make sense to add an element at a particular iterator position, or to traverse a set backwards. Maps A map keeps associations between key and value objects Mathematically speaking, a map is a function from one set, the key set, to another set, the value set Every key in a map has a unique value A value may be associated with several keys Classes that implement the Map interface HashMap TreeMap An Example of a Map Figure 3: An Example of a Map Map Classes and Interfaces Figure 4: Map Classes and Interfaces in the Standard Library Code for Creating and Using a HashMap //Changing an existing association favoriteColor.put("Juliet",Color.RED); //Removing a key and its associated value favoriteColors.remove("Juliet"); Code for Creating and Using a HashMap //Creating a HashMap Map<String, Color> favoriteColors = new HashMap<String, Color>(); //Adding an association favoriteColors.put("Juliet", Color.PINK); //Changing an existing association favoriteColor.put("Juliet",Color.RED); Continued Code for Creating and Using a HashMap //Getting the value associated with a key Color julietsFavoriteColor = favoriteColors.get("Juliet"); //Removing a key and its associated value favoriteColors.remove("Juliet"); Printing Key/Value Pairs Set<String> keySet = m.keySet(); for (String key : keySet) { Color value = m.get(key); System.out.println(key + "->" + value); } File MapTester.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: import import import import import /** This program tests a map that maps names to colors. */ public class MapTester { public static void main(String[] args) { Map<String, Color> favoriteColors = new HashMap<String, Color>(); favoriteColors.put("Juliet", Color.pink); favoriteColors.put("Romeo", Color.green); Continued java.awt.Color; java.util.HashMap; java.util.Iterator; java.util.Map; java.util.Set; File MapTester.java 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: } favoriteColors.put("Adam", Color.blue); favoriteColors.put("Eve", Color.pink); Set<String> keySet = favoriteColors.keySet(); for (String key : keySet) { Color value = favoriteColors.get(key); System.out.println(key + "->" + value); } } Continued File MapTester.java Output Romeo->java.awt.Color[r=0,g=255,b=0] Eve->java.awt.Color[r=255,g=175,b=175] Adam->java.awt.Color[r=0,g=0,b=255] Juliet->java.awt.Color[r=255,g=175,b=175] Self Check 1. What is the difference between a set and a map? 2. Why is the collection of the keys of a map a set? Answers 1. A set stores elements. A map stores associations between keys and values. 2. The ordering does not matter, and you cannot have duplicates. Hash Tables Hashing can be used to find elements in a data structure quickly without making a linear search A hash table can be used to implement sets and maps A hash function computes an integer value (called the hash code) from an object Continued Hash Tables A good hash function minimizes collisions identical hash codes for different objects To compute the hash code of object x: int h = x.hashCode(); Sample Strings and Their Hash Codes String "Adam" "Eve" "Harry" "Jim" "Joe" "Juliet" "Katherine" "Sue" Hash Code 2035631 70068 69496448 74478 74676 - 2065036585 2079199209 83491 Simplistic Implementation of a Hash Table To implement Generate hash codes for objects Make an array Insert each object at the location of its hash code To test if an object is contained in the set Compute its hash code Check if the array position with that hash code is already occupied Simplistic Implementation of a Hash Table Figure 5: A Simplistic Implementation of a Hash Table Problems with Simplistic Implementation It is not possible to allocate an array that is large enough to hold all possible integer index positions It is possible for two different objects to have the same hash code Solutions Pick a reasonable array size and reduce the hash codes to fall inside the array int h = x.hashCode(); if (h < 0) h = -h; h = h % size; When elements have the same hash code: Use a node sequence to store multiple objects in the same array position These node sequences are called buckets Hash Table with Buckets to Store Elements with Same Hash Code Figure 6: A Hash Table with Buckets to Store Elements with Same Hash Code Algorithm for Finding an Object x in a Hash Table Get the index h into the hash table Compute the hash code Reduce it modulo the table size Iterate through the elements of the bucket at position h For each element of the bucket, check whether it is equal to x If a match is found among the elements of that bucket, then x is in the set Otherwise, x is not in the set Hash Tables A hash table can be implemented as an array of buckets Buckets are sequences of nodes that hold elements with the same hash code If there are few collisions, then adding, locating, and removing hash table elements takes constant time Big-Oh notation: O(1) Continued Hash Tables For this algorithm to be effective, the bucket sizes must be small The table size should be a prime number larger than the expected number of elements An excess capacity of 30% is typically recommended Hash Tables Adding an element: simple extension of the algorithm for finding an object Compute the hash code to locate the bucket in which the element should be inserted Try finding the object in that bucket If it is already present, do nothing; otherwise, insert it Continued Hash Tables Removing an element is equally simple Compute the hash code to locate the bucket in which the element should be inserted Try finding the object in that bucket If it is present, remove it; otherwise, do nothing If there are few collisions, adding or removing takes O(1) time File HashSet.java 001: 002: 003: 004: 005: 006: 007: 008: 009: 010: 011: 012: 013: 014: 015: 016: import java.util.AbstractSet; import java.util.Iterator; import java.util.NoSuchElementException; /** A hash set stores an unordered collection of objects, using a hash table. */ public class HashSet extends AbstractSet { /** Constructs a hash table. @param bucketsLength the length of the buckets array */ public HashSet(int bucketsLength) Continued { File HashSet.java 017: 018: 019: 020: 021: 022: 023: 024: 025: 026: 027: 028: 029: 030: 031: 032: 033: 034: buckets = new Node[bucketsLength]; size = 0; } /** Tests for set membership. @param x an object @return true if x is an element of this set */ public boolean contains(Object x) { int h = x.hashCode(); if (h < 0) h = -h; h = h % buckets.length; Node current = buckets[h]; while (current != null) { Continued File HashSet.java 035: 036: 037: 038: 039: 040: 041: 042: 043: 044: 045: 046: 047: 048: 049: 050: 051: 052: if (current.data.equals(x)) return true; current = current.next; } return false; } /** Adds an element to this set. @param x an object @return true if x is a new object, false if x was already in the set */ public boolean add(Object x) { int h = x.hashCode(); if (h < 0) h = -h; h = h % buckets.length; Continued File HashSet.java 053: 054: 055: 056: 057: 058: 059: 060: 061: 062: 063: 064: 065: 066: 067: Node current = buckets[h]; while (current != null) { if (current.data.equals(x)) return false; // Already in the set current = current.next; } Node newNode = new Node(); newNode.data = x; newNode.next = buckets[h]; buckets[h] = newNode; size++; return true; } Continued File HashSet.java 068: 069: 070: 071: 072: 073: 074: 075: 076: 077: 078: 079: 080: 081: 082: 083: 084: 085: /** Removes an object from this set. @param x an object @return true if x was removed from this set, false if x was not an element of this set */ public boolean remove(Object x) { int h = x.hashCode(); if (h < 0) h = -h; h = h % buckets.length; Node current = buckets[h]; Node previous = null; while (current != null) { if (current.data.equals(x)) { Continued File HashSet.java 086: 087: 088: 089: 090: 091: 092: 093: 094: 095: 096: 097: 098: 099: 100: 101: 102: 103: 104: if (previous == null) buckets[h] = current.next; else previous.next = current.next; size--; return true; } previous = current; current = current.next; } return false; } /** Returns an iterator that traverses the elements of this set. @param a hash set iterator */ public Iterator iterator() { return new HashSetIterator(); } Continued File HashSet.java 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: /** Gets the number of elements in this set. @return the number of elements */ public int size() { return size; } private Node[] buckets; private int size; private class Node { public Object data; public Node next; } Continued File HashSet.java 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: private class HashSetIterator implements Iterator { /** Constructs a hash set iterator that points to the first element of the hash set. */ public HashSetIterator() { current = null; bucket = -1; previous = null; previousBucket = -1; } public boolean hasNext() { if (current != null && current.next != null) return true; Continued File HashSet.java 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: for (int b = bucket + 1; b < buckets.length; b++) if (buckets[b] != null) return true; return false; } public Object next() { previous = current; previousBucket = bucket; if (current == null || current.next == null) { // Move to next bucket bucket++; while (bucket < buckets.length && buckets[bucket] == null) bucket++; Continued File HashSet.java 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: if (bucket < buckets.length) current = buckets[bucket]; else throw new NoSuchElementException(); } else // Move to next element in bucket current = current.next; return current.data; } public void remove() { if (previous != null && previous.next == current) previous.next = current.next; else if (previousBucket < bucket) buckets[bucket] = current.next; else Continued throw new IllegalStateException(); File HashSet.java 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: } current = previous; bucket = previousBucket; } private private private private } int bucket; Node current; int previousBucket; Node previous; File SetTester.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: 18: import java.util.Iterator; import java.util.Set; /** This program tests the hash set class. */ public class SetTester { public static void main(String[] args) { HashSet names = new HashSet(101); // 101 is a prime names.add("Sue"); names.add("Harry"); names.add("Nina"); names.add("Susannah"); names.add("Larry"); names.add("Eve"); Continued File SetTester.java 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: } names.add("Sarah"); names.add("Adam"); names.add("Tony"); names.add("Katherine"); names.add("Juliet"); names.add("Romeo"); names.remove("Romeo"); names.remove("George"); Iterator iter = names.iterator(); while (iter.hasNext()) System.out.println(iter.next()); } Continued File SetTester.java Output Harry Sue Nina Susannah Larry Eve Sarah Adam Juliet Katherine Tony Self Check 1. If a hash function returns 0 for all values, will the HashSet work correctly? 2. What does the hasNext method of the HashSetIterator do when it has reached the end of a bucket? Answers 1. Yes, the hash set will work correctly. All elements will be inserted into a single bucket. 2. It locates the next bucket in the bucket array and points to its first element. Computing Hash Codes A hash function computes an integer hash code from an object Choose a hash function so that different objects are likely to have different hash codes. Continued Computing Hash Codes Bad choice for hash function for a string Adding the unicode values of the characters in the string int h = 0; for (int i = 0; i < s.length(); i++) h = h + s.charAt(i); Because permutations ("eat" and "tea") would have the same hash code Computing Hash Codes Hash function for a string s from standard library final int HASH_MULTIPLIER = 31; int h = 0; for (int i = 0; i < s.length(); i++) h = HASH_MULTIPLIER * h + s.charAt(i) For example, the hash code of "eat" is 31 * (31 * 'e' + 'a') + 't' = 100184 The hash code of "tea" is quite different, namely 31 * (31 * 't' + 'e') + 'a' = 114704 A hashCode Method for the Coin Class There are two instance fields: String coin name and double coin value Use String's hashCode method to get a hash code for the name To compute a hash code for a floating-point number: Wrap the number into a Double object Then use Double's hashCode method Combine the two hash codes using a prime number as the HASH_MULTIPLIER A hashCode Method for the Coin Class class Coin { public int hashCode() { int h1 = name.hashCode(); int h2 = new Double(value).hashCode(); final int HASH_MULTIPLIER = 29; int h = HASH_MULTIPLIER * h1 + h2: return h } . . . } Creating Hash Codes for your Classes Use a prime number as the HASH_MULTIPLIER Compute the hash codes of each instance field For an integer instance field just use the field value Combine the hash codes int h = HASH_MULTIPLIER * h1 +h2; h = HASH_MULTIPLIER * h + h3; h = HASH_MULTIPLIER *h + h4; . . . return h; Creating Hash Codes for your Classes Your hashCode method must be compatible with the equals method if x.equals(y) then x.hashCode() == y.hashCode() Continued Creating Hash Codes for your Classes You get into trouble if your class defines an equals method but not a hashCode method If we forget to define hashCode method for Coin it inherits the method from Object superclass That method computes a hash code from the memory location of the object Creating Hash Codes for your Classes Effect: any two objects are very likely to have a different hash code Coin coin1 = new Coin(0.25, "quarter"); Coin coin2 = new Coin(0.25, "quarter"); In general, define either both hashCode and equals methods or neither Hash Maps In a hash map, only the keys are hashed The keys need compatible hashCode and equals method File Coin.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: /** A coin with a monetary value. */ public class Coin { /** Constructs a coin. @param aValue the monetary value of the coin. @param aName the name of the coin */ public Coin(double aValue, String aName) { value = aValue; name = aName; } Continued File Coin.java 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: /** Gets the coin value. @return the value */ public double getValue() { return value; } /** Gets the coin name. @return the name */ public String getName() { return name; } Continued File Coin.java 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: public boolean equals(Object otherObject) { if (otherObject == null) return false; if (getClass() != otherObject.getClass()) return false; Coin other = (Coin) otherObject; return value == other.value && name.equals(other.name); } public int hashCode() { int h1 = name.hashCode(); int h2 = new Double(value).hashCode(); final int HASH_MULTIPLIER = 29; int h = HASH_MULTIPLIER * h1 + h2; return h; } Continued File Coin.java 52: 53: 54: 55: 56: 57: 58: 59: } public String toString() { return "Coin[value=" + value + ",name=" + name + "]"; } private double value; private String name; File HashCodeTester.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: import java.util.HashSet; import java.util.Iterator; import java.util.Set; /** A program to test hash codes of coins. */ public class HashCodeTester { public static void main(String[] args) { Coin coin1 = new Coin(0.25, "quarter"); Coin coin2 = new Coin(0.25, "quarter"); Coin coin3 = new Coin(0.05, "nickel"); Continued File HashCodeTester.java 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: } System.out.println("hash code of coin1=" + coin1.hashCode()); System.out.println("hash code of coin2=" + coin2.hashCode()); System.out.println("hash code of coin3=" + coin3.hashCode()); Set<Coin> coins = new HashSet<Coin>(); coins.add(coin1); coins.add(coin2); coins.add(coin3); for (Coin c : coins) System.out.println(c); } Continued File HashCodeTester.java Output hash code of coin1=-1513525892 hash code of coin2=-1513525892 hash code of coin3=-1768365211 Coin[value=0.25,name=quarter] Coin[value=0.05,name=nickel] Self Check 1. What is the hash code of the string "to"? 2. What is the hash code of new Integer(13)? Answers 1. 31 116 + 111 = 3707 2. 13. Binary Search Trees Binary search trees allow for fast insertion and removal of elements They are specially designed for fast searching A binary tree consists of two nodes, each of which has two child nodes Continued Binary Search Trees All nodes in a binary search tree fulfill the property that: Descendants to the left have smaller data values than the node data value Descendants to the right have larger data values than the node data value A Binary Search Tree Figure 7: A Binary Search Tree A Binary Tree That Is Not a Binary Search Tree Figure 8: A Binary Tree That Is Not a Binary Search Tree Implementing a Binary Search Tree Implement a class for the tree containing a reference to the root node Implement a class for the nodes A node contains two references (to left and right child nodes) A node contains a data field The data field has type Comparable, so that you can compare the values in order to place them in the correct position in the binary search tree Implementing a Binary Search Tree public class BinarySearchTree { public BinarySearchTree() {. . .} public void add(Comparable obj) {. . .} . . . private Node root; private class Node { public void addNode(Node newNode) { . . . } . . . public Comparable data; public Node left; public Node right; } } Insertion Algorithm If you encounter a non-null node reference, look at its data value If the data value of that node is larger than the one you want to insert, continue the process with the left subtree If the existing data value is smaller, continue the process with the right subtree If you encounter a null node pointer, replace it with the new node Example BinarySearchTree tree = new BinarySearchTree(); tree.add("Juliet"); tree.add("Tom"); tree.add("Dick"); tree.add("Harry"); Example Figure 9: Binary Search Trees After Four Insertions Example Continued Tree: Add Romeo Figure 10: Binary Search Trees After Five Insertions Insertion Algorithm: BinarySearchTree Class public class BinarySearchTree { . . . public void add(Comparable obj) { Node newNode = new Node(); newNode.data = obj; newNode.left = null; newNode.right = null; if (root == null) root = newNode; else root.addNode(newNode); } . . . } Insertion Algorithm: Node Class private class Node { . . . public void addNode(Node newNode) { int comp = newNode.data.compareTo(data); if (comp < 0) { if (left == null) left = newNode; else left.addNode(newNode); } else if (comp > 0) { if (right == null) right = newNode; else right.addNode(newNode); } } . . . } Binary Search Trees When removing a node with only one child, the child replaces the node to be removed When removing a node with two children, replace it with the smallest node of the right subtree Removing a Node with One Child Figure 11: Removing a Node with One Child Removing a Node with Two Children Figure 12: Removing a Node with Two Children Binary Search Trees Balanced tree: each node has approximately as many descendants on the left as on the right If a binary search tree is balanced, then adding an element takes O(log(n)) time If the tree is unbalanced, insertion can be slow Perhaps as slow as insertion into a linked list An Unbalanced Binary Search Tree Figure 13: An Unbalanced Binary Search Tree File BinarySearchTree.java 001: 002: 003: 004: 005: 006: 007: 008: 009: 010: 011: 012: 013: 014: 015: /** This class implements a binary search tree whose nodes hold objects that implement the Comparable interface. */ public class BinarySearchTree { /** Constructs an empty tree. */ public BinarySearchTree() { root = null; } Continued File BinarySearchTree.java 016: 017: 018: 019: 020: 021: 022: 023: 024: 025: 026: 027: 028: 029: /** Inserts a new node into the tree. @param obj the object to insert */ public void add(Comparable obj) { Node newNode = new Node(); newNode.data = obj; newNode.left = null; newNode.right = null; if (root == null) root = newNode; else root.addNode(newNode); } Continued File BinarySearchTree.java 030: 031: 032: 033: 034: 035: 036: 037: 038: 039: 040: 041: 042: 043: 044: 045: 046: 047: /** Tries to find an object in the @param tree. obj the object to find @return true if the object is contained in the tree */ public boolean find(Comparable obj) { Node current = root; while (current != null) { int d = current.data.compareTo(obj); if (d == 0) return true; else if (d > 0) current = current.left; else current = current.right; } return false; } Continued File BinarySearchTree.java 048: 049: 050: 051: 052: 053: 054: 055: 056: 057: 058: 059: 060: 061: 062: 063: 064: 065: /** Tries to remove an object from the tree. Does nothing if the object is not contained in the tree. @param obj the object to remove */ public void remove(Comparable obj) { // Find node to be removed Node toBeRemoved = root; Node parent = null; boolean found = false; while (!found && toBeRemoved != null) { int d = toBeRemoved.data.compareTo(obj); if (d == 0) found = true; else Continued { File BinarySearchTree.java 066: 067: 068: 069: 070: 071: 072: 073: 074: 075: 076: 077: 078: 079: 080: 081: 082: parent = toBeRemoved; if (d > 0) toBeRemoved = toBeRemoved.left; else toBeRemoved = toBeRemoved.right; } } if (!found) return; // toBeRemoved contains obj // If one of the children is empty, use the other if (toBeRemoved.left == null || toBeRemoved.right == null) { Node newChild; if (toBeRemoved.left == null) newChild = toBeRemoved.right; Continued File BinarySearchTree.java 083: 084: 085: 086: 087: 088: 089: 090: 091: 092: 093: 094: 095: 096: 097: 098: else newChild = toBeRemoved.left; if (parent == null) // Found in root root = newChild; else if (parent.left == toBeRemoved) parent.left = newChild; else parent.right = newChild; return; } // Neither subtree is empty // Find smallest element of the right subtree Continued File BinarySearchTree.java 099: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: Node smallestParent = toBeRemoved; Node smallest = toBeRemoved.right; while (smallest.left != null) { smallestParent = smallest; smallest = smallest.left; } // smallest contains smallest child in right subtree // Move contents, unlink child toBeRemoved.data = smallest.data; smallestParent.left = smallest.right; } Continued File BinarySearchTree.java 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: /** Prints the contents of the tree in sorted order. */ public void print() { if (root != null) root.printNodes(); } private Node root; /** A node of a tree stores a data item and references of the child nodes to the left and to the right. */ private class Node { Continued File BinarySearchTree.java 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: /** Inserts a new node as a descendant of this node. @param newNode the node to insert */ public void addNode(Node newNode) { if (newNode.data.compareTo(data) < 0) { if (left == null) left = newNode; else left.addNode(newNode); } else { if (right == null) right = newNode; else right.addNode(newNode); } } Continued File BinarySearchTree.java 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: } /** Prints this node and all of its descendants in sorted order. */ public void printNodes() { if (left != null) left.printNodes(); System.out.println(data); if (right != null) right.printNodes(); } public Comparable data; public Node left; public Node right; } Continued File BinarySearchTree.java 168: 169: 170: Self Check 1. 2. What is the difference between a tree, a binary tree, and a balanced binary tree? Give an example of a string that, when inserted into the tree of Figure 10, becomes a right child of Romeo. Answers 1. In a tree, each node can have any number of children. In a binary tree, a node has at most two children. In a balanced binary tree, all nodes have approximately as many descendants to the left as to the right. For example, Sarah. Any string between Romeo and Tom will do. 2. Tree Traversal Print the tree elements in sorted order: Print the left subtree Print the data Print the right subtree Continued Example Let's try this out with the tree in Figure 10. The algorithm tells us to 1. Print the left subtree of Juliet; that is, Dick and descendants 2. Print Juliet 3. Print the right subtree of Juliet; that is, Tom and descendants Continued Example How do you print the subtree starting at Dick? 1. Print the left subtree of Dick. There is nothing to print 2. Print Dick 3. Print the right subtree of Dick, that is, Harry Example Algorithm goes on as above Output: Dick Harry Juliet Romeo Tom The tree is printed in sorted order BinarySearchTree Class print Method public class BinarySearchTree { . . . public void print() { if (root != null) root.printNodes(); } . . . } Node Class printNodes Method private class Node { . . . public void printNodes() { if (left != null) left.printNodes(); System.out.println(data); if (right != null) right.printNodes(); } . . . } Tree Traversal Tree traversal schemes include Preorder traversal Inorder traversal Postorder traversal Preorder Traversal Visit the root Visit the left subtree Visit the right subtree Inorder Traversal Visit the left subtree Visit the root Visit the right subtree Postorder Traversal Visit the left subtree Visit the right subtree Visit the root Tree Traversal Postorder traversal of an expression tree yields the instructions for evaluating the expression on a stack-based calculator Figure 14: Expression Trees Continued Tree Traversal The first tree ((3 + 4) * 5) yields 3 4 + 5 * Whereas the second tree (3 + 4 * 5) yields 3 4 5 * + A Stack-Based Calculator A number means: Push the number on the stack An operator means: Pop the top two numbers off the stack Apply the operator to these two numbers Push the result back on the stack A Stack-Based Calculator For evaluating arithmetic expressions 1. Turn the expression into a tree 2. Carry out a postorder traversal of the expression tree 3. Apply the operations in the given order The result is the value of the expression A Stack-Based Calculator Figure 15: A Stack-Based Calculator Self Check 1. 2. What are the inorder traversals of the two trees in Figure 14? Are the trees in Figure 14 binary search trees? Answers 1. 2. For both trees, the inorder traversal is 3 + 4 * 5. Nofor example, consider the children of +. Even without looking up the Unicode codes for 3, 4, and +, it is obvious that + isn't between 3 and 4. Reverse Polish Notation Using Tree Sets and Tree Maps HashSet and TreeSet both implement the Set interface With a good hash function, hashing is generally faster than tree-based algorithms TreeSet's balanced tree guarantees reasonable performance TreeSet's iterator visits the elements in sorted order rather than the HashSet's random order To Use a TreeSet Either your objects must implement Comparable interface Or you must provide a Comparator object To Use a TreeMap Either the keys must implement the Comparable interface Or you must provide a Comparator object for the keys There is no requirement for the values File TreeSetTester.java 01: 02: 03: 04: 05: 06: 07: 08: 09: 10: 11: 12: 13: 14: 15: 16: 17: import import import import /** A program to test hash codes of coins. */ public class TreeSetTester { public static void main(String[] args) { Coin coin1 = new Coin(0.25, "quarter"); Coin coin2 = new Coin(0.25, "quarter"); Coin coin3 = new Coin(0.01, "penny"); Coin coin4 = new Coin(0.05, "nickel"); java.util.Comparator; java.util.Iterator; java.util.Set; java.util.TreeSet; Continued File TreeSetTester.java 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: class CoinComparator implements Comparator<Coin> { public int compare(Coin first, Coin second) { if (first.getValue() < second.getValue()) return -1; if (first.getValue() == second.getValue()) return 0; return 1; } } Comparator<Coin> comp = new CoinComparator(); Set<Coin> coins = new TreeSet<Coin>(comp); coins.add(coin1); coins.add(coin2); coins.add(coin3); Continued coins.add(coin4); File TreeSetTester.java 34: 35: 36: 37: 38: } for (Coin c : coins) System.out.println(c); } File TreeSetTester.java Output: Coin[value=0.01,name=penny] Coin[value=0.05,name=nickel] Coin[value=0.25,name=quarter] Self Check 1. 2. When would you choose a tree set over a hash set? Suppose we define a coin comparator whose compare method always returns 0. Would the TreeSet function correctly? Answers 1. 2. When it is desirable to visit the set elements in sorted order. Noit would never be able to tell two coins apart. Thus, it would think that all coins are duplicates of the first. Priority Queues A priority queue collects elements, each of which has a priority Example: collection of work requests, some of which may be more urgent than others When removing an element, element with highest priority is retrieved Customary to give low values to high priorities, with priority 1 denoting the highest priority Continued Priority Queues Standard Java library supplies a PriorityQueue class A data structure called heap is very suitable for implementing priority queues Example Consider this sample code: PriorityQueue<WorkOrder> q = new PriorityQueue<WorkOrder>; q.add(new WorkOrder(3, "Shampoo carpets")); q.add(new WorkOrder(1, "Fix overflowing sink")); q.add(new WorkOrder(2, "Order cleaning supplies")); When calling q.remove() for the first time, the work order with priority 1 is removed Next call to q.remove() removes the order with priority 2 Heaps A heap (or, a min-heap) is a binary tree with two special properties 1. It is almost complete All nodes are filled in, except the last level may have some nodes missing toward the right All nodes store values that are at most as large as the values stored in their descendants 2. The tree fulfills the heap property Heap property ensures that the smallest element is stored in the root An Almost Complete Tree Figure 16: An Almost Complete Tree A Heap Figure 17: A Heap Differences of a Heap with a Binary Search Tree 1. The shape of a heap is very regular Binary search trees can have arbitrary shapes 2. In a heap, the left and right subtrees both store elements that are larger than the root element In a binary search tree, smaller elements are stored in the left subtree and larger elements are stored in the right subtree Inserting a New Element in a Heap 1. Add a vacant slot to the end of the tree Figure 18: Inserting a New Element in a Heap Inserting a New Element in a Heap 1. Demote the parent of the empty slot if it is larger than the element to be inserted Move the parent value into the vacant slot, and move the vacant slot up Repeat this demotion as long as the parent of the vacant slot is larger than the element to be inserted Continued Inserting a New Element in a Heap Figure 18 (continued): Inserting a New Element in a Heap Inserting a New Element in a Heap 1. Demote the parent of the empty slot if it is larger than the element to be inserted Move the parent value into the vacant slot, and move the vacant slot up Repeat this demotion as long as the parent of the vacant slot is larger than the element to be inserted Continued Inserting a New Element in a Heap Figure 18 (continued): Inserting a New Element in a Heap Inserting a New Element in a Heap 1. At this point, either the vacant slot is at the root, or the parent of the vacant slot is smaller than the element to be inserted. Insert the element into the vacant slot Continued Inserting a New Element in a Heap Figure 18 (continued): Inserting a New Element in a Heap Removing an Arbitrary Node from a Heap 1. Extract the root node value Figure 19: Removing the Minimum Value from a Heap Removing an Arbitrary Node from a Heap 1. Move the value of the last node of the heap into the root node, and remove the last node. Hep property may be violated for root node (one or both of its children may be smaller). Continued Removing an Arbitrary Node from a Heap Figure 19 (continued): Removing the Minimum Value from a Heap Removing an Arbitrary Node from a Heap 1. Promote the smaller child of the root node. Root node again fulfills the heap property. Repeat process with demoted child. Continue until demoted child has no smaller children. Heap property is now fulfilled again. This process is called "fixing the heap". Removing an Arbitrary Node from a Heap Figure 19 (continued): Removing the Minimum Value from a Heap Removing an Arbitrary Node from a Heap Figure 19 (continued): Removing the Minimum Value from a Heap Heap Efficiency Insertion and removal operations visit at most h nodes h: Height of the tree If n is the number of elements, then Continued Heap Efficiency Thus, insertion and removal operations take O(log(n)) steps Heap's regular layout makes it possible to store heap nodes efficiently in an array Storing a Heap in an Array Figure 20: Storing a Heap in an Array File MinHeap.java 001: 002: 003: 004: 005: 006: 007: 008: 009: 010: 011: 012: 013: 014: 015: 016: import java.util.*; /** This class implements a heap. */ public class MinHeap { /** Constructs an empty heap. */ public MinHeap() { elements = new ArrayList<Comparable>(); elements.add(null); } Continued File MinHeap.java 017: 018: 019: 020: 021: 022: 023: 024: 025: 026: 027: 028: 029: 030: 031: 032: 033: /** Adds a new element to this heap. @param newElement the element to add */ public void add(Comparable newElement) { // Add a new leaf elements.add(null); int index = elements.size() - 1; // Demote parents that are larger than the new element while (index > 1 && getParent(index).compareTo(newElement) > 0) { elements.set(index, getParent(index)); index = getParentIndex(index); Continued } File MinHeap.java 034: 035: 036: 037: 038: 039: 040: 041: 042: 043: 044: 045: 046: 047: 048: 049: 050: 051: // Store the new element into the vacant slot elements.set(index, newElement); } /** Gets the minimum element stored in this heap. @return the minimum element */ public Comparable peek() { return elements.get(1); } /** Removes the minimum element from this heap. @return the minimum element Continued */ File MinHeap.java 052: 053: 054: 055: 056: 057: 058: 059: 060: 061: 062: 063: 064: 065: 066: 067: 068: public Comparable remove() { Comparable minimum = elements.get(1); // Remove last element int lastIndex = elements.size() - 1; Comparable last = elements.remove(lastIndex); if (lastIndex > 1) { elements.set(1, last); fixHeap(); } return minimum; } Continued File MinHeap.java 069: 070: 071: 072: 073: 074: 075: 076: 077: 078: 079: 080: 081: 082: 083: 084: 085: 086: /** Turns the tree back into a heap, provided only the root node violates the heap condition. */ private void fixHeap() { Comparable root = elements.get(1); int lastIndex = elements.size() - 1; // Promote children of removed root while they are larger than last int index = 1; boolean more = true; while (more) { int childIndex = getLeftChildIndex(index); if (childIndex <= lastIndex) Continued { File MinHeap.java 087: 088: 089: 090: 091: 092: 093: 094: 095: 096: 097: 098: 099: 100: 101: 102: 103: // Get smaller child // Get left child first Comparable child = getLeftChild(index); // Use right child instead if it is smaller if (getRightChildIndex(index) <= lastIndex && getRightChild(index...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UPR Mayagüez - ICOM - 4036
Programming Language Specification and TranslationICOM 4036Fall 2006 Lecture 3Some parts are Copyright 2004 Pearson Addison-Wesley. All rights reserved.3-1Language Specification and TranslationTopics Structure of a Compiler Lexical Sp
UPR Mayagüez - ICOM - 4036
ICOM 4036: PROGRAMMING LANGUAGESLecture 5 Logic Programming 05/17/09What is Prolog Prolog is a `typeless' language with a verysimple syntax. Prolog is declarative: you describe the relationship between input and output, not how to construct th
UPR Mayagüez - ICOM - 4036
University of Puerto Rico Mayagez Department of Electrical and Computer Engineering ICOM 4036: Programming Languages Spring 2006 Problem Set 3 DUE Tuesday April 4, 2006Double IntegralsFor this programming assignment you are required to develop th
UPR Mayagüez - INEL - 4206
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|27 Aug 2002 18:10:48 -0000 vti_extenderversion:SR|5.0.2.3409 vti_title:SR|Department of Electrical and Computer Engineering vti_assignedto:SR| vti_approvallevel:SR| vti_backlinkinfo:VX|courses/spring200
UPR Mayagüez - ICOM - 4036
ICOM 4036: Programming Languages Otoo de 2003 Temas a estudiar para el examen parcial I1) Programming Language History and Design Criteria a) Temas cubiertos en las siguientes lecturas: i) Transparencias Lecture 1 ii) Texto Captulo 1 (todas las secc
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de Mayagez Departamento de Ingeniera Elctrica y ComputadorasICOM 4036 Programming LanguagesPrimavera 2008 Ejercicios de prctica Examen Parcial I 1) Device Turing Machine to accomplish the following
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de Mayagez Departamento de Ingeniera Elctrica y ComputadorasICOM 4036 Programming LanguagesOtoo 2007 Ejercicios de prctica Examen Parcial II 1) Design low-level computer to perform the following co
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de Mayagez Departamento de Ingeniera Elctrica y ComputadorasICOM 4036 Programming LanguagesOtoo de 2007 Ejercicios de prctica Examen Parcial III Write recursive versions in C+ and MIPS assembly lan
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de Mayagez Departamento de Ingeniera Elctrica y ComputadorasICOM 4036 Programming LanguagesOtoo de 2007 Ejercicios de prctica Examen Parcial III Write recursive versions in C+ and MIPS assembly lan
UPR Mayagüez - ICOM - 4029
University of Puerto Rico Mayagez Campus College of Engineering Department of Electrical and Computer Engineering ICOM4029 Compilers Professor: Bienvenido Vlez Technical Assistant: Ren D. BadaLaboratory 2 Lexical AnalysisThe function of a lexica
UPR Mayagüez - ICOM - 4029
University of Puerto Rico Mayagez Campus College of Engineering Department of Electrical and Computer Engineering ICOM4029 Compilers Professor: Bienvenido Vlez Technical Assistant: Ren D. BadaLaboratory 4 PA's 1 &amp; 2 I. Solution to Programming Ass
UPR Mayagüez - ICOM - 4029
University of Puerto Rico Mayagez Campus College of Engineering Department of Electrical and Computer Engineering ICOM4029 Compilers Professor: Bienvenido Vlez Technical Assistant: Ren D. BadaLaboratory 8 Semantic Analysis (continued) I. Role of
UPR Mayagüez - ICOM - 4036
ICOM 4015 Advanced ProgrammingLecture 13 Data Abstraction IReading: Chapter 6Prof. Bienvenido Vlez05/17/09ICOM 40151Data Abstraction Lecture Series Lecture 1 introduction to classes Lecture 2 encapsulation Lecture 3 class speciali
UPR Mayagüez - ICOM - 4036
Chapter 12 Topics Introduction Object-Oriented Programming Design Issues for Object-Oriented Languages Support for Object-Oriented Programming in Smalltalk Support for Object-Oriented Programming in C+ Support for Object-Oriented Programming in
UPR Mayagüez - ICOM - 4036
Variables, Names, Scope and LifetimeICOM 4036 Lecture 9ISBN 0-321-19362-8What is Variable? Imperative view A variable is an abstraction of a memory (state) cell Functional view A variable is an abstraction of a value Every definition int
UPR Mayagüez - ICOM - 4036
University of Puerto Rico Department of Electrical and Computer Engineering ICOM 4036: Programming Languages Spring 2006 Problem Set #1 (DUE Feb 15 In class) 1. Provide the state diagram for a Turing Machine recognizing the set of strings anbncn of e
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|03 Oct 2003 14:17:34 -0000 vti_extenderversion:SR|5.0.2.4330 vti_title:SR|Department of Electrical and Computer Engineering vti_backlinkinfo:VX|courses/spring2002/inel4206/inel4206.htm courses/Fall2003/
UPR Mayagüez - ICOM - 4015
IntroductionAdvanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1Fall 2008Slides adapted from Java Concepts companion slides1Lecture Goals To understand the activity of programming To learn about machine code and high l
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 2Reading: Chapter Two: Using ObjectsICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Two: Using ObjectsICOM 4015 Fall 2008Big Java by Cay H
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 4Chapter Four: Fundamental Data TypesICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Four: Fundamental Data TypesICOM 4015 Fall 2008Big Jav
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 5Chapter Five: DecisionsICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Five: DecisionsBig Java by Cay Horstmann Copyright 2008 by John Wil
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 8Chapter Eight: Designing ClassesICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Eight: Designing ClassesBig Java by Cay Horstmann Copyright
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 9Chapter Nine: Interfaces and PolymorphismICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Nine: Interfaces and PolymorphismBig Java by Cay H
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 10Chapter Ten: InheritanceICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Ten: InheritanceBig Java by Cay Horstmann Copyright 2008 by John
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 13Chapter Thirteen: RecursionICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Thirteen: RecursionBig Java by Cay Horstmann Copyright 2008 b
UPR Mayagüez - ICOM - 4015
ICOM 4015: Advanced ProgrammingLecture 14Chapter Fourteen: Sorting and SearchingICOM 4015 Fall 2008Big Java by Cay Horstmann Copyright 2008 by John Wiley &amp; Sons. All rights reserved.Chapter Fourteen: Sorting and SearchingBig Java by Cay Hor
UPR Mayagüez - INEL - 4206
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|15 Jan 2003 14:53:06 -0000 vti_extenderversion:SR|5.0.2.3409 vti_title:SR|Department of Electrical and Computer Engineering vti_assignedto:SR| vti_approvallevel:SR| vti_backlinkinfo:VX|courses/spring200
UPR Mayagüez - ICOM - 4029
Department of Electrical and Computer Engineering University of Puerto Rico Mayagez CampusICOM 4029 Compilers Fall 2003Prof: Bienvenido Vlez Asistente: Arturo SilvaLaboratorio N 2: Ejecutando FLEX bajo LinuxObjetivos1. Entender la metodologa
UPR Mayagüez - ICOM - 4036
The Nature of ComputingICOM 4036 Lecture 2Prof. Bienvenido VelezSpring 2007ICOM 4036 Programming Laguages Lecture 21Some Inaccurate Yet Popular Perceptions of Computing Computing = Computers Computing = Programming Computing = Software
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de Mayagez Departamento de Ingeniera Elctrica y ComputadorasICOM 4036 Programming LanguagesOtoo 2004 Ejercicios de prctica Examen Parcial I 1. Add a STACK pointer register to the Easy I Data Path.
UPR Mayagüez - ICOM - 4036
ICOM 4036: PROGRAMMING LANGUAGESLecture 5 Functional Programming The Case of Scheme 05/17/09Required Readings Texbook (Scott PLP) Chapter 11 Section 2: Functional Programming Scheme Language Description Revised Report on the Algorithmic Langu
UPR Mayagüez - INEL - 4206
Universidad de Puerto Rico Recinto Universitario de MayagezINEL 4206 MicroprocesadoresPrimavera 2002 Ejercicios de prctica Examen Parcial I 1. Processor Implementation. Add an instruction BrL (Branch and link) to the Easy I processor designed in
UPR Mayagüez - INEL - 4206
INEL 4206 Fall 2002 Exmen I Nombre: _5/17/09 Seccin: _Anota tu nombre y nmero de seccin en todas las hojas del examen AHORA! (penalidad de 5 puntos)Tienes 2 horas para completar tres problemas. Lee cuidadosamente todo el examen antes de empezar
UPR Mayagüez - INEL - 4206
INEL 4206 Fall 2002 Exmen I Nombre: _5/17/09Anota tu nombre y nmero de seccin en todas las hojas del examen AHORA! (penalidad de 5 puntos)Tienes 2 horas para completar todos los problemas. Lee cuidadosamente todo el examen antes de empezar a tra
UPR Mayagüez - ICOM - 4015
ICOM 4015 Advanced ProgrammingLecture 9 Data Abstraction II Class Specialization Subtype PolymorphismProf. Bienvenido Vlez05/17/09ICOM 40151Inheritance Subtype Polymorphism Outline Defining derived classes Member inheritance Method over
UPR Mayagüez - INEL - 4206
Easy IControl Unit(Level 3 Flowcharts) fetchop1DI&lt;0:9&gt; ABUS AOFetchOpfetchop2AO EAB EDB DI00 11x00 00x00 branch on opcode 100 101 0000 01000 011opcodeaoprsoprloadstorebrnjumpFall 2002INEL 4206 Microprocessors
UPR Mayagüez - INEL - 4206
The Nature of ComputingINEL 4206 Microprocessors Lecture 2Bienvenido Vlez Ph. D. School of Engineering University of Puerto Rico - MayagezSome Inaccurate (Although Popular) Perceptions of Computing Computing = (Electronic) Computers Computing
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|15 Jan 2004 16:25:08 -0000 vti_extenderversion:SR|5.0.2.4330 vti_title:SR|Department of Electrical and Computer Engineering vti_syncwith_ece.uprm.edu\:21/public_html:TX|15 Jan 2004 16:25:08 -0000 vti_sy
UPR Mayagüez - INEL - 4206
Universidad de Puerto Rico Recinto Universitario de MayagezINEL 4206 MicroprocesadoresPrimavera 2002 Ejercicios de prctica Examen Parcial I 1. Processor Implementation. Add an instruction BrL (Branch and link) to the Easy I processor designed in
UPR Mayagüez - INEL - 4206
INEL 4206 Spring 2002 Exmen II Nombre: _5/17/09 Seccin: _Anota tu nombre y nmero de seccin en todas las hojas del examen AHORA! (penalidad de 5 puntos)Tienes 2 horas para completar tres problemas. Lee cuidadosamente todo el examen antes de empez
UPR Mayagüez - ICOM - 4036
Universidad de Puerto Rico Recinto Universitario de MayagezICOM 4036 Programming LanguagesOtoo 2003 Ejercicios de prctica Examen Parcial II 1. Write a logic program in Prolog to compute the greatest common divisor (GCD) of 2 integer arguments. Th
UPR Mayagüez - ICOM - 4029
Programming Assignments Dates Happy Hour October 15 November 22 December 14-16PA 3 (Parser) 4a (Semantic Analyzer) 4b 5a (Code Generator) 5bHand-out Date September 29 October 11 October 25 November 15 November 29Deadline October 11 October 25 N
UPR Mayagüez - INEL - 4206
Evaluacion Curso INEL 4206 Segundo Examen.Menciona los aspectos que ms te gustan de la clase INEL 4206 en orden decreciente de importancia.AspectoEl uso de las transparencias en la clase y tener un buen Web-Site para el curso.Porcentaje37.09
UPR Mayagüez - INEL - 4206
Universidad de Puerto Rico Mayaguez Department of Electrical and Computer Engineering INEL 4206 Microprocessors Exam III Summary of Topics Review all previous material up to Exam II Procedures o Parameter Passing o Stack frames o Recursive proce
UPR Mayagüez - ICOM - 4015
Sus contestaciones al problemario 2 deben ser entregadas electrnicamente por e-mail siguiendo las siguientes instrucciones.0. Crear un directorio para almacenar los archivos relacionados con cadaproblemario. No tiene que hacer este paso si ya lo h
UPR Mayagüez - ICOM - 4015
Department of Electrical and Computer Engineering University of Puerto Rico Mayagez ICOM 4015 Advanced Programming Fall 2006 Exam I Practice Exercises and Problem Set 1 DUE: September 14, 2006 In class 1) Create a new Eclipse project titled icom4015
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timelastmodified:TR|15 Aug 2005 18:50:12 -0000 vti_timecreated:TR|08 Nov 2004 11:08:29 -0000 vti_title:SR|Universidad de Puerto Rico vti_extenderversion:SR|5.0.2.6417
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|29 Aug 2005 18:28:44 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|20 Jan 2004 16:01:58 -0000 vti_title:SR|Chapter 1 vti_nexttolast
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|18 Oct 2005 18:41:18 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|04 Sep 2003 17:25:30 -0000 vti_title:SR|Imperative Programming T
UPR Mayagüez - PA - 4029
ICOM 4029 Compiler Writing 1HandoutProgramming Assignment I1 Due Friday, September 3, 2004 at 11:59pmThis assignment asks you to write a short Cool program. The purpose is to acquaint you with the Cool language and to give you experience with so
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|13 Oct 2004 16:46:56 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|04 Sep 2003 17:25:30 -0000 vti_title:SR|Imperative Programming T
UPR Mayagüez - ICOM - 4036
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|11 May 2004 18:57:00 -0000 vti_extenderversion:SR|5.0.2.4803 vti_backlinkinfo:VX|courses/Fall2004/icom4036/icom4036.htm courses/Spring2004/icom4036/icom4036.htm vti_author:SR|CHURCH\bvelez vti_modifiedb
UPR Mayagüez - INEL - 4206
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|25 Nov 2002 14:19:52 -0000 vti_extenderversion:SR|5.0.2.3409 vti_author:SR|CHURCH\bvelez vti_modifiedby:SR|CHURCH\bvelez vti_timecreated:TR|22 Nov 2002 13:30:27 -0000 vti_title:SR|Problema vti_assignedt
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|30 Jan 2001 13:43:12 -0000 vti_extenderversion:SR|4.0.2.4426 vti_backlinkinfo:VX|courses/spring2001/icom4015/icom4015.htm vti_cacheddtm:TX|30 Jan 2001 13:43:12 -0000 vti_filesize:IR|42496 vti_cachedlink
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|18 Sep 2001 12:37:56 -0000 vti_extenderversion:SR|4.0.2.4426 vti_filesize:IR|60416 vti_title:SR|ICOM 4015 Advanced Programming vti_assignedto:SR| vti_approvallevel:SR| vti_backlinkinfo:VX|courses/fall20
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|14 Nov 2001 16:22:06 -0000 vti_extenderversion:SR|4.0.2.4426 vti_backlinkinfo:VX|courses/fall2001/icom4015/icom4015.htm vti_filesize:IR|44544 vti_title:SR|ICOM 4015 Advanced Programming vti_syncwith_ece
UPR Mayagüez - PA - 4029
ICOM 4029 Compiler WritingHandout 4Programming Assignment IV1 A Semantic Analyzer for COOLDue Friday, November 14, 2003i.IntroductionIn this assignment you will implement the static semantics of Cool. You will use the abstract syntax trees
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|02 Oct 2001 15:15:56 -0000 vti_extenderversion:SR|5.0.2.4803 vti_title:SR| vti_backlinkinfo:VX|courses/fall2001/icom4015/icom4015.htm vti_syncwith_ece.uprm.edu\:21/public_html:TX|02 Oct 2001 15:15:56 -0
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_author:SR|Michael vti_timecreated:TR|29 Feb 2000 02:30:38 -0000 vti_timelastmodified:TR|27 Mar 2000 14:32:00 -0000 vti_filesize:IR|50176 vti_title:SR|ICOM 4015 Advanced Programming vti_assignedto:SR| vti_approvallevel:SR|
UPR Mayagüez - ICOM - 4015
vti_encoding:SR|utf8-nl vti_author:SR|Michael vti_timecreated:TR|29 Feb 2000 02:30:38 -0000 vti_timelastmodified:TR|27 Mar 2000 14:32:00 -0000 vti_filesize:IR|59904 vti_title:SR|ICOM 4015 Advanced Programming vti_assignedto:SR| vti_approvallevel:SR|
UPR Mayagüez - ICOM - 4029
vti_encoding:SR|utf8-nl vti_timelastmodified:TR|04 Oct 2004 20:46:56 -0000 vti_extenderversion:SR|5.0.2.6417 vti_author:SR|BVWS\bvelez vti_modifiedby:SR|BVWS\bvelez vti_timecreated:TR|04 Oct 2004 20:46:56 -0000 vti_cacheddtm:TX|04 Oct 2004 20:46:56 -