Exam 1 Flashcards

(524 cards)

1
Q

Reversed Card

A formula in which some number in a sequence depends on the previous numbers in a sequence.

A

What is a recurrence relation?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does a skip list search work?

A

A search proceeds along the list with the greatest span until two references are found that enclose the required key. Then the search proceeds at the next level down until the required key found, or is deemed to be not present.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Reversed Card

LIFO

A

Stacks are sometimes known as ______ lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the findMin algorithm?

A
  • FindMin(BinaryNode t)
    • if(t==null) return null;
    • if(t.left==null) return t;
    • return findMin(t.left);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Preorder traversal algorithm?

A
  • DFSPre(Node X)
    • If(X!=null)
      • Do Work at Node
      • DFSPre(x.left)
      • DFSPre(x.right)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Reversed Card

it allows GenericClass m = new GenericClass(); to be written simply as GenericClass m = new GenericClass<>();

A

What does the diamond operator do?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What four methods make up the simplest linked list interface?

A

Addathead
RemoveAtHead
Clear
isEmpty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How much space does merge sort require?

A

2n

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Reversed Card

One takes only an object as an argument
One takes an object and a nextNode as arguments

A

When making a linked list, we use two constructors, what are their differences?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What a wrapper class?

A

A data type that stores a primitive type and adds extra functionality and methods to be used on the primitive type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the PostOrder traversal algorithm?

A
  • DFSPost
    • If(X!=null)
      • DFSPost(x.left)
      • DFSPost(x.right)
      • Do work
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Reversed Card

Finding the insertion point.

A

What is the first step to doing an insertion or deletion in a probabilistic skip list?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Classes that extend the iterable interface can implement what?

A

The enhanced for loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Reversed Card

  • Guess the result and prove it by induction.
  • Expand the recurrence by repeatedly substituting it into itself.
  • The general solution method.
A

What are the three main ways to solve recurrence relations?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Reversed Card

An amortized runtime means that the runtime could be as large as O(n), but if m consecutive calls are made to the member functions, the runtime is MO(logN).

A

What is amortized runtime?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Reversed Card

It enables additions and deletions at either end of the list.

A

How is a deque different?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is the linear time algorithm for the positive max subsequence problem?

A

Public static int maxsubsum(int[] a)

Int max sum = 0, this sum =0;

For (int I =0, I < a.length, i++)

Thissum += a[i];

If(thissum > maxsum ) maxsum = thissum;

Else if (thissum < 0) thissum = 0;

Return maxsum;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What are the two modes of insert in a red-black tree?

A

Top down insert and bottom up insert

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Reversed Card

Reading the data (from disk)

A

When using an efficient algorithm, what is generally the bottleneck?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Reversed Card

A perfect binary tree of all black nodes.

A

What is embedded in every Red-Black tree?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is a doubly linked list?

A

A list in which every node maintains a link to its previous and next node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is the suggested probabilistic variable value for a probabilistic skip list?

A

.25

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Reversed Card

2n+2

A

