COMP 1005 Lecture Notes - Lecture 13: Substring, Binary Search Algorithm, Binary Search Tree
Document Summary
A dictionary is a collection of unordered key/value pairs. Dictionaries in python are enclosed in curly brackets. There are two ways to create an empty dictionary: How to create a dictionary with only one or more values: We can access/modify values in a dictionary by specifying the key in square brackets [ ]. The length of a dictionary is the current number of keys in it. The in operator lets us check if a key is in a dictionary. Note: this way of iterating over a dictionary is not efficient. Since the dictionary is unordered, repeating this loop after modifying the dictionary may result in a completely new order. Note: this way of iterating over a dictionary is efficient. A binary search tree is a node-based binary tree data structure which has the following properties: The left subtree of a node only contains nodes with keys lesser than the node"s key.