5/5/2020lab_dict - CPSC221 2019W2: Data Structures1/8lab_dict Devious Dictionaries: Cleverness Through AssociationDue: Sunday, March 15 at 11:59 PMAssignment DescriptionThis lab is all about making you think with dictionaries. Dictionaries (aka mapsor associative arrays) are an abstract data type which stores pairs of dataand can support operations like insert, find, and remove. We generally call these (key, value)pairs. The idea is to associate a keywith a certain value.Hence, dictionaries are useful for when you want to quickly “lookup” a value associated with a certain key. The name dictionarycomes from the morefamiliar physical dictionary, where you lookup the definitions of words. If we were to model a physical dictionary with an ADT dictionary the keys wouldbe the words, and the values would be their definitions.Since dictionaries are abstract in nature, they have no prescription for what underlying structure should be used to implement them. Common choices aretree-based structures (e.g. balanced binary search trees, BTrees, &c.) or some sort of hash table. Different underlying implementations have differentperformance considerations, and which you use in the real world will depend on things like desired performance and what is readily available.For this lab, we’re not going to concern ourselves with the underlying implementation of dictionaries. Instead, we’ll be using dictionary types that havealready been defined for us. In C++ there are two “built-in” dictionary types: std::mapand std::unordered_map. Both exist in the wonderful land ofthe Standard Template Library (STL). The STL is a subset of the C++ Standard Library (the library a compiler must implement to be standard-compliant)which provides data containers. As the name implies, these containers are templated and thus can contain any type (which meets the restriction of thecontainer). You’ve probably experienced at least one of the STL types so far: std::vector, which is pretty much just a super fancy array. In general, theSTL types are very convenient as they provide a lot of functionality (e.g. sorting, automatic resizing) that you don’t have to bother implementing yourself.Dictionaries are amongst some of the most important abstract data types that are used in the real world. Therefore, this lab is perhaps one of the most usefullabs from a real world perspective. Mastering the concepts that you see in this lab will be a tremendous help for most technical interviews andprogramming problems in the future.
5/5/2020lab_dict - CPSC221 2019W2: Data Structures2/8C++11 Goodnessauto— easy typesMost of the code we present in this class uses old (C++03) style, but in this lab we encourage you to use some C++11 features to make your lifeeasier.