16 Pages

ch04s5

Course: CS 2510, Fall 2009
School: Bowling Green
Rating:
 
 
 
 
 

Word Count: 1453

Document Preview

Functions, Relations, and M atrices Mathematical Structures for Computer Science Chapter 4 Copyright 2006 W.H. Freeman & Co. MSCS Slides The Mighty Mod Function The Mighty Mod Function q q We define the modulo n function as follows: If x = qn + r, 0 r n, then x mod n = r. In other words, x mod n is the nonnegative remainder (also called the residue of x modulo n) when x is divided by the positive...

Register Now

Unformatted Document Excerpt

Coursehero >> Ohio >> Bowling Green >> CS 2510

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.
Functions, Relations, and M atrices Mathematical Structures for Computer Science Chapter 4 Copyright 2006 W.H. Freeman & Co. MSCS Slides The Mighty Mod Function The Mighty Mod Function q q We define the modulo n function as follows: If x = qn + r, 0 r n, then x mod n = r. In other words, x mod n is the nonnegative remainder (also called the residue of x modulo n) when x is divided by the positive integer n. Section 4.5 The Mighty Mod Function 2 Hashing q q q q A hash function h: S T, where the domain S is a set of text strings or integer values and the codomain T is the set of integers {0, 1, ... , t - 1}, where t is some relatively small positive integer. If the domain S consists of text strings, we can imagine them encoded in some way into integer values. For example, an algorithm as simple as converting each individual letter of a text string into its position in the alphabet and adding up the resulting list. The function h therefore maps a potentially large set of values S into a relatively small window of integer values T. Consequently h isn't likely to be a one-toone function. The Mighty Mod Function 3 Section 4.5 Hashing q q q q A hash function is often used as part of a search algorithm. In a search using a hash function, n elements are stored in an array (a one-dimensional table) called a hash table, where the array is indexed from 0 through t - 1; the table is of size t. The element x is passed as the argument to the hash function, and the resulting h(x) value gives the array index at which the element is then stored. Later, when a search is carried out, the target value is run through the same hash function, giving an index location in the hash table, which is where to look for the matching stored element. Section 4.5 The Mighty Mod Function 4 Hashing q q q However, because the hash function is not one-to-one, things are not quite that simple. Different values may hash to the same array index, producing a collision. Here are several collision resolution algorithms available. One is called linear probing. s Keep going in the array and store element x in the next available empty slot. q Another method, called chaining, builds a linked list for each array index. Section 4.5 The Mighty Mod Function 5 Hashing q Following are the desirable properties of a hash function: 1. 2. Given an argument value x, h(x) can be computed quickly. The number of collisions will be reduced because h(x) does a good job of distributing values throughout the hash table. q q Use of a modulo function as the hash function accomplishes goal 1. Goal 2 is harder to achieve, but distribution seems to work better on the average if the table size (the modulo value) is a prime number. Section 4.5 The Mighty Mod Function 6 Hashing q q q q The average number of comparisons required to search for an element using hashing depends on the ratio of n to the total table size t. If this ratio is low, then (using linear probing) there are lots of empty slots, so you won't have to look very far to find a place to insert a new element into the table. If this ratio is low and chaining is used, the average length of any linked list you may have to (sequentially) search for a target element should be short. This ratio n/t is called the load factor of the hash table. Section 4.5 The Mighty Mod Function 7 Computer Security q q q q The mod function plays a part in many aspects of security. Military information, financial information, and company proprietary information that must be transmitted securely uses some encoding/decoding scheme. The original information (called the plaintext) is encrypted using an encryption key, resulting in coded text called the ciphertext. The ciphertext is transmitted, and when it is received, it can be decoded using the corresponding decryption key. Encryption and decryption are inverse functions in the sense that: s decryption(encryption(plaintext)) = plaintext The Mighty Mod Function 8 Section 4.5 Computer Security q q q Cryptography is the study of various encryption/decryption schemes. Military use of cryptographic techniques can be traced back to Julius Caesar, who sent messages to his generals in the field using a scheme now known as the Caesar cipher. Let us assume that plaintext messages only use the 26 capital letters of the alphabet, that spaces between words are suppressed, and that each letter is first mapped to its corresponding position in the alphabet. Section 4.5 The Mighty Mod Function 9 Computer Security q q q q We'll denote this mapping as the bijection g: {A, ... , Z} {0, ... , 25}. Then a positive integer key value k is chosen that shifts each number k positions to the right with a "wrap-around" back to the beginning if needed (this is the mod function). Finally, the function g-1 is applied to translate the resulting number back into a letter. The encoding function is given by: s f(p) = g-1([g(p) + k] mod 26) f -1(c) = g-1([g(c) - k] mod 26) q The decoding function is: s Section 4.5 The Mighty Mod Function 10 Computer Security q q q The Caesar cipher is a simple substitution cipher, meaning that each plaintext character is coded consistently into the same single ciphertext character. Encryption techniques where a single plaintext character contributes to several ciphertext characters introduce diffusion. The advantage to diffusion is that it hides the frequency statistics of individual letters, making analysis of an intercepted ciphertext message much more difficult. DES (Data Encryption Standard) is an internationally standard encryption algorithm developed in 1976. DES was developed to safeguard the security of digital information, so we may consider the plaintext to be a string of bits. The Mighty Mod Function 11 Section 4.5 Computer Security q q q q q DES is a block cipher. A block of 64 plaintext bits is encoded as a unit using a 56-bit key. This results in a block of 64 ciphertext bits. Changing one bit in the plaintext or one bit in the key changes about half the resulting 64 ciphertext bits, so DES exhibits high diffusion. Because the DES algorithm is well known, the only "secret" part is the 56-bit key that is used. Section 4.5 The Mighty Mod Function 12 Computer Security q q q q AES (Advanced Encryption Standard) is also a block encryption scheme, but it uses a key length of 128 bits or more. AES also uses a form of the Euclidean algorithm. Disadvantage of both DES and AES is that they are symmetric encryption (also called private key encryption) schemes. The same key is used to both encode and decode the message. In a private key encryption scheme, both the sender and receiver must know the key. The problem of securely transmitting a message turns into the problem of securely transmitting the key to be used for the encryption and decryption. Section 4.5 The Migh...

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:

Bowling Green - CS - 2510
Relations, Functions, and MatricesMathematical Structures for Computer ScienceChapter 4Copyright 2006 W.H. Freeman & Co.MSCS SlidesRelations, Functions and MatricesMatrixqData about many kinds of problems can often be represented using
Bowling Green - CS - 2510
Graphs and TreesMathematical Structures for Computer ScienceChapter 5Copyright 2006 W.H. Freeman & Co.MSCS SlidesGraphs and TreesTree TerminologyqqqA special type of graph called a tree turns out to be a very useful representatio
Bowling Green - CS - 2510
Gr aph Algor ithmsM athematical Str uctur es for Computer ScienceChapter 6Copyr ight 2006 W.H . F r eeman & Co.M SCS SlidesGr aph Algor ithmsEuler Pat hqq qqqDEFINITION: EULER PATH An Euler path in a graph G is a path that uses e
Bowling Green - CS - 2510
Graph AlgorithmsMathematical Structures for Computer ScienceChapter 6Copyright 2006 W.H. Freeman & Co.MSCS SlidesGraph AlgorithmsGraph Traversalqqq qGraph traversal is the process of writing out all the nodes of a simple, connect
Bowling Green - CS - 2510
Boolean Algebra and Computer LogicMathematical Structures for Computer ScienceChapter 7Copyright 2006 W.H. Freeman & Co.MSCS SlidesBoolean Algebra StructureModels or AbstractionsqqMathematical principles are models or abstractions in
Bowling Green - CS - 2510
Boolean Algebra and Computer LogicMathematical Structures for Computer ScienceChapter 7Copyright 2006 W.H. Freeman & Co.MSCS SlidesBoolean Logic and Computer LogicCombinational Networksq qqqqBasic logic elements Imagine that the
Bowling Green - CS - 2510
Boolean Algebra and Computer LogicMathematical Structures for Computer ScienceChapter 7Copyright 2006 W.H. Freeman & Co.MSCS SlidesBoolean Logic and Computer LogicMinimizationqqqTo design a logic network for the function, the ideal
Bowling Green - CS - 2510
M odeling Arithmetic, Computation, and LanguagesMathematical Structures for Computer ScienceChapter 8Copyright 2006 W.H. Freeman & Co.MSCS SlidesTuring MachinesTuring MachinesqA Turing machine is essentially a finite-state machine with
Bowling Green - CS - 2510
Bowling Green - CS - 2510
Bowling Green - CS - 2510
Bowling Green - CS - 2510
Bowling Green - CS - 2510
Bowling Green - CS - 2510
Iowa State - MR - 0518
Wallace's Farmer, IA 05-17-07 CSIF Embarks on Fourth Year of Service Rod Swoboda rswoboda@farmprogress.com The Coalition to Support Iowa's Farmers began its fourth year of service on May 11, helping livestock farmers grow responsibly and successfully
Iowa State - PUBLIC - 0518
Wallace's Farmer, IA 05-17-07 CSIF Embarks on Fourth Year of Service Rod Swoboda rswoboda@farmprogress.com The Coalition to Support Iowa's Farmers began its fourth year of service on May 11, helping livestock farmers grow responsibly and successfully
Stanford - PUBS - 20620
International Physicians for the Prevention of Nuclear Warhttp:/www.ippnw.org/NukeEPWsFull.html. Find a Topic.Go!Nuclear War PreventionNuclear Bunker Busters: The Medical Consequences1 of 86/1/04 1:20 PMInternational Physicians for the
CSU Northridge - VCEED - 002
CSU Northridge - VCEED - 002
(1) Discuss the processes of exchange of oxygen and carbon dioxide that occur at the alveoli and muscle cells of mammals. Include in your answer a description of the transport of these gases in the blood.Table 3.2: Grid for answering an essay quest
CSU Northridge - VCEED - 002
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41A B C The Sourcebook for Teaching Science Chapter 20.1DEFGHIJFigure 20.2 Sample Spreadsheet CalculationsTemperature c
CSU Northridge - VCEED - 002
Atmospheric Carbon Dioxide Concentrations at Mauna Loa Observatory(The Sourcebook for Teaching Science, Figure 20.8) Year ppmMar-58 Apr-58 May-58 Jun-58 Jul-58 Aug-58 Sep-58 Oct-58 Jan-59 Feb-59 Mar-59 Apr-59 May-59 Jun-59 Jul-59 Aug-59 Sep-59 Oct
CSU Northridge - VCEED - 002
Sourcebook for Teaching Science Chapter 20.4 Ozone pollution (24 h period) mountain beach valley hourAtmpspheric Ozone Concentration (one day period)0.90 0.90Atmpspheric Ozone Concentration (one day period)1 2 3 4 5 6 7 8 9 10 11 12 13
CSU Northridge - VCEED - 002
Sourcebook for Teaching Science Chapter 20.5 Age Profiles (2004) source: US Census Bureau Afghanistan GermanyPopulation Profiles40 percent of population 30 20 10 0 10-19 0-9 30-39 50-59 70-79 80-89 9020-29 40-49 60-69 Afghanistan USAage 09 10
CSU Northridge - VCEED - 002
Norm Herr Types of Graphs The Soucebook for Teaching Science (Chapter 20) Causes of Death in the US 2005 1 heart disease 654,092 2 cancer 550,270 3 stroke 150,147 4 chronic respiratory diseases 123,884 5 accidents 108,694 6 influenza & pneumonia
CSU Northridge - VCEED - 002
The Sourcebook for Teaching Science - Chapter 20.7Seasonal High and Low Temperatures cityAtlanta Baltimore Boston Chicago Cleveland Dallas Denver Detroit Houston Kansas City Los Angeles Miami Minneapolis Nashville New Orleans New York Philadelphia
LSU - ETD - 04152009
ANALYSIS OF PROGRESSIVE LAG REINFORCMENT SCHEDULES AND ENVIRONMENTAL CUES ON VERBAL RESPONSE VARIABILITYA Dissertation Submitted to the Graduate Faculty of the Louisiana State University and Agricultural and Mechanical College in partial fulfillmen
CSU Northridge - VCEED - 002
Complete the following conceptual grid Table 9.3 Conceptual grid comparing three classes of fishtemperatur e regulation Agnatha Chondrichthyes Osteichthyes fins respiration skeleton swim bladder mouth examplesDrag this box off to see a solution to
CSU Northridge - VCEED - 002
California State UniversityNorthridgeAPPLICATION FOR ADMISSION TO MASTER'S DEGREE PROGRAM Science EducationDepartment of Secondary EducationMichael D. Eisner College of Education Personal Information (name street state, zip)home phone emai
CSU Northridge - VCEED - 002
California State UniversityNorthridgeAPPLICATION FOR ADMISSION TO MASTER'S DEGREE PROGRAM Science EducationDepartment of Secondary EducationMichael D. Eisner College of Education Personal Information (name street state, zip)home phone emai
Millersville - CS - 161
Essential Emacs Commands (by Gary M. Zoppetti)=(C = Control, M = Meta = ESC)Invoking Emacs (from the shell)-emacs &run Emacs in the background (using X Windows)emacs -nwrun Emacs in a terminal window (cannot use menus)File Handling-C
Millersville - CS - 362
Introduction: C+, Data Structures Scope Resolution Operator Storage Containers -General -Vectors -Lists -Maps ADT's Classes -Declaration -Private/Public Sections time24 function addTime() Rectangle Class API -Constructor -Operations -RandomNumber Cl
Millersville - CS - 362
Heaps, Binary Files, and Bit Sets Complete Binary Trees Maximum and Minimum Heaps pushHeap () popHeap () Adjusting popHeap() Heap Sort Heapifying File Structure Direct File Access bitVector Class Lossless Compression Lossy Compression Example of Bui
Millersville - CS - 362
Divide and Conquer Building a Ruler: drawRuler() Merge Algorithm Partitioning and Merging of Sublists in mergeSort() mergeSort () Recursion Tree Quicksort Finding kth Largest Element powerSet() Example Recursive calls for fib(5)Lecture 14Effect
Millersville - CS - 362
Lecture 15 Graphs Graph Categories Example of Digraph Connectedness of Digraph Adjacency Matrix Adjacency Set1Graphs Graph G = (V, E) graph (digraph)V is a set of vertices E is a set of edges E consists of ordered pairs of vertices E = { (
Millersville - CS - 362
Sorting, Searching, Recursion Introduction to Algorithms Selection Sort Algorithm -Integer Version -String Version Template Syntax Recursion Sorting Alg. Search Algorithms Illustrating Binary Search Big-O Notation Constant Time Algorithms Linear Tim
Millersville - CS - 362
Containers Overview and Class VectorContainer Types Sequence Containers Associative Containers Adapter Classes The List Container Stack Containers Queue Containers Priority Queue Containers Set Containers Map Containers C+ Arrays Vectors Insertion S
Millersville - CS - 362
Pointers and Dynamic MemoryVertical / Horizontal View . . . Data Addresses in Memory Matrices Declaring Pointer Variables Assigning Values to Pointers Accessing Data with Pointers Arrays and Pointers Operator `new' Operator `delete' Copy Constructor
Millersville - CS - 362
List Container and IteratorsShifting blocks of elements. Linked Lists The list ADT CLASS list Constructors CLASS list Operations CLASS list:iterator Operations Inserting an element into a list Removing an element from a list Ordered lists Splicing t
Millersville - CS - 362
Lecture 9Binary Trees Tree Structures Tree Node Level and Path Length Binary Tree Definition Sample Trees Binary Tree Nodes Binary Search Trees Using Binary Search Trees - Removing Duplicates Find Insert, Erase1Trees k-ary trees= |V| - 1
Millersville - CS - 161
Building Java ProgramsChapter 1: Introduction to Java ProgrammingCopyright 2006 by Pearson Education1Chapter outlinebasic Java programs programs and programming languages output with println statements syntax and errors String liter
Millersville - CS - 161
Building Java ProgramsSupplement 3G: GraphicsCopyright 2006 by Pearson Education1Chapter outlinedrawing 2D graphics DrawingPanel and Graphics objects drawing and filling shapes coordinate system colors drawing with loops drawing wit
Millersville - CS - 161
Building Java ProgramsChapter 6: File ProcessingCopyright 2006 by Pearson Education1Chapter outlinefile input using Scanner File objects throwing exceptions file names and folder paths tokenbased file processinglinebased file pr
Millersville - CS - 161
Building Java ProgramsChapter 8: ClassesCopyright 2006 by Pearson Education1Chapter outlineobjects, classes, and objectoriented programming relationship between classes and objects abstractionanatomy of a class fields instance m
Millersville - CS - 161
Building Java ProgramsChapter 10: ArrayListCopyright 2006 by Pearson Education1Chapter outlineArrayList basic operations searching for elements wrapper classesComparable interface natural ordering and compareTo implementing Compa
Millersville - CS - 161
Building Java ProgramsChapter 11: Java Collections FrameworkCopyright 2006 by Pearson Education1Chapter outlineLists Collections LinkedList vs. ArrayList IteratorsSets TreeSet vs. HashSet Set operationsMaps Map operation
Millersville - CS - 161
Building Java ProgramsChapter 12: RecursionCopyright 2006 by Pearson Education1Chapter outlinethinking recursively recursive algorithms iteration vs. recursion integer exponentiation (pow) infinite recursion tracing recursive methods gre
Millersville - CS - 161
Building Java ProgramsChapter 13: Searching and SortingCopyright 2006 by Pearson Education1Chapter outlineSearching and sorting in the Java class libraries sequential and binary search sorting shuffling custom ordering with Comparator
Millersville - CS - 161
Building Java ProgramsChapter 14: Graphical User InterfacesCopyright 2006 by Pearson Education1Chapter outlineGUI basics Graphical input and output with JOptionPane Frames, buttons, labels, and text fields Changing a frame's layout Han
CSU Northridge - VCEED - 002
for California Public Schools1999 EDITIONHANDBOOKCIENCE AFETYCALIFORNIA DEPARTMENT OF EDUCATION SACRAMENTO, 1999TMENTOFEDUCAN TIODEPARTEOFCA LIF ORPublishing InformationThe Science Safety Handbook for Californi
CSU Northridge - VCEED - 002
APPENDIX MSample Chemical Inventory School Inventory prepared by Date acquired 8-94 2-94 Chemical name Acetic acid Acetone Concentration Type of /Purity container 1.0 99.5% Glass Metal can Quantity 1 liter 400 ml Hazard class Storage Storage locatio
Millersville - CS - 162
Intellectual Property (IP)Intellectual Property Creative works that have economic value and are protected by law IP law limits copying, performing, distributing protected works Purpose: provide economic incentive for individuals to produce works
Millersville - CS - 162
Building Java ProgramsClasses1Outlineobjects, classes, and objectoriented programming relationship between classes and objects abstractionanatomy of a class fields instance methods constructors encapsulationadvanced classes
Millersville - CS - 162
Software Development Objectives: Discuss the goals of software development Identify various aspects of software quality Examine two development life cycle models Explore the notation of the Unified Modeling Language (UML) Examine issues related
CSU Northridge - VCEED - 002
APPENDIX 3.2 CHEMICAL STORAGE NFPA Hazard Codes The National Fire Protection Association developed a standard label to display chemical hazard ratings (see Appendix 3-3). The NFPA label is required by many institutions, industries, and municipalities
Millersville - CS - 162
Building Java ProgramsArrayList1OutlineArrayList basic operations searching for elements wrapper classesComparable interface natural ordering and compareTo implementing Comparable2ArrayList3Listslist: an ordered sequence
Millersville - CS - 162
Building Java ProgramsInheritance and Interfaces1Outlinebackground categories of employees relationships and hierarchies creating subclasses overriding behavior multiple levels of inheritance interacting with the superclass using the super
Millersville - CS - 162
Building Java ProgramsJava Collections Framework1OutlineLists Collections LinkedList vs. ArrayList IteratorsSets TreeSet vs. HashSet Set operationsMaps Map operations Map views TreeMap vs. HashMap2Lists3Collections
Iowa State - NR - 78044
Iowa State - NR - 91405
To Your HealthDecember 2008Enjoy Tasty (and Healthy) Party TreatsMany parties are focused on food particularly this time of year. Cookies, candies, pies, cakes, beverages of various kinds and so much more adorn tables. While all foods or bevera
Iowa State - ADE - 93901
Icebreakers and Group GamesTarget Audience: Youth 5-11 years old. Description: Icebreakers and other games are a good way to ease the tension as groups and/or teams are being formed. The 22 icebreakers and games in this collection are designed to he
CSU Northridge - VCEED - 002
121086 42010C Volume of carbon dioxide (mL) Time (m) A B C 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 020C Volume of carbon dioxide (mL) Time (m) A