{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Hash 1

# Hash 1 - CSC2100A Tutorial Hashing(Part 1 Spring 2006/2007...

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

CSC2100A Spring 2006-2007 Spring 2006/2007 CSC2100A Tutorial Hashing (Part ) 1

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

View Full Document
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 *));
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);

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

View Full Document
CSC2100A Spring 2006-2007 Hashing - overview How to use a 1d array to implement a 2d array? 0 1 2 0 1 2 Column Row A[1][0] 0 1 2 3 4 5 6 7 8 9 10 11 3
CSC2100A Spring 2006-2007 Hashing - overview a b c e f g i j k 0 1 2 0 1 2 Column Row a b c d e f g h i 0 1 2 3 4 5 6 7 8 d h l j k l 9 10 11 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]

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

View Full Document
CSC2100A Spring 2006-2007 Hashing - overview a b c e f g i j k 0 1 2 0 1 2 Column Row a e i b f j c g k 0 1 2 3 4 5 6 7 8 d h l d h l 9 10 11 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]
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern