Name Every Data Structure (There are 8 Main Ones) - Answer- 1. Array
2. Stack
3. Queue
4. Linked Lists
5. Hash Table
6. BST
7. B-Tree, Red Black Trees
8. Heaps
Name Every Python Super Basic Datastructure - Answer- 1. List
2. Tuples
3. Sets
4. Strings
5. Arrays (you must use numpy)
Strings - Answer- 1. They are immutable
2. Access characters in strings like you do for arrays/lists
3. empty strings are false, non empty are true.
4. | and & don't work on strings
Slicing - Answer- string_name[beginning:end:step]
*end is not inclusive
*works for strings, lists, and tuples
Useful String Methods - Answer- 1. s[3]
2. s + t
3. len(s)
4. s in t
5. s.strip()
6. s.startswith(prefix)
7. s.endswith(suffix)
8. s.find(substring, beg, end) - returns the first position where substring is found.
9. s.rfind(substring, beg,end) - returns the position of the last occurrence of string
10. s.lower() - changes case
11. s.upper() - changes case
12. s.swapcase() - changes to other case
Python List - Answer- 1. not always homogenous
2. mutable
3. used to implement stacks and queues
Python List Methods - Answer- 1. append(x)
2. extend(x)
3. insert(i, x)
4. min(list)
5. max(list)
, 6. del a[i:j]
7. a.reverse()
8. a.sort()
9. B = copy.deepcopy(A)
10. b = copy.copy(A)
11. remove(index)
Tuples - Answer- 1. collection of python objects separated by commas
2. immutable
3. use () to create
Tuples Methods - Answer- 1. len(tuple_name)
2. tuple(list_name)
3. cmp() - returns 0 if matched. 1 when not matched and longer, -1 when not
matched and shorter
4. max() - returns max el
5. min() - returns min el
Python Sets - Answer- 1. unordered collection data type that is iterable, mutable, and
has no duplicate elements
2. based on datastructure known as hash table
3. highly optimized for checking contains
4. to create a set you need to use set(list)
*Only instances of immutable types can be added to python set
Methods - Answer- 1. add(x)
2. union(other)
3. intersect(other)
4. difference(other)
5. clear()
6. set(list) - create a set
Arrays - Answer- 1. There is no built in support.
2. Use numpy arrays
3. To create: np.array([][][]) where each list is its own row
Numpy Array Methods - Answer- ?
Python Dictionaries - Answer- 1. To construct: {key:value,key:value ...}
2. To add key,value pair: dic[new_key] = new_value
Dictionaries Methods - Answer- 1. str(dic) - string of key value pairs
2. items() - returns list of all dictionary keys
3. len() - number of key entries
4. clear()
5. fromkeys(seq, value) - declare new dic form sequence, initialize dic with values
Linked List - Answer- Similar to lists but use it when inserting and deleting a lot.
Linked List Implementation - Answer- class LinkedList():