What is the T(n) of a for loop from 1-n?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
# Reversed Card When the work at a ndoe is performed before its children are processed.
What is preorder traversal?
26
What is autoboxing/ unboxing?
Compiler features that allow primitive types to be passed as wrapper classes and vice versa.
27
What is a full binary tree?
A tree in which every node, other than the leaves, has two children.
28
# Reversed Card sqrt(N)
What is the average depth of a binary tree?
29
# Reversed Card return root == null;
What is the IsEmpty algorithm?
30
# Reversed Card one in which the numbers are in the sequence are a product of the previous number and some k.
What is a geometric recurrence?
31
# Reversed Card A tree with the lowest amount of nodes needed to obtain a tree of height h.
What is a skinny AVL tree?
32
What does returning a value count as for time complexity?
One unit to return.
33
When we are speaking of trees, N always represents what?
34
How are nested loops analyzed?
inside out; the total running time of a statement inside a group of nested loops is the running time of the statement multiplied by the product of the sizes of all the loops.
35
What is the wild card operator?
?
36
What is the recursive maxim?
"Don’t compute anything more than once."
37
# Reversed Card An in order traversal is used
What kind of traversal is used to evaluate an expression tree?
38
# Reversed Card Path length = 0.
What is the path length from every node to itself?
39
What is the first and most crucial thing we do when creating Binary search tree functions?
Test for an empty tree first.
40
# Reversed Card depth = 0.
What is the depth of the root?
41
42
What are the four fundamental rules of recursion?
1. You must have some base case that can be solved without recursion. 2. The recursive call must always be with a case that makes some progress toward the base case. 3. Assume that all recursive calls work. 4. Never duplicate work by solving the same instance of a problem in a recursive call.
43
# Reversed Card ?
What is the wild card operator?
44
What kind of list is required for a sufficient implementation of a deque?
A doubly linked list.
45
# Reversed Card * Contains(x, BinaryNode t) * if(t == null) return false; * if(x.compareTo(t.Object) \< 0) return contains(x, t.left); * if(x.compareTo(t.Object) \> 0) return containts(x, t.right); * else return true;
What is the contains algorithm?
46
# Reversed Card A tail node, insert at tail, remove at head
What extra variable and operations are used in a queue?
47
Stacks are sometimes known as ______ lists.
LIFO
48
Every red black tree with N nodes has a height less than or equal to what?
2log2(n+1)
49
# Reversed Card They are not necessarily adjacent.
What can be said about the nodes of a linked list's position in memory?
50
# Reversed Card Log A + Log B
Log(A\*B) = ?
51
What is the T(n) of a for loop from 1-n?
2n+2
52
# Reversed Card the current partition to be sorted drops below 25 (approximately).
The most efficient implementations of QuickSort revert to Insertion Sort when
53
# Reversed Card O(log N) this is worst
What is the worst case tree height of an AVL tree?
54
55
# Reversed Card this is the case that two Insertion took place in the right subtree of the right child.
Let x be the out of balance node, and k be the key that was inserted what is the case that x.rightChild.value \< k ?
56
# Reversed Card 1 unit to initialize i, n+1 units for comparisons, and n units for all increments.
What is a for loops cost?
57
What is the runtime of all operations in an AVL tree when lazy deletion has not occured?
O(log N)
58
# Reversed Card get, set, add, remove, isempty, clear, size, and capacity increase.
What are the ArrayList's 8 basic operations?
59
What is the Euclid algorithm?
Long(long m, long n) while(n!=0) long rem = m % n; m = n; n = rem; return m;
60
What is the time complexity of Euclids algorithm?
O(logn), solved by noticing that after two iterations the remainder is less than n/2.
61
What are the four fundamental properties of Red-Black Trees?
* Every node is either red or black. * The root of the tree is black. * A red node must have no children or exactly two black children. * Every path from a node x to a descendent null-link must have the same number of black nodes.
62
# Reversed Card Get and Set take constant time.
What is the advantage of the built in ArrayList?
63
What is the advantage of the built in ArrayList?
Get and Set take constant time.
64
The minimum number of nodes in an AVL tree of height h is given by what recurrence relation?
S(h) = S(h-1) + S(h-2) + 1
65
# Reversed Card Recursion.
What is commonly used when writing the operations of a Binary search tree?
66
Let x be the out of balance node, and k be the key that was inserted what is the case that x.leftchild \< k \< x.value?
this is the case that insertion took place in the right subtree of x's left child.
67
# Reversed Card Primitive types, Wrapper classes must be used.
What type of objects cannot be used in place of generic type parameters?
68
What part of the java library includes an implementation of common data structures?
The java collections API
69
What are skip lists made of?
Ordered Linked Lists
70
# Reversed Card inside out; the total running time of a statement inside a group of nested loops is the running time of the statement multiplied by the product of the sizes of all the loops.
How are nested loops analyzed?
71
If an outer class is called outer, what is the implicit reference to the outer class object that created the inner class called?
outer.this
72
What is the average depth of a binary tree?
sqrt(N)
73
# Reversed Card When the work at a node is done after its children have been evaluated.
What is postorder traversal?
74
What are the two steps for proving something by induction?
The first step is proving a base case, that is, showing the theorem is true for some small value. It is shown that if k is true, the theorem must also be true for k+1.
75
What is the time unit of a simple operation or assignment?
One time unit.
76
What is the length of a path?
The number of edges on the path, namely k-1 if k are the nodes of the path.
77
# Reversed Card The unbalanced node's child is swapped with the unbalanced node's grandchild.
What happens first in a double rotation?
78
Describe the "model" computer that is used for time complexity analysis
* simple instructions: addition, multiplication, comparison, and assignment * takes exactly one time unit to do any simple instruction. * has infinite memory
79
What is a recurrence relation?
A formula in which some number in a sequence depends on the previous numbers in a sequence.
80
What is the algorithm for fast exponentiation?
Long power(long a, int b) if(b == 0) return 1; if(b == 1) return a; if(b%2 == 0) return power(a\*a, b/2); else return power(a\*a, b/2)\*a;
81
# Reversed Card if(head is null) head = new Node(x, head) else: if(head\>x) head = new Node(x, head) else: Node prev = head; Node ref = head.next; while(ref!=null && ref.val \> x) move prev and ref up prev.setNext(new Node(x, ref));
What is the insertInorder Algorithm?
82
# Reversed Card Nested inside of the Binary tree class.
Where is the binary node class usually located?
83
84
# Reversed Card The worst case time complexity.
What is generally the quantity searched for when analyzing an algorithms runtime?
85
If an array is ever used to implement a list, what must we keep track of?
The front and end indices, and the size.
86
# Reversed Card A height variable.
What extra information do AVLNodes have that BSTNodes do not?
87
What is amortized runtime?
An amortized runtime means that the runtime could be as large as O(n), but if m consecutive calls are made to the member functions, the runtime is MO(logN).
88
What is the path from nodes N1 to Nk?
A sequence of nodes such that leads from n1 to nk
89
# Reversed Card B\*Log(A)
Log(AB) = ?*
90
91
What are the add and remove operations called in a queue?
Enqueue, dequeue
92
What two implementations are there of the built in List interface?
ArrayList, and LinkedList
93
# Reversed Card A list in which 50% of nodes have just one reference, 25% have just two, etcetera.
What is a probabilistic skip list?
94
Xn + Xn = ?
2Xn
95
96
What is a probabilistic skip list?
A list in which 50% of nodes have just one reference, 25% have just two, etcetera.
97
# Reversed Card An arbitrary number, possibly zero.
A tree that is not binary may have how many children?
98
What is a perfect binary tree?
A full binary tree in which all the leaves are at the same depth or level.
99
# Reversed Card the running time of the test plus the larger of the running times of either statement.
What is the runtime of an if/else statment?
100
What is Euclid's algorithm used for?
Finding the GCD of two numbers.
101
What are the AVL tree properties?
* Abides by the Binary search tree property. * The heights of the left and right subtrees of any node differ by no more than 1.
102
# Reversed Card rotate with left child
What function is called when Insertion took place in the left subtree of the left child of X(out-of-balance node).
103
# Reversed Card The type of object that will replace the parameter type.
When instantiating a class, what goes inside of the angle brackets?
104
# Reversed Card When the division into regions of size equal to powers of two is maintained.
When can insertion and deletion in a skip list take O(N)?
105
A rotate with left child causes the Node X to replace it's left child with what?
The left child's right subtree.
106
# Reversed Card A list in which insertion is done at one end and removal is done at the other end.
What is a queue?
107
What is the runtime of an if/else statment?
the running time of the test plus the larger of the running times of either statement.
108
What extra information do AVLNodes have that BSTNodes do not?
A height variable.
109
# Reversed Card For every node X in the tree, the values of all the items in its left subtree are smaller than teh item in X, and values of all the items in its right subtree are larger than the item in X.
What is the Binary search tree property?
110
# Reversed Card The length of the longest path from the root to a leaf.
What is the height of a tree?
111
# Reversed Card If Logx B = a
Xa = B if and only if what?
112
# Reversed Card The information saved on a stack when a method is called and the registers must be cleared.
What is a stack frame, or activation record?
113
When using an efficient algorithm, what is generally the bottleneck?
Reading the data (from disk)
114
# Reversed Card A postorder traversal.
What kind of traversal is used to convert an expression tree into a postfix expression?
115
Collections add or remove return what?
True or false.
116
# Reversed Card O(logn), which is given by the number of multiplications computed.
What is the runtime of fast exponentiation?
117
# Reversed Card An object, NOT a node.
What does the remove from head function return?
118
What is a full binary tree sometimes called?
A proper tree, or a 2 tree.
119
# Reversed Card A perfect Binary tree.
A Red-Black tree where all nodes are black is what?
120
# Reversed Card The front and end indices, and the size.
If an array is ever used to implement a list, what must we keep track of?
121
What is the new size of an ArrayList after capacity expansion?
2(size) + 1
122
# Reversed Card log\_(1/p)(n) where p is the probability fraction one has chosen.
How is the maximum level a probabilistic skip list chosen?
123
How does merge sort work?
sorts an array by partitioning the array into blocks of size one, then pairs of these are merged into blocks of size 2 values, then pairs of those blocks are merged into size four. This behavior continues until the entire array is enclosed in a single block.
124
How can we determine the relative growth of two functions f(n) and g(n)?
125
In a tree, the root of each subtree is said to be what?
A child of the whole tree's root.
126
What are not compatible with the Object data type?
Primitive types are not compatible.
127
How many rotations maybe required to restore the balance condition of an AVL tree?
Only one rotation is ever needed.
128
What is the runtime of adding an removing from a linked list?
O(1), it is constant.
129
130
# Reversed Card references to the nodes with the smallest and larges elemetns in a tree or subtree.
What do findMin and FindMax return?
131
# Reversed Card The height of the left and rigth subtrees of any node can differ by no more than 1.
What is the AVL tree balance condition?
132
What is an Abstract Data Type?
a set of objects together with a set of operations.
133
A binary tree consists of what?
A root and two subtrees, both of which could be empty.
134
135
# Reversed Card By downcasting the object to the proper type.
How can a generic object of Object type be accessed and used properly?
136
What do findMin and FindMax return?
references to the nodes with the smallest and larges elemetns in a tree or subtree.
137
The GCD of three or more positive numbers is equal to what?
the product of the prime factors common to all of the integers.
138
# Reversed Card The directory structure is a popular application.
What is a popular application of trees in operating systems?
139
# Reversed Card To the base case.
All recursive functions must eventually reduce to what?
140
# Reversed Card A double rotation.
What restores the balance from an inside insertion?
141
What is the least common multiple algorithm?
* Break each number down into its prime numbers. * Multiply together each factor the greatest number of times it occurs in any of the numbers. * The product is the LCM.
142
What is generally considered an error in the stack adt?
A pop or peek on an empty list.
143
What is a type bounds?
it specifies the properties that the parameter types must have and goes inside of the angle brackets after the type parameter.
144
# Reversed Card The node is a unary operator, such as a unary minus (negative)
What does it mean if a node has only one child in an expression tree?
145
146
# Reversed Card A doubly Linked List.
What kind of implementation is the built in Linked List?
147
the running time of all operations in a binary search tree is what?
O(d) where d is the depth of the node containing the accessed item.
148
# Reversed Card * BinaryNode Insert(x, BinaryNode t) * if(t==null) return new BinaryNode(x, null, null); * int compare = x.compareTo(t.element); * if(compare \< 0) t.left = insert(x, t.left) * else if(compare \> 0 ) t.right = insert(x, t.right); * else do nothing; * return t;
What is the binary tree insertion algorithm?
149
# Reversed Card 2(size) + 1
What is the new size of an ArrayList after capacity expansion?
150
151
What is the double rotate with left child algorithm?
* DoubleRotateWLeft(Node x) * x.left = rotateWRight(x.left); * Return rotateWithLeftChild(x);
152
# Reversed Card "Don’t compute anything more than once."
What is the recursive maxim?
153
How is the maximum level a probabilistic skip list chosen?
log\_(1/p)(n) where p is the probability fraction one has chosen.
154
# Reversed Card A collection of nodes that is either empty or consists of a distinguished root node and zero or more subtrees each of whose roots are connected by a directed edge from r.
What is a tree?
155
# Reversed Card * DoubleRotateWLeft(Node x) * x.left = rotateWRight(x.left); * Return rotateWithLeftChild(x);
What is the double rotate with left child algorithm?
156
What is the height of an empty AVL tree defined as?
height = -1
157
# Reversed Card * FindMin(BinaryNode t) * if(t==null) return null; * if(t.left==null) return t; * return findMin(t.left);
What is the findMin algorithm?
158
A rotate with right child causes the Node X to become what
It's right child's left subtree.
159
What is the diamond operator?
\<\>
160
# Reversed Card When n \< 25.
When is insertion sort generally faster?
161
# Reversed Card outer.this
If an outer class is called outer, what is the implicit reference to the outer class object that created the inner class called?
162
# Reversed Card 2n
How much space does merge sort require?
163
# Reversed Card Top down insert and bottom up insert
What are the two modes of insert in a red-black tree?
164
What is an AVL tree?
A balanced search tree where the heights of the left and right subtrees of any node differ by no more than 1.
165
What should the last node in a linked list always point to?
null.
166
# Reversed Card Any node other than a null link.
In a Red-Black tree, an internal node is considered to be what?
167
# Reversed Card O(N)
What is the runtime of operations that must search linked lists?
168
# Reversed Card It goes in angle brackets after the class name.
When creating a generic class, where does a generic type parameter go?
169
How is a proof by contradiction done?
A statement is assumed false, it is then shown that this assumption implies that some known property is false.
170
# Reversed Card sorts an array by partitioning the array into blocks of size one, then pairs of these are merged into blocks of size 2 values, then pairs of those blocks are merged into size four. This behavior continues until the entire array is enclosed in a single block.
How does merge sort work?
171
We say that A is congruent to B modulo N, if
N divides A - B, this intuitively means that the remainder is the same when N divides either A or B.
172
All insertions in a red black tree create a new what?
A new red node with null links.
173
In a Red-Black tree, an internal node is considered to be what?
Any node other than a null link.
174
How do we prove the property of the worst case height of an AVL tree to be O(log N)?
We construct the AVL tree of height h that contains the fewest nodes, we call these the skinniest AVL trees. We deduce a recurrence relation for the minimum number of nodes in an AVL tree of height h. We solve this recurrence relation and then rearrange the result to get an equation for the maximum height of an AVL tree with N nodes.
175
# Reversed Card Nodes without children.
What are leaf nodes?
176
# Reversed Card An if/else statement in the else of an outer if/else statement.
What is the structure of the InsertInOrder algorithm for a linked list?
177
What restores the balance from an inside insertion?
A double rotation.
178
# Reversed Card a reference that is assigned to the left or right child of the current node. i.e. t.right = insert(x, t.right);
Each recursive call to insert returns what?
179
Each recursive call to insert returns what?
a reference that is assigned to the left or right child of the current node. i.e. t.right = insert(x, t.right);
180
# Reversed Card The left child's right subtree.
A rotate with left child causes the Node X to replace it's left child with what?
181
Xa = B if and only if what?
If Logx B = a
182
If a tree has N nodes, how many edges does it have?
N-1
183
What does the delete function do if a value is not found?
It does nothing.
184
# Reversed Card The first step is proving a base case, that is, showing the theorem is true for some small value. It is shown that if k is true, the theorem must also be true for k+1.
What are the two steps for proving something by induction?
185
186
# Reversed Card * Break each number down into its prime numbers. * Multiply together each factor the greatest number of times it occurs in any of the numbers. * The product is the LCM.
What is the least common multiple algorithm?
187
# Reversed Card printList, makeEmpty
What are some popular but not required linked list operations?
188
# Reversed Card Anywhere in the class where the type of an object can be anything.
Where is the parameter type used in a class definition?
189
What does it mean if a node has only one child in an expression tree?
The node is a unary operator, such as a unary minus (negative)
190
# Reversed Card LinkedList Node
What are the minimal two classes needed to implement a linked list?
191
# Reversed Card The parent node sets its child node to its grandchild.
How is a node with one child deleted?
192
# Reversed Card MO(logN)
What is the runtime of find, insert, and delete in a skip list?
193
# Reversed Card An insertion took place in the right subtree of teh rigth child, or the left subtree of the left child.
What is meant by an outside insertion?
194
What are the two most commonly used methods for proving statements in data structure analysis?
Proof by induction, and proof by contradiction.
195
Why must we use the static keyword when nesting a class inside of a class?
To allow the nested class to use the members of the outer class.
196
What are the two special cases dealt with first in most list operations?
Head is Node, List is Empty.
197
# Reversed Card 2n+1
2n ![]() + 2n = ?
198
# Reversed Card this is the case that insertion took place in the left subtree of the right child.
Let x be the out of balance node, and k be the key that was inserted what is the case that x.value \< k \< x.rightChild.value?
199
# Reversed Card 1. You must have some base case that can be solved without recursion. 2. The recursive call must always be with a case that makes some progress toward the base case. 3. Assume that all recursive calls work. 4. Never duplicate work by solving the same instance of a problem in a recursive call.
What are the four fundamental rules of recursion?
200
When is using an inner class useful?
when each inner class object is associated with exactly one instance of an outer class object.
201
What can be said about the nodes of a linked list's position in memory?
They are not necessarily adjacent.
202
What is the essential class variable of the Linked List class?
the head node
203
# Reversed Card Enqueue, dequeue
What are the add and remove operations called in a queue?
204
# Reversed Card Linked lists are used to implement these data structures.
What data structure is used to implement stacks, queues and deques?
205
What is the Binary search tree property?
For every node X in the tree, the values of all the items in its left subtree are smaller than teh item in X, and values of all the items in its right subtree are larger than the item in X.
206
Why does deletion cause the average runtime of O(log N) to not always hold?
Because deltion will always faovr making one sides subtree shorter, therefore making all insertion sequences no longer equally likely.
207
# Reversed Card A binary search tree with a balance condition.
What is an AVL Tree?
208
# Reversed Card The number of edges on the path, namely k-1 if k are the nodes of the path.
What is the length of a path?
209
How is a deque different?
It enables additions and deletions at either end of the list.
210
# Reversed Card A recursive call at the last line of a method, and an example of bad recursion.
What is tail recursion?
211
# Reversed Card the product of the prime factors common to all of the integers.
The GCD of three or more positive numbers is equal to what?
212
How is a generic array created?
(Anytype []) new Object[];
213
What is the structure of the InsertInOrder algorithm for a linked list?
An if/else statement in the else of an outer if/else statement.
214
When making a linked list, we use two constructors, what are their differences?
One takes only an object as an argument One takes an object and a nextNode as arguments
215
When implementing recursion, what ADT is usually used?
A stack
216
What is the runtime of operations that must search linked lists?
O(N)
217
218
What is generally the quantity searched for when analyzing an algorithms runtime?
The worst case time complexity.
219
220
What is a for loops cost?
1 unit to initialize i, n+1 units for comparisons, and n units for all increments.
221
# Reversed Card Object element Node next
What two data members make up a linked list node?
222
How can Euclids algorithm be used for finding the GCD of 3 or more positive numbers?
by repeatedly taking the GCDs of pairs of numbers: gcd(gcd(a, b), c)
223
# Reversed Card \<\>
What is the diamond operator?
224
# Reversed Card an algorithm that can correctly give an answer for the data it has read at any given time.
What is an online algorithm?
225
# Reversed Card A sequence of nodes such that leads from n1 to nk
What is the path from nodes N1 to Nk?
226
# Reversed Card O(nlogn).
What is the average case time complexity of quicksort?
227
# Reversed Card A function that is defined in terms of itself.
Waht is a recursive function?
228
What does a collection do?
stores identically typed objects
229
What can a red node never have?
A red node can never have a red child, or just one child.
230
What are the three cases which the delete algorithm must address?
1. Deleting a leaf Node. 2. Deleting a node with one child. 3. Deleting a node with two children.
231
# Reversed Card Finding the GCD of two numbers.
What is Euclid's algorithm used for?
232
What is a tree?
A collection of nodes that is either empty or consists of a distinguished root node and zero or more subtrees each of whose roots are connected by a directed edge from r.
233
Waht is a recursive function?
A function that is defined in terms of itself.
234
# Reversed Card It's right child's left subtree.
A rotate with right child causes the Node X to become what
235
# Reversed Card O(log N)
What is the average depth of a binary search tree?
236
# Reversed Card Test for an empty tree first.
What is the first and most crucial thing we do when creating Binary search tree functions?
237
238
What does the remove from head function return?
An object, NOT a node.
239
# Reversed Card The sum of the depths of all nodes in a tree.
What is the intenal path length?
240
What is the InOrder Traversal Algorithm?
* DFSIn(Node X) * If(X!=null) * DFSIn(x.left); * Do work * DFSIn(x.right);
241
# Reversed Card Proof by induction, and proof by contradiction.
What are the two most commonly used methods for proving statements in data structure analysis?
242
What is the insertInorder Algorithm?
if(head is null) head = new Node(x, head) else: if(head\>x) head = new Node(x, head) else: Node prev = head; Node ref = head.next; while(ref!=null && ref.val \> x) move prev and ref up prev.setNext(new Node(x, ref));
243
What is the divide and conquer strategy?
split the problem into two roughly equal subproblems, which are then solved recursively and then patched together.
244
What is lazy deletion?
When nodes have a deleted marker that is turned on when they are deleted.
245
A rotate with left child causes the Node X to become what?
It's left child's right subtree.
246
What is a skinny AVL tree?
A tree with the lowest amount of nodes needed to obtain a tree of height h.
247
# Reversed Card Keep a record of frequency in each node and update it when a duplicate is added or removed.
What is one way to handle a tree that will have duplicates inserted?
248
What is the runtime of find, insert, and delete in a skip list?
MO(logN)
249
# Reversed Card The java collections API
What part of the java library includes an implementation of common data structures?
250
# Reversed Card N-1
At worst case, a binary tree can have a depth of what?
251
# Reversed Card O(d) where d is the depth of the node containing the accessed item.
the running time of all operations in a binary search tree is what?
252
# Reversed Card O(log N)
What is the runtime of all operations in an AVL tree when lazy deletion has not occured?
253
What is the path length from every node to itself?
Path length = 0.
254
# Reversed Card rotate with right
What function is called when Insertion took place in the right subtree of the right child?
255
# Reversed Card Object, left child, right child.
What are the variables of a BinaryNode?
256
# Reversed Card A tree in which no node can have more than two children.
What is a binary tree?
257
What does the structural condition of balance mean?
That no node is allowed to get too deep.
258
LogA B = ?
(Logc B) --------------- (Logc A)
259
# Reversed Card A data type that stores a primitive type and adds extra functionality and methods to be used on the primitive type.
What a wrapper class?
260
# Reversed Card a set of objects together with a set of operations.
What is an Abstract Data Type?
261
262
What is the intenal path length?
The sum of the depths of all nodes in a tree.
263
# Reversed Card An edge from one directory node to the other.
In a path name, each slash indicates what?
264
What are the ArrayList's 8 basic operations?
get, set, add, remove, isempty, clear, size, and capacity increase.
265
266
# Reversed Card * Abides by the Binary search tree property. * The heights of the left and right subtrees of any node differ by no more than 1.
What are the AVL tree properties?
267
What time unit do declartions count for?
They count for no time unit.
268
# Reversed Card AddAtHead RemoveAtHead
These two linked list operations are identical to a stack push and pop...
269
What is the rotateWithLeftChild() algorithm?
RotateWithLeft(Node n) * Node leftPoint = n.left; * n.left = leftPoint.right; * leftPoint.right = n; * n.height = Math.max(height(n.left), height(n.right)) + 1; * leftPoint.height = Math.max(height(leftpoint.left), height(leftPoint.right)) + 1; * Return leftPoint;
270
# Reversed Card An underlying array, the array capacity, and the current number of items in the array.
The ArrayList class contains what data variables?
271
# Reversed Card One unit to return.
What does returning a value count as for time complexity?
272
# Reversed Card Selection sort, bubble sort, insertion sort.
What are three examples of simple sorting algorithms?
273
# Reversed Card An extra operation for a stack that returns a value without popping the node at the head of the list.
What is the peek routine?
274
# Reversed Card split the problem into two roughly equal subproblems, which are then solved recursively and then patched together.
What is the divide and conquer strategy?
275
# Reversed Card the head node
What is the essential class variable of the Linked List class?
276
Let x be the out of balance node, and k be the key that was inserted what is the case that x.rightChild.value \< k ?
this is the case that two Insertion took place in the right subtree of the right child.
277
When is an algorithm O(logn)?
when it takes constant time to cut the problem size by a fraction, usually 1/2.
278
What is an AVL Tree?
A binary search tree with a balance condition.
279
What fixes the balance after an outside insertion?
A single rotation
280
What happens first in a double rotation?
The unbalanced node's child is swapped with the unbalanced node's grandchild.
281
# Reversed Card When insertions and deletions occur throughout the list.
When is an array not a good option for a list?
282
# Reversed Card Base 2
In computer science, all logarithms are to what base?
283
What is commonly used when writing the operations of a Binary search tree?
Recursion.
284
# Reversed Card * simple instructions: addition, multiplication, comparison, and assignment * takes exactly one time unit to do any simple instruction. * has infinite memory
Describe the "model" computer that is used for time complexity analysis
285
# Reversed Card That no node is allowed to get too deep.
What does the structural condition of balance mean?
286
How can we determine the relative growth of two functions f(n) and g(n)?
287
# Reversed Card 1. Scan the infix expression from left to right. 2. If the scanned character is an operand, output it. 3. Else, 1 If the precedence of the scanned operator is greater than the precedence of the operator in the stack(or the stack is empty or the stack contains a ‘(‘ ), push it. 2 Else, Pop all the operators from the stack which are greater than or equal to in precedence than that of the scanned operator. After doing that Push the scanned operator to the stack. (If you encounter parenthesis while popping then stop there and push the scanned operator in the stack.) 4. If the scanned character is an ‘(‘, push it to the stack. 5. If the scanned character is an ‘)’, pop the stack and output it until a ‘(‘ is encountered, and discard both the parenthesis. 6. Repeat steps 2-6 until infix expression is scanned. 7. Print the output 8. Pop and output from the stack until it is not empty.
What is the algorithm for converting an infix expression to postfix?
288
What is embedded in every Red-Black tree?
A perfect binary tree of all black nodes.
289
What are the three main ways to solve recurrence relations?
* Guess the result and prove it by induction. * Expand the recurrence by repeatedly substituting it into itself. * The general solution method.
290
# Reversed Card the running time of the statements inside the for loop multiplied by the number of iterations.
The running time of a for loop is at most what?
291
What is the base case of a recursive function?
It is the value for which the function is known without having to resort to recursion.
292
# Reversed Card A statement is assumed false, it is then shown that this assumption implies that some known property is false.
How is a proof by contradiction done?
293
What is the AVL tree balance condition?
The height of the left and rigth subtrees of any node can differ by no more than 1.
294
# Reversed Card Add and remove at head take constant time.
What is the advantage of a LinkedList over an ArrayList?
295
# Reversed Card Only one rotation is ever needed.
How many rotations maybe required to restore the balance condition of an AVL tree?
296
What kind of implementation is the built in Linked List?
A doubly Linked List.
297
298
What are the only two operations besides, peek, makeEmpty, and isEmpty, that you can do to a stack?
Pop, Push
299
# Reversed Card A single rotation
What fixes the balance after an outside insertion?
300
# Reversed Card True or false.
Collections add or remove return what?
301
# Reversed Card Pop, Push
What are the only two operations besides, peek, makeEmpty, and isEmpty, that you can do to a stack?
302
# Reversed Card N-1
If a tree has N nodes, how many edges does it have?
303
# Reversed Card A balanced search tree where the heights of the left and right subtrees of any node differ by no more than 1.
What is an AVL tree?
304
# Reversed Card the right childs left subtree.
A rotate with right child causes the Node X to replace it's right child with what?
305
The most efficient implementations of QuickSort revert to Insertion Sort when
the current partition to be sorted drops below 25 (approximately).
306
When is an array not a good option for a list?
When insertions and deletions occur throughout the list.
307
What are leaf nodes?
Nodes without children.
308
How is a leaf node deleted?
The parent node's child node is set to null.
309
# Reversed Card it divides at least one of the two numbers.
If a prime number N divides a product of two numbers, then
310
What is the height of a tree?
The length of the longest path from the root to a leaf.
311
Let x be the out of balance node, and k be the key that was inserted what is the case that K \< x.leftChild.Value?
this is the case that insertion took place in the left subtree of x's left child.
312
# Reversed Card RotateWithLeft(Node n) * Node leftPoint = n.left; * n.left = leftPoint.right; * leftPoint.right = n; * n.height = Math.max(height(n.left), height(n.right)) + 1; * leftPoint.height = Math.max(height(leftpoint.left), height(leftPoint.right)) + 1; * Return leftPoint;
What is the rotateWithLeftChild() algorithm?
313
# Reversed Card To pass functions as parameters.
What are function objects used for?
314
What is the average running time of most operations in a binary search tree?
O(logN)
315
# Reversed Card A child of the whole tree's root.
In a tree, the root of each subtree is said to be what?
316
What does the contains function do?
It returns true if a node in tree T has item x, or false if not.
317
# Reversed Card The parent node's child node is set to null.
How is a leaf node deleted?
318
When creating a generic class, where does a generic type parameter go?
It goes in angle brackets after the class name.
319
Trees are actually what?
Graphs
320
Log(AB) = ?*
B\*Log(A)
321
What is an expression tree?
A tree in which the leaves are operands, such as constants or variable names, and the internal nodes contain operators.
322
What is the average case time complexity of quicksort?
O(nlogn).
323
# Reversed Card It becomes its right child's left child.
When an outer insertion occurs to the right, what does the imbalanced node become?
324
What does the diamond operator do?
it allows GenericClass m = new GenericClass(); to be written simply as GenericClass m = new GenericClass\<\>();
325
# Reversed Card Primitive types are not compatible.
What are not compatible with the Object data type?
326
# Reversed Card When using a generic Collections, a wild card goes inside of the angle brackets after Collection along with the extends keyword to allow a class and any of its subclasses to be used in the collection.
When and for what are wildcards used?
327
# Reversed Card height = -1
What is the height of an empty AVL tree defined as?
328
What is the peek routine?
An extra operation for a stack that returns a value without popping the node at the head of the list.
329
Where is the binary node class usually located?
Nested inside of the Binary tree node.
330
What does an AVL tree ensure?
It ensures that the depth of a tree is O(log N)
331
What is the algorithm for converting an infix expression to postfix?
1. Scan the infix expression from left to right. 2. If the scanned character is an operand, output it. 3. Else, 1 If the precedence of the scanned operator is greater than the precedence of the operator in the stack(or the stack is empty or the stack contains a ‘(‘ ), push it. 2 Else, Pop all the operators from the stack which are greater than or equal to in precedence than that of the scanned operator. After doing that Push the scanned operator to the stack. (If you encounter parenthesis while popping then stop there and push the scanned operator in the stack.) 4. If the scanned character is an ‘(‘, push it to the stack. 5. If the scanned character is an ‘)’, pop the stack and output it until a ‘(‘ is encountered, and discard both the parenthesis. 6. Repeat steps 2-6 until infix expression is scanned. 7. Print the output 8. Pop and output from the stack until it is not empty.
332
What is the Big Oh time of a simple sorting algorithm?
O(N2)
333
What are the three variables of a treeNode?
Object element; TreeNode firstChild; TreeNode secondChild;
334
# Reversed Card Addathead RemoveAtHead Clear isEmpty
What four methods make up the simplest linked list interface?
335
# Reversed Card By enclosing the body in a while loop and replacing the recursive call with one assignment per method argument.
How can tail recursion be eliminated?
336
# Reversed Card Classes built with no data and one single method.
What are function objects?
337
# Reversed Card A tree in which the leaves are operands, such as constants or variable names, and the internal nodes contain operators.
What is an expression tree?
338
# Reversed Card Let the Node be N. N.Object = findMin(N.right).Object; Delete(findMin(N.right);
How is a node with two children deleted?
339
# Reversed Card Long(long m, long n) while(n!=0) long rem = m % n; m = n; n = rem; return m;
What is the Euclid algorithm?
340
When an outer insertion occurs to the right, what does the imbalanced node become?
It becomes its right child's left child.
341
Where is the insertion point in a probabilistic skip list?
The point in the list after the previous node.
342
What function is called when Insertion took place in the left subtree of the left child of X(out-of-balance node).
rotate with left child
343
# Reversed Card double rotate with left.
What function is called when Insertion took place in the right subtree of the left child?
344
What function is called when Insertion took place in the right subtree of the right child?
rotate with right
345
What interface does the Collections interface extend?
The iterable interface
346
What type of objects cannot be used in place of generic type parameters?
Primitive types, Wrapper classes must be used.
347
# Reversed Card A root and two subtrees, both of which could be empty.
A binary tree consists of what?
348
What is one way to shorten code for assignments?
making multiple assignments in one line right to left.
349
350
What is a directory in the UNIX File System?
A file with a list of all its children.
351
# Reversed Card Long power(long a, int b) if(b == 0) return 1; if(b == 1) return a; if(b%2 == 0) return power(a\*a, b/2); else return power(a\*a, b/2)\*a;
What is the algorithm for fast exponentiation?
352
# Reversed Card O(log N) assuming all insertion sequences are equally likely.
What is the average depth over all nodes in a binary search tree assuming that all insertion sequences are equally likely?
353
These two linked list operations are identical to a stack push and pop...
AddAtHead RemoveAtHead
354
What data structure is used to implement stacks, queues and deques?
Linked lists are used to implement these data structures.
355
# Reversed Card A queue
What ADT is used in operating systems and algorithm design?
356
# Reversed Card ArrayList, and LinkedList
What two implementations are there of the built in List interface?
357
# Reversed Card O(N2)
What is the Big Oh time of a simple sorting algorithm?
358
When is the maximum level of a probabilistic skip list chosen?
At construction
359
# Reversed Card A stack
When implementing recursion, what ADT is usually used?
360
What two data members make up a linked list node?
Object element Node next
361
What is an online algorithm?
an algorithm that can correctly give an answer for the data it has read at any given time.
362
# Reversed Card head = new Node(object, head);
The addAtHead function has only one line of code. What is it?
363
The running time of a for loop is at most what?
the running time of the statements inside the for loop multiplied by the number of iterations.
364
The ArrayList class contains what data variables?
An underlying array, the array capacity, and the current number of items in the array.
365
What is the advantage of a LinkedList over an ArrayList?
Add and remove at head take constant time.
366
A rotate with right child causes the Node X to replace it's right child with what?
the right childs left subtree.
367
Log(A\*B) = ?
Log A + Log B
368
What is postorder traversal?
When the work at a node is done after its children have been evaluated.
369
# Reversed Card Graphs
Trees are actually what?
370
What is a queue?
A list in which insertion is done at one end and removal is done at the other end.
371
# Reversed Card We construct the AVL tree of height h that contains the fewest nodes, we call these the skinniest AVL trees. We deduce a recurrence relation for the minimum number of nodes in an AVL tree of height h. We solve this recurrence relation and then rearrange the result to get an equation for the maximum height of an AVL tree with N nodes.
How do we prove the property of the worst case height of an AVL tree to be O(log N)?
372
# Reversed Card A reference that points to itself, and another entry that points to the parent of the directory.
Besides a list of its children, what else does a Unix directory have?
373
# Reversed Card Head is Node, List is Empty.
What are the two special cases dealt with first in most list operations?
374
What kind of traversal is used to evaluate an expression tree?
An in order traversal is used
375
# Reversed Card the process performed by the compiler that turns generic classes into non-generic classes.
What is type erasure?
376
What is preorder traversal?
When the work at a ndoe is performed before its children are processed.
377
# Reversed Card * DoubleRotateWRight(node x) * x.right = rotateWLeft(x.right); * Return rotateWRight(x);
What is the double rotate with right child algorithm?
378
# Reversed Card infix.
An expression that is in standard form is said to be\_\_\_\_
379
# Reversed Card this is the case that insertion took place in the right subtree of x's left child.
Let x be the out of balance node, and k be the key that was inserted what is the case that x.leftchild \< k \< x.value?
380
# Reversed Card it specifies the properties that the parameter types must have and goes inside of the angle brackets after the type parameter.
What is a type bounds?
381
# Reversed Card O(logn), solved by noticing that after two iterations the remainder is less than n/2.
What is the time complexity of Euclids algorithm?
382
383
How is a node with two children deleted?
Let the Node be N. N.Object = findMin(N.right).Object; Delete(findMin(N.right);
384
What is a popular application of trees in operating systems?
The directory structure is a popular application.
385
What is the worst case tree height of an AVL tree?
O(log N) this is worst
386
# Reversed Card Object element; TreeNode firstChild; TreeNode secondChild;
What are the three variables of a treeNode?
387
All recursive functions must eventually reduce to what?
To the base case.
388
What else may be used besides the Object class for genericity, and how?
An interface may be used as the parameter type and return type to create a generic function.
389
What ADT is used in operating systems and algorithm design?
A queue
390
When is insertion sort generally faster?
When n \< 25.
391
# Reversed Card They count for no time unit.
What time unit do declartions count for?
392
# Reversed Card null checks
When compound logical statements are used in linked list traversals, what should always be done first?
393
# Reversed Card A new red node with null links.
All insertions in a red black tree create a new what?
394
# Reversed Card when each inner class object is associated with exactly one instance of an outer class object.
When is using an inner class useful?
395
# Reversed Card 2h+1-1
A perfect binary tree has how many nodes?
396
# Reversed Card double rotate with right
What function is called when Insertion took place in the left subtree of the right child?
397
When can insertion and deletion in a skip list take O(N)?
When the division into regions of size equal to powers of two is maintained.
398
# Reversed Card The iterable interface
What interface does the Collections interface extend?
399
# Reversed Card Public static int maxsubsum(int[] a) Int max sum = 0, this sum =0; For (int I =0, I \< a.length, i++) Thissum += a[i]; If(thissum \> maxsum ) maxsum = thissum; Else if (thissum \< 0) thissum = 0; Return maxsum;
What is the linear time algorithm for the positive max subsequence problem?
400
Where is the parameter type used in a class definition?
Anywhere in the class where the type of an object can be anything.
401
# Reversed Card S(h) = S(h-1) + S(h-2) + 1
The minimum number of nodes in an AVL tree of height h is given by what recurrence relation?
402
What extra variable and operations are used in a queue?
A tail node, insert at tail, remove at head
403
When creating a generic method, where do the angle brackets go?
Before the return type.
404
In a path name, each slash indicates what?
An edge from one directory node to the other.
405
# Reversed Card 1. An insertion into the left subtree of the left child of unbalanced node. 2. An insertion in to the right subtree of the left child of unbalanced node. 3. An insertion into the left subtree of the right child of unbalanced node. 4. An insertion into the right subtree of the right child of the unbalanced node.
What are the four cases that may cause a balance violation?
406
What function is called when Insertion took place in the right subtree of the left child?
double rotate with left.
407
# Reversed Card 2Xn
Xn + Xn = ?
408
409
What two kind of rotations is a double rotation?
1. a rotate with right, followed by a rotate with left or 2. a rotate with left, followed by a rotate with right.
410
# Reversed Card 1. Deleting a leaf Node. 2. Deleting a node with one child. 3. Deleting a node with two children.
What are the three cases which the delete algorithm must address?
411
What is an inside insertion?
an insertion into the right subtree of the left child, or the left subtree of the right child.
412
# Reversed Card After the class name, before the object reference.
When instantiating a generic class, where do the angle brackets go?
413
# Reversed Card (Anytype []) new Object[];
How is a generic array created?
414
# Reversed Card Stores a current position starting at the beginning. HasNext(); Next(); Remove();
What is the basic implementation of an iterator?
415
# Reversed Card stores identically typed objects
What does a collection do?
416
Let x be the out of balance node, and k be the key that was inserted what is the case that x.value \< k \< x.rightChild.value?
this is the case that insertion took place in the left subtree of the right child.
417
What is a rooted Binary tree?
A tree with a root node in which every node has at most two children.
418
# Reversed Card O(logN)
What is the average running time of most operations in a binary search tree?
419
What is a geometric recurrence?
one in which the numbers are in the sequence are a product of the previous number and some k.
420
What is the basic implementation of an iterator?
Stores a current position starting at the beginning. HasNext(); Next(); Remove();
421
What are the minimal two classes needed to implement a linked list?
LinkedList Node
422
423
# Reversed Card O(1), it is constant.
What is the runtime of adding an removing from a linked list?
424
A tree that is not binary may have how many children?
An arbitrary number, possibly zero.
425
# Reversed Card The point in the list after the previous node.
Where is the insertion point in a probabilistic skip list?
426
In computer science, all logarithms are to what base?
Base 2
427
What is the runtime of fast exponentiation?
O(logn), which is given by the number of multiplications computed.
428
# Reversed Card N divides A - B, this intuitively means that the remainder is the same when N divides either A or B.
We say that A is congruent to B modulo N, if
429
When instantiating a generic class, where do the angle brackets go?
After the class name, before the object reference.
430
Besides a list of its children, what else does a Unix directory have?
A reference that points to itself, and another entry that points to the parent of the directory.
431
# Reversed Card if(head ==null) throw error Object result = head.value; head = head.next; return result;
What is the removeFromHead algorithm?
432
# Reversed Card A list in which every node maintains a link to its previous and next node.
What is a doubly linked list?
433
When instantiating a class, what goes inside of the angle brackets?
The type of object that will replace the parameter type.
434
# Reversed Card A search proceeds along the list with the greatest span until two references are found that enclose the required key. Then the search proceeds at the next level down until the required key found, or is deemed to be not present.
How does a skip list search work?
435
What is the contains algorithm?
* Contains(x, BinaryNode t) * if(t == null) return false; * if(x.compareTo(t.Object) \< 0) return contains(x, t.left); * if(x.compareTo(t.Object) \> 0) return containts(x, t.right); * else return true;
436
437
# Reversed Card by repeatedly taking the GCDs of pairs of numbers: gcd(gcd(a, b), c)
How can Euclids algorithm be used for finding the GCD of 3 or more positive numbers?
438
When and for what are wildcards used?
When using a generic Collections, a wild card goes inside of the angle brackets after Collection along with the extends keyword to allow a class and any of its subclasses to be used in the collection.
439
What kind of traversal is used to convert an expression tree into a postfix expression?
A postorder traversal.
440
# Reversed Card It returns true if a node in tree T has item x, or false if not.
What does the contains function do?
441
# Reversed Card It's left child's right subtree.
A rotate with left child causes the Node X to become what?
442
The addAtHead function has only one line of code. What is it?
head = new Node(object, head);
443
What is the average depth of a binary search tree?
O(log N)
444
# Reversed Card Before the return type.
When creating a generic method, where do the angle brackets go?
445
# Reversed Card 1. a rotate with right, followed by a rotate with left or 2. a rotate with left, followed by a rotate with right.
What two kind of rotations is a double rotation?
446
What are the variables of a BinaryNode?
Object, left child, right child.
447
# Reversed Card Because deltion will always faovr making one sides subtree shorter, therefore making all insertion sequences no longer equally likely.
Why does deletion cause the average runtime of O(log N) to not always hold?
448
# Reversed Card A preorder traversal.
What kind of traversal is used to convert an expression tree into a prefix expression?
449
# Reversed Card null.
What should the last node in a linked list always point to?
450
# Reversed Card It ensures that the depth of a tree is O(log N)
What does an AVL tree ensure?
451
When we are speaking of trees, N always represents what?
452
# Reversed Card making multiple assignments in one line right to left.
What is one way to shorten code for assignments?
453
# Reversed Card The path from the root to the farthest null-link is no more than twice as long as the path from the root to the nearest null link.
What is the fundamental Red-Black Tree Property?
454
# Reversed Card The enhanced for loop.
Classes that extend the iterable interface can implement what?
455
What is the fundamental Red-Black Tree Property?
The path from the root to the farthest null-link is no more than twice as long as the path from the root to the nearest null link.
456
How can tail recursion be eliminated?
By enclosing the body in a while loop and replacing the recursive call with one assignment per method argument.
457
What is the IsEmpty algorithm?
return root == null;
458
What is a stack frame, or activation record?
The information saved on a stack when a method is called and the registers must be cleared.
459
What kind of traversal is used to convert an expression tree into a prefix expression?
A preorder traversal.
460
# Reversed Card Compiler features that allow primitive types to be passed as wrapper classes and vice versa.
What is autoboxing/ unboxing?
461
# Reversed Card 2log2(n+1)
Every red black tree with N nodes has a height less than or equal to what?
462
# Reversed Card To allow the nested class to use the members of the outer class.
Why must we use the static keyword when nesting a class inside of a class?
463
# Reversed Card A pop or peek on an empty list.
What is generally considered an error in the stack adt?
464
What are function objects?
Classes built with no data and one single method.
465
# Reversed Card A file with a list of all its children.
What is a directory in the UNIX File System?
466
# Reversed Card O(n2), different from its average case.
What is the time complexity of Quick sort?
467
# Reversed Card An interface may be used as the parameter type and return type to create a generic function.
What else may be used besides the Object class for genericity, and how?
468
# Reversed Card * Every node is either red or black. * The root of the tree is black. * A red node must have no children or exactly two black children. * Every path from a node x to a descendent null-link must have the same number of black nodes.
What are the four fundamental properties of Red-Black Trees?
469
# Reversed Card a clearly specified set of simple instructions to be followed to solve a problem.
What is an algorithm?
470
When compound logical statements are used in linked list traversals, what should always be done first?
null checks
471
# Reversed Card When every node that is inserted is larger or smaller than the one before, ie, they are inserted in order.
When does the worst case depth happen in a binary search tree?
472
What is a binary tree?
A tree in which no node can have more than two children.
473
At worst case, a binary tree can have a depth of what?
N-1
474
What is the binary tree insertion algorithm?
* BinaryNode Insert(x, BinaryNode t) * if(t==null) return new BinaryNode(x, null, null); * int compare = x.compareTo(t.element); * if(compare \< 0) t.left = insert(x, t.left) * else if(compare \> 0 ) t.right = insert(x, t.right); * else do nothing; * return t;
475
What are the three steps to creating an expression tree from a postfix expression?
1. We read our expression one symbol at a time. If the symbol is an operand, we create a one node tree and push it to a stack of trees. 2. If the symbol is an operator, we pop two trees from the stack and form a new tree whose root is the operator. 3. The new tree is then pushed onto the stack, and the process continues until it is complete.
476
# Reversed Card 2 constructors, right child, left child, object, height.
What is the AVL node implemenation?
477
What is the performance time of a degenerate tree?
The same as that of a linked list. O(n)
478
2n ![]() + 2n = ?
2n+1
479
What is tail recursion?
A recursive call at the last line of a method, and an example of bad recursion.
480
What is a complete binary tree?
A binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
481
What is the first step to doing an insertion or deletion in a probabilistic skip list?
Finding the insertion point.
482
A Red-Black tree where all nodes are black is what?
A perfect Binary tree.
483
# Reversed Card A red node can never have a red child, or just one child.
What can a red node never have?
484
When does the worst case depth happen in a binary search tree?
When every node that is inserted is larger or smaller than the one before, ie, they are inserted in order.
485
What is the time complexity of Quick sort?
O(n2), different from its average case.
486
# Reversed Card 1. We read our expression one symbol at a time. If the symbol is an operand, we create a one node tree and push it to a stack of trees. 2. If the symbol is an operator, we pop two trees from the stack and form a new tree whose root is the operator. 3. The new tree is then pushed onto the stack, and the process continues until it is complete.
What are the three steps to creating an expression tree from a postfix expression?
487
# Reversed Card Ordered Linked Lists
What are skip lists made of?
488
A perfect binary tree has how many nodes?
2h-1
489
# Reversed Card Operands are pushed onto a stack until an operator is encountered. Two operands are then popped and the operator is applied to them and saved in a result variable. The result is pushed back onto the stack, and this is continued until the end of the expression.
What is the algorithm for evaluating a postfix expression?
490
# Reversed Card It is the value for which the function is known without having to resort to recursion.
What is the base case of a recursive function?
491
# Reversed Card (Logc B) --------------- (Logc A)
LogA B = ?
492
# Reversed Card One time unit.
What is the time unit of a simple operation or assignment?
493
What is the average depth over all nodes in a binary search tree assuming that all insertion sequences are equally likely?
O(log N) assuming all insertion sequences are equally likely.
494
# Reversed Card At construction
When is the maximum level of a probabilistic skip list chosen?
495
If a prime number N divides a product of two numbers, then
it divides at least one of the two numbers.
496
497
What are the four cases that may cause a balance violation?
1. An insertion into the left subtree of the left child of unbalanced node. 2. An insertion in to the right subtree of the left child of unbalanced node. 3. An insertion into the left subtree of the right child of unbalanced node. 4. An insertion into the right subtree of the right child of the unbalanced node.
498
# Reversed Card when it takes constant time to cut the problem size by a fraction, usually 1/2.
When is an algorithm O(logn)?
499
What is an algorithm?
a clearly specified set of simple instructions to be followed to solve a problem.
500
What is the double rotate with right child algorithm?
* DoubleRotateWRight(node x) * x.right = rotateWLeft(x.right); * Return rotateWRight(x);
501
What is the removeFromHead algorithm?
if(head ==null) throw error Object result = head.value; head = head.next; return result;
502
503
# Reversed Card The length of the unique path from the root to it.
What is the depth of a node?
504
What function is called when Insertion took place in the left subtree of the right child?
double rotate with right
505
An expression that is in standard form is said to be\_\_\_\_
infix.
506
How can a generic object of Object type be accessed and used properly?
By downcasting the object to the proper type.
507
What is the depth of the root?
depth = 0.
508
# Reversed Card this is the case that insertion took place in the left subtree of x's left child.
Let x be the out of balance node, and k be the key that was inserted what is the case that K \< x.leftChild.Value?
509
What are some popular but not required linked list operations?
printList, makeEmpty
510
# Reversed Card .25
What is the suggested probabilistic variable value for a probabilistic skip list?
511
What is the depth of a node?
The length of the unique path from the root to it.
512
What is type erasure?
the process performed by the compiler that turns generic classes into non-generic classes.
513
How is a node with one child deleted?
The parent node sets its child node to its grandchild.
514
What are function objects used for?
To pass functions as parameters.
515
What is meant by an outside insertion?
An insertion took place in the right subtree of teh rigth child, or the left subtree of the left child.
516
# Reversed Card It does nothing.
What does the delete function do if a value is not found?
517
What is one way to handle a tree that will have duplicates inserted?
Keep a record of frequency in each node and update it when a duplicate is added or removed.
518
What are three examples of simple sorting algorithms?
Selection sort, bubble sort, insertion sort.
519
# Reversed Card When nodes have a deleted marker that is turned on when they are deleted.
What is lazy deletion?
520
# Reversed Card A doubly linked list.
What kind of list is required for a sufficient implementation of a deque?
521
What is the algorithm for evaluating a postfix expression?
Operands are pushed onto a stack until an operator is encountered. Two operands are then popped and the operator is applied to them and saved in a result variable. The result is pushed back onto the stack, and this is continued until the end of the expression.
522
# Reversed Card an insertion into the right subtree of the left child, or the left subtree of the right child.
What is an inside insertion?
523
What is a degenerate tree?
a tree where, for each parent node, there is only one associated child node.
524
What is the AVL node implemenation?
2 constructors, right child, left child, object, height.