1 Data Structures CSCI 132, Spring 2014 Lecture 32 Tables I.

Slides:



Advertisements
Similar presentations
Tables and Information Retrieval
Advertisements

REACH-CRC. Lookup Functions INDEX-MATCH LOOKUP Database Functions DSUM DMIN DMAX DCOUNT DAVERAGE.
Chapter 6 Lists and Dictionaries CSC1310 Fall 2009.
The Dictionary ADT Definition A dictionary is an ordered or unordered list of key-element pairs, where keys are used to locate elements in the list. Example:
MIS: Chapter 14 Cumulative concepts, features and functions, plus new functions COUNTIFS, SUMIFS, AVERAGEIFS (Separate ppt on REACH.louisville.edu) All.
Arrays.
Arrays. 1D Array Representation In C 1-dimensional array x = [a, b, c, d] map into contiguous memory locations Memory abcd start location(x[i]) = start.
Data Structures Michael J. Watts
Nov 12, 2009IAT 8001 Hash Table Bucket Sort. Nov 12, 2009IAT 8002  An array in which items are not stored consecutively - their place of storage is calculated.
Introduction to GTECH 201 Session 13. What is R? Statistics package A GNU project based on the S language Statistical environment Graphics package Programming.
BTrees & Bitmap Indexes
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 48 Hashing.
1 Lecture 9  Arrays  Declaration  Initialization  Applications  Pointers  Declaration  The & and * operators  NULL pointer  Initialization  Readings:
R-1 University of Washington Computer Programming I Lecture 17: Multidimensional Arrays © 2000 UW CSE.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (excerpts) Advanced Implementation of Tables CS102 Sections 51 and 52 Marc Smith and.
Matrices Write and Augmented Matrix of a system of Linear Equations Write the system from the augmented matrix Solve Systems of Linear Equations using.
Recall that a square matrix is one in which there are the same amount of rows as columns. A square matrix must exist in order to evaluate a determinant.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
With Microsoft Access 2007 Volume 1© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2007 Volume 1 Chapter.
Abstract Data Types (ADTs) and data structures: terminology and definitions A type is a collection of values. For example, the boolean type consists of.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Handling Lists F. Duveau 16/12/11 Chapter 9.2. Objectives of the session: Tools: Everything will be done with the Python interpreter in the Terminal Learning.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture8.
1 Performing Spreadsheet What-If Analysis Applications of Spreadsheets.
Chapter 9 Tables and Information Retrieval. Tables Introduction In chapter 7 we showed that –By use of key comparisons alone, it is impossible to complete.
259 Lecture 13 Spring 2013 Advanced Excel Topics – Arrays.
Lecture 7 Matrices CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
ARRAYS 1 Week 2. Data Structures  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently 
Java Script: Arrays (Chapter 11 in [2]). 2 Outline Introduction Introduction Arrays Arrays Declaring and Allocating Arrays Declaring and Allocating Arrays.
Arrays 1 Multiple values per variable. Why arrays? Can you collect one value from the user? How about two? Twenty? Two hundred? How about… I need to collect.
 DATA STRUCTURE DATA STRUCTURE  DATA STRUCTURE OPERATIONS DATA STRUCTURE OPERATIONS  BIG-O NOTATION BIG-O NOTATION  TYPES OF DATA STRUCTURE TYPES.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
C++ STL CSCI 3110.
Data Structures and Algorithms Lecture 3 Instructor: Quratulain Date: 8 th September, 2009.
Built-in Data Structures in Python An Introduction.
HASHING PROJECT 1. SEARCHING DATA STRUCTURES Consider a set of data with N data items stored in some data structure We must be able to insert, delete.
Lecture 12COMPSCI.220.FS.T Symbol Table and Hashing A ( symbol) table is a set of table entries, ( K,V) Each entry contains: –a unique key, K,
The List ADT A sequence of zero or more elements A 1, A 2, A 3, … A N-1 N: length of the list A 1 : first element A N-1 : last element A i : position i.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Matrices and Systems of Equations
Chapter 15 A External Methods. © 2004 Pearson Addison-Wesley. All rights reserved 15 A-2 A Look At External Storage External storage –Exists beyond the.
Chapter 13 C Advanced Implementations of Tables – Hash Tables.
 2008 Pearson Education, Inc. All rights reserved. 1 Arrays and Vectors.
Lecture 5 functions 1 © by Pearson Education, Inc. All Rights Reserved.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
Computer Science: A Structured Programming Approach Using C1 8-7 Two-Dimensional Arrays The arrays we have discussed so far are known as one- dimensional.
+ Arrays & Random number generator. + Introduction In addition to arrays and structures, C supports creation and manipulation of the following data structures:
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
Data Structure and Algorithm: CIT231 Lecture 3: Arrays and ADT DeSiaMore DeSiaMorewww.desiamore.com/ifm1.
1. 2  Introduction  Array Operations  Number of Elements in an array One-dimensional array Two dimensional array Multi-dimensional arrays Representation.
1 Data Structures CSCI 132, Spring 2014 Lecture 33 Hash Tables.
Two dimensional arrays A two dimensional m x n array A is a collection of m. n elements such that each element is specified by a pair of integers (such.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
Table of Contents Matrices - Definition and Notation A matrix is a rectangular array of numbers. Consider the following matrix: Matrix B has 3 rows and.
1 ENERGY 211 / CME 211 Lecture 4 September 29, 2008.
© 2006 Pearson Addison-Wesley. All rights reserved15 A-1 Chapter 15 External Methods.
Precalculus Section 14.1 Add and subtract matrices Often a set of data is arranged in a table form A matrix is a rectangular.
Arrays. 1D Array Representation In C++ 1-dimensional array x = [a, b, c, d] map into contiguous memory locations Memory abcd start location(x[i]) = start.
Windows Programming Lecture 03. Pointers and Arrays.
CSC 212 – Data Structures Lecture 28: More Hash and Dictionaries.
C Programming Lecture 15 Two Dimensional Arrays. Two-Dimensional Arrays b The C language allows arrays of any type, including arrays of arrays. With two.
Matrix Operations.
Lecture No.43 Data Structures Dr. Sohail Aslam.
Matrix Operations.
CSCI N207 Data Analysis Using Spreadsheet
MATRICES MATRIX OPERATIONS.
MSIS 655 Advanced Business Applications Programming
Database SQL.
A type is a collection of values
Presentation transcript:

1 Data Structures CSCI 132, Spring 2014 Lecture 32 Tables I

2 Table Lookup You can speed up search if you store items in a table. Assign 1 item per key, for integer keys ranging from 1 to n. To find an item, simply access the index given by its key no it by if at we in of an Table lookup has running time of O(1)

3 Example: Color Tables

4 Rectangular Tables c s c i f u n ! v e r y (0, 0) (2, 3) Tables are very often in rectangular form with rows and columns. Most programming languages accommodate rectangular tables as 2-D arrays.

5 Rectangular Tables in Memory c s c i f u n ! v e r y (0, 0) (2, 3) Row-major order: c s c i f u n ! v e r y Column-major order: c f v s u e c n r i ! y row 0row 1row 2 col 0col 1col 2col 3

6 Computing the index in memory The compiler must be able to convert the index (i, j) of a rectangular table to the correct position in the sequential array in memory. For an m x n array (m rows, n columns): Each row is indexed from 0 to m-1 Each column is indexed from 0 to n - 1 c... i f... ! v... y row 0row 1row 2 Item at (i, j) is at sequential position i * n + j 0n-1n2n2n-1

7 Access Arrays Multiplication can be slow. To speed things up, we can compute the beginning index of each row and store it in an auxiliary array, called an access array. 0 n 2n 3n To find the position of (i, j), take the value at index i from the access array and add j. (access_array[i] + j) In general, an access array is an auxiliary array used to find data that is stored elsewhere. access_array

8 Triangular Tables Some rectangular tables have positions where the entry is always zero. To save memory, we omit these positions from our table. Definitions: A matrix is a table of numbers. A lower triangular matrix is a matrix in which non zero entries are only in positions for which i >= j:

9 Leaving out the zeros

10 Calculating Access Array values Number of cells preceding the start of row i: i = i (i + 1) /2 Each entry (i, j) is located at position: j + i (i + 1)/2 One can compute the values of the access array once and then not again for the entire program. You do not need multiplication to compute these values: 0, 0 + 1, 1 + 2, (1 + 2) + 3,....

11 Jagged Tables

12 Inverted Tables

13 Functions and Tables A function starts with an argument and computes a value. A table starts with an index and looks up a value. A function assigns to each element in set A (the domain) a single element from set B (the codomain). A table assigns to each index in set A (the index set) a single value from set B (the base type).

14 The Table ADT A table with index set I and base type T is a function from I into T together with the following operations. Standard operations: 1. Table access: Evaluate the function at any index in I. 2. Table assignment: Modify the function by changing its value at a specified index in I to the new value specified in the assignment. Additional operations: 3. Creation: Set up a new function from I to T. 4. Clearing: Remove all elements from the index set I, so the remaining domain is empty. 5. Insertion: Adjoin a new element x to the index set I and define a corresponding value of the function at x. 6. Deletion: Delete an element x from the index set I and restrict the function to the resulting smaller domain.

15 Lists vs. Tables Lists are inherently sequential; Tables are not. List retrieval requires search O(lgn); Tables do not: O(1) Traversal is natural for a list, not for a table.