Python Built-In Data Structures Flashcards
Python has 4 types of built-in data structures, they are?
lists,
tuples,
dictionaries,
sets.
Which two types of python data structures are mutatable?
lists and dictionaries.
What python data types are not mutable?
tuples and sets.
Python lists are created by?
[]
Python sets are created by?
{ }
Python dictionary are created by?
{ }
dict( )
Python tuples are created by?
( )
Cite the data structure?
a = [“apple”, “banana”, “cherry”]
print(a)
list
Cite the data structure?
a = (“apple”, “banana”, “cherry”)
tuple
Cite the data structure?
a = {“apple”, “banana”, “cherry”}
set
Cite the data structure?
a = {
“brand”: “Ford”,
“model”: “Mustang”,
“year”: 1964
}
dictionary
______ items are ordered, changeable, and allow duplicate values.
______ items are indexed, the first item has index [0], the second item has index [1] etc.
List
List
____ items are ordered, unchangeable, and allow duplicate values.
____ items are indexed, the first item has index [0], the second item has index [1] etc.
tuple
tuple
____ items are unordered, unchangeable, and do not allow duplicate values.
set
_____ items are unordered, changeable, and does not allow duplicates.
_____ items are presented in key:value pairs, and can be referred to by using the key name.
dictionary
Cite 6 user type data structures in python3
stacks,
queues,
trees,
linked lists,
graphs,
hashmaps.
Last in first out (LIFO) describe what user type data structure?
stacks
linear data-structure, reversing words, recursion programming, word editors,
First in first out (FIFO) describe what user type data structure?
queues
about: linear data structure, array structured, heads & tails, traffic congestion management, dequeue, enque to remove elements, job scheduling (ie print que)
A non linear data structure ecompassing a root and nodes is what type of user defined data structure?
trees
about: parent child relationships, last node are described as leaves, hierarchy structured (ie web pages), efficient at searching
A linear data structure that isn’t sorted and utilizes pointers describes what user defined data structure?
linked list
about: image viewing, pointers -> next, used in music player applications,
What user defined data structure encompasses pointers, vertices and edges
graphs
about: real world example of a map, used by Google map, used to determine quickest most efficient routes between nodes or points, used by Uber.
What user defined data structure can define a dictionary like structure much like a phone book?
hashmaps
about: identical as a dict object in python, used in applications like phone books,
populate data from a list,
_________ are rules or instructions that are formulated in a finite, sequential order to colve problems. They provide the ________ for problems.
algorithms
pseudocode
What are the 5 steps involved in writing algorithms?
- determine the exact problem
- define start
- define stop
- formulate intermediate steps
- review
Elements of a good algorithm are:
- finite, clear, and understandable.
- clear and precise description of input and outputs.
- each step must have a defines output that depends only on inouts in that step of the preceding steps.
- should be flexible.
- every step should make use of general programming fundamentals and be language agnostic.
Cite three algorithms classes?
divide & conquer
dynamic programming
greedy algorithms
“Divides the problem into sub parts and solves each on separately” describes which algorithm class?
divide & conquer
“Divides the problem into sub-parts, remembers the results and applies it to simliar ones” describes which algorithm class?
dynamic programming
“Involves taking the easiest step while solving a problem without worrying about the complexity of the future steps” describes which algorithm class?
greedy algorithm
Cite the 3 types of tree traversals?
In-order
pre-order
post-order
______ traversal refers to visiting the left nodes followed by the root and then right nodes.

in-order
______ traversal refers to visiting the root nodes followed by the left nodes and then right nodes.

pre-order
_______ traversal refers to visiting the left nodes followed by the right nodes and then root node.

post-order
Cite the five(5) sorting algorithms types?
- merge
- bubble
- insertion
- selection
- shell
What type of algorithm follows the divide & conquer rule and the given list is divided into smaller lists and compared to adjacent lists and then reorders in the desired sequence all using recursion?
merge sort