# on 24-Oct-2018 (Wed)

#### Flashcard 3497625521420

Question
In python/algorithms, what is the time complexity of insert(i,item) for lists (e.g. you have l = [1,2,3,4,5], what is big-O of doing: l.insert(1,7)?
O(n)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500726160652

Question
In python/algorithms, what is the time complexity of the in operation for lists (e.g. you have l = [1,2,3,4,5], what is big-O of doing: if 3 in l: ?
O(n)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500731403532

Question
In python/algorithms, what is the time complexity of the copy operation for dictionaries (e.g. you have d = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}, what is big-O of doing: d2 = d1.copy()?
O(n)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500736646412

Question
In python/algorithms, what is the time complexity of the get operation for dictionaries (e.g. you have d = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}, what is big-O of doing: d['b']?
O(1)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500740578572

Question
In python/algorithms, what is the time complexity of the set operation for dictionaries (e.g. you have d = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}, what is big-O of doing: d['b'] = 0?

set item
O(1)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500744510732

Question
In python/algorithms, what is the time complexity of the in operation for dictionaries (e.g. you have d = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}, what is big-O of doing: if 'e' in d: ?

contains (in)
O(1)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500748442892

Question
In python/algorithms, what is the time complexity of iterating over a dictionary (e.g. you have d = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}, what is big-O of doing: for key in d: ?
O(n)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500755520780

Question
In python, and in all languages, an array is a special type of list that is different from a normal list, how (think of Array in Java terms)?
With an array, all its elements are stored in one continuous block of memory!

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500759452940

Question
In python/algorithms, pointer structures are lists of items that can be [...] in memory (<--1 or 2 words in answer)
spread out / distributed / non-continuous

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500763385100

Question
In algorithms, very generally, a node contains two components: 1) a pointer to some data and; 2) [...]
pointer(s) to one or more other nodes.

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500766530828

Question
In algorithms, very generally, a node contains two components: 1) [...] and; 2) pointer(s) to one or more other nodes.
a pointer to some data

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500769676556

Question
In algorithms/data structures, specificallly in python, the last node(s) in a linked structure (e.g. link list, tree, etc) has its next pointer pointing to [...]
None

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500773870860

Question
For algorithms, in python, define a simple Node class to represent a simple node, which can hold some data and end up as part of a linked stucture (e.g. linked list)
class Node(object):
def __init__(self, data):
self.data = data
self.next = None

^^ note that we are initially setting the next pointer to None (self.next = None) as easy way to properly terminate the linked list that will be made using these Node objects

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500777803020

Question
For algorithms, in python, if you have a Node class, such as:

class Node(object):
def __init__(self, data):
self.data = data
self.next = None
Why is it still better to create a seperate SinglyLinkedList class, as below, rather than just constructing the link list directly from the objects of the Node class?

def __init__(self):
self.first = None
def append(self, data):
node = Node(data)
if self.first == None:
self.first = node
else:
current = self.first
while current.next:
current = current.next
current.next = node
To abstract away the internals of the Node class from the programmer/user (e.g. the programmer using the SinglyLinkedList class's append method, just adds items to the linked list without having to know about the details of the Node class and all the pointer, etc or even knowing that this is a linked list used to append/hold the items, aside from the name of the class)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500781735180

Question
In algorithms, for linked list traversel, you keep advancing the node.next pointer until you [...]
hit None (which signifies the end of the linked list)

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs

#### Flashcard 3500785667340

Question
In algorithms, in python, if we have a Node class and a LinkedList class that uses it (and abstracts Node's inner wroking/pointers), how do we iterate over the data of all the Nodes in the LinkedList class without taking away the abstraction of the inner working of Node?
via a generator function defined in LinkedList class.
here is example (this is not needed to pass this test :) :
class LinkedList(object):
...
def iter(self):
current = self.tail
while current:
val = current.data
current = current.next
yield val

status measured difficulty not learned 37% [default] 0

#### pdf

cannot see any pdfs