
![]() |
This lecture starts by showing how hashing can be used to achieve near constant time lookups and the concept of classes as understood by a computer. It then introduces exceptions. Image courtesy of donovanbeeson on Flickr. |
About this Video
Topics covered: Hashing, bucket, collision, linear rehash, exceptions, classes, modules, built-in classes.
Resources
What does hashing do?
› View/hide answer
It converts the object to be hashed into an int that lies within a pre-defined range.
What is a bucket?
› View/hide answer
A list of items that have the same hash value.
What are try blocks for?
› View/hide answer
Try blocks are used when a piece of code may not work in all cases or for all inputs. It consists of a try statement and an except statement. First the try statement is executed; if it throws an exception, the program uses the except statement instead of terminating the program.
What does polymorphic mean?
› View/hide answer
Works with a variety of different types.
What is a module?
› View/hide answer
A collection of related functions.
What is an object?
› View/hide answer
A collection of data and functions that operate on that data.
This assignment will deal with a well-known (though not very secure) encryption method called the Caesar cipher. In this problem set you will need to devise your own algorithms and will practice using recursion to solve a non-trivial problem.
Problem set 5 is assigned in this session. The instructions and solutions can be found on the session page where it is due, Lecture 12 Introduction to Simulation and Random Walks.
These optional resources are provided for students that wish to explore this topic more fully.
After watching the lecture, you may want to read some of the following resources: