Hash 1 - CSC2100A Tutorial Hashing (Part 1) Spring...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
CSC2100A Spring 2006-2007 Spring 2006/2007 CSC2100A Tutorial Hashing (Part ) 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSC2100A Spring 2006-2007 Hashing - overview • Implement a 2d array using malloc and free 1 2 array 2 for (i = 0; i < m; i++) { array[i] = (int *) malloc(n * sizeof(int)); } 1 int **array; array = (int **) malloc(m * sizeof(int *));
Background image of page 2
CSC2100A Spring 2006-2007 Hashing - overview • Implement a 2d array using malloc and free 1 2 array 1 2 for (i = 0; i < m; i++) free(array[i]); free(array);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSC2100A Spring 2006-2007 Hashing - overview • How to use a 1d array to implement a 2d array? 012 0 1 2 Column Row A[1][0] 0 12345678 91 0 1 1 3
Background image of page 4
CSC2100A Spring 2006-2007 Hashing - overview a b c e f g i j k 012 0 1 2 Column Row a b c d e f g h i 0 12345678 d h l j k l 91 0 1 1 3 char *A = new char [12]; int row_major_ordering(int i, int j) { return (i * column_size + j); } A[row_major_ordering(1, 3)] = ‘h’; Row-Major Ordering (1 * 4 + 3) [1][3]
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSC2100A Spring 2006-2007 Hashing - overview a b c e f g i j k 012 0 1 2 Column Row a e i b f j c g k 0 12345678 d h l d h l 91 0 1 1 3 char *A = new char [12]; int column_major_ordering(int i, int j) { return (j * row_size + i); } A[column_major_ordering(2, 1)] = ‘h’; Column-Major Ordering (3 * 3 + 1) [1][3]
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/28/2010 for the course CSC CSC1110 taught by Professor Cjyuan during the Fall '06 term at CUHK.

Page1 / 27

Hash 1 - CSC2100A Tutorial Hashing (Part 1) Spring...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online