Join Simon Allardice for an in-depth discussion in this video Supporting hashing, part of Foundations of Programming: Data Structures.
- View Offline
…So you may be wondering, before I do any of this,…do I have go off and write lots of complicated hash functions?…Thankfully, no.…It's probably the case that most of your objects already have perfectly…acceptable hash functions for most of the things you want to do.…For example, every single class in Java already has a hashCode method.…It's part of the base object class, so any classes you define and all the…objects you create from those classes already have…a default hashCode behavior that returns an integer.…
And likewise, all Objective C objects have the hash method, it's part…of the NS Object base class, and all .NET objects have GetHashCode.…All Python objects have a hash method, all Ruby objects have a hash method.…Now usually, the default hash…functionality will return an integer that's…calculated from the ID or the underlying memory address of that object.…Meaning you should get a different hash value for every object you call this on.…And if you have two separate references pointing to the…same actual object, you should still get the same hash.…
Starting with simple ways of grouping data like arrays and structs, together you'll explore gradually more complex data structures, like dictionaries, sets, hash tables, queues and stacks, links and linked lists, and trees and graphs. Simon keeps the lessons grounded in the real world and answers the "why" behind many data-structuring decisions: Why use a hash table? Why is a set useful? Why avoid arrays? When you're finished with the course, you'll have a clear understanding of data structures and understand how to use them in whatever language you're programming in, today or 5 years from now.
- What is a data structure?
- Using C-style structs and arrays
- Sorting and searching arrays
- Working with singly and doubly linked lists
- Using stacks for last-in, first-out (LIFO) structures
- Using queues for first-in, first-out (FIFO) structures
- Working with hash tables
- Understanding binary search trees (BSTs)
- Learning about graphs