BEP Chapter 2 Learning and Cognition Exercise Automaticity Aoccdrnig to a rscheearch at Cmabrigde Uinvertisy it deosent mttaer waht leettr is fsrit in a word, jsut taht the frist and lsat ltteer are the smae Learning Long Term change in mental repres
CS 360 Exam 1
Fall 2011
Solution
1. Arrange these running times in order from best (most efficient) to worst (least efficient):
3n
n
nn
lg n
n3
n lg n
2n
5000
n!
n2
n n
n
lg n
n
n lg n
n2
n3
2n
3n
n!
nn
2. Write the running time of each code fragment be
CS 360 Exam 2
Spring 2012
Preview / Study guide
Your score on this exam is based on your best 7 of these 8 problems.
1. Draw trees that have the indicated traversal orders (pre-order, post-order, level-order, in-order).
2. Write a pseudo-code function rel
CS 360 Exam 3
Fall 2011
Name _
1. Given disjoint sets cfw_1), cfw_2), cfw_3), cfw_4), cfw_5), cfw_6), cfw_7), cfw_8), write a sequence of Merge operations
using union-by-size that will produce a tree with height 3 (so the tree has 4 levels), and
draw the
CS 360 Exam 2
Spring 2012
Solution
Your score on this exam is based on your best 7 of these 8 problems.
1. Draw two trees as indicated below.
a. Draw a binary arithmetic expression tree that has these traversal orders:
Infix:
H/G+F-E*D*C/B+A
Prefix:
*/H-+
CS 360 Exam 2
Spring 2012
Name _
Your score on this exam is based on your best 7 of these 8 problems.
1. Draw two trees as indicated below.
a. Draw a binary arithmetic expression tree that has these traversal orders:
Infix:
H/G+F-E*D*C/B+A
Prefix:
*/H-+GF
CS 360 Exam 2
Fall 2011
Solution
1. Begin with the min-ordered binary heap shown below.
a. Redraw the heap after inserting key 1.
b. Redraw the heap after performing removeMin on the original heap.
3
5
6
7
9
12
11
3
2
5
6
4
9
12
4
10
3
1
2
8
10
11
7
5
9
1
CS 360 Exam 3
Fall 2011
Solution
1. Given disjoint sets cfw_1), cfw_2), cfw_3), cfw_4), cfw_5), cfw_6), cfw_7), cfw_8), write a sequence of Merge operations
using union-by-size that will produce a tree with height 3 (so the tree has 4 levels), and
draw th
CS 360 Exam 3
Spring 2012
Name _
Your score on this exam is based on your best 7 of these 8 problems.
1. Begin with the max-ordered binary heap shown below.
a. Redraw the heap after inserting key 13.
b. Redraw the heap after performing removeMax on the or
CS 360 Exam 3
Spring 2012
Preview / Study guide
Your score on this exam is based on your best 7 of these 8 problems.
1. Trace some operations on a binary heap, and draw the heap.
2. Trace some operations on a leftist heap, and draw the heap.
3. Trace some
CS 360 Exam 3
Spring 2012
Solution
Your score on this exam is based on your best 7 of these 8 problems.
1. Begin with the max-ordered binary heap shown below.
a. Redraw the heap after inserting key 13.
b. Redraw the heap after performing removeMax on the
CS 360 Exam 4
Spring 2012
Preview / Study guide
Your score on this exam is based on your best 6 of these 7 problems.
1. Given a graph, draw its adjacency matrix and adjacency lists data structures.
2. Given a graph, trace the breadth-first search and dept
CS 360 Exam 4
Spring 2012
Solution
Your score on this exam is based on your best 6 of these 7 problems.
1. Complete the weighted adjacency matrix and weighted adjacency lists data structures for
this undirected graph. Arrange each list of neighbors alphab
CS 360 Exam 4
Spring 2012
Name _
Your score on this exam is based on your best 6 of these 7 problems.
1. Complete the weighted adjacency matrix and weighted adjacency lists data structures for
this undirected graph. Arrange each list of neighbors alphabet
CS 360 Exam 5
Spring 2012
Solution
Your score on this exam is based on your best 8 of these 9 problems.
1. Trace the Huffman coding algorithm for the alphabet and frequencies below. Draw the
Huffman tree, and show the binary code for each letter.
Letter
A
CS 360 Exam 5
Spring 2012
Preview / Study guide
Your score on this exam is based on your best 8 of these 9 problems.
1. Trace a greedy algorithm.
2. Determine whether a proposed greedy algorithm is correct or not.
3. Write a greedy algorithm.
4. Solve sev
CS 360 Exam 5
Spring 2012
Name _
Your score on this exam is based on your best 8 of these 9 problems.
1. Trace the Huffman coding algorithm for the alphabet and frequencies below. Draw the
Huffman tree, and show the binary code for each letter.
Letter
A
B
CS 360 Exam 1
Spring 2012
Solution
Your score on this exam is based on your best 5 of these 6 problems.
1. Arrange these running times in order from best (most efficient) to worst (least efficient):
n
n lg n 4n n 22 n4 n! 4 n 3n 3 n 2n n n3 lg lg n 9999 l
CS 360 Exam 1
Fall 2011
Name _
1. Arrange these running times in order from best (most efficient) to worst (least efficient):
3n
n
nn
lg n
n3
n lg n
2n
5000
n!
n2
n n
n
2. Write the running time of each code fragment below as the simplest function of n.
f
CS 360 Exam 2
Fall 2011
Name _
1. Begin with the min-ordered binary heap shown below.
a. Redraw the heap after inserting key 1.
b. Redraw the heap after performing removeMin on the original heap.
2
3
4
5
6
7
9
12
11
10
8
2. Begin with the min-ordered left
CS 360 Quiz 18
Spring 2013
Solution
Given this weighted undirected graph:
9
1
5
6
12
7
11
4
2
3
8
10
1. Complete the weighted adjacency matrix and weighted adjacency lists data structures.
Arrange each adjacency list in ascending order of neighbor vertice
CS 360 Quiz 16
Spring 2013
Solution
1. Write the worst-case running time of each indicated sorting algorithm below as a function of
the size n and any other parameters as shown.
Bin or bucket sort, items in range 0m
Bubble sort
Counting sort, items in ran
CS 360 Quiz 17
Spring 2013
Solution
1. Given the disjoint sets tree T as shown below. Re-draw the tree T as it would appear after
calling find (12), when using each of the three indicated heuristics.
T
(a.) Path compression:
1
1
2
3
4
6
5
2
3
8
7
8
11
12
CS 360 Quiz 20
Spring 2013
Solution
Trace Kruskals algorithm, Prims algorithm, and Dijkstras algorithm for this weighted graph.
For Prim and Dijkstra algorithms, let A be the start vertex.
12
B
10
11
13
J
9
1
C
H
2
16
A
14
8
D
15
E
5
G
7
3
4
F
6
Draw a mi
CS 360 Quiz 19
Spring 2013
Solution
1. Given this undirected graph, trace depth-first search six times, by using each vertex 1, 2, 3, 4, 5, 6
as the start vertex. While tracing DFS, remember to traverse each adjacency list in ascending order
of the neighb
CS 360 Quiz 15
Spring 2013
Solution
Use this array as input for each sorting algorithm below:
10
13
12
3
8
7
2
5
a. Insertion sort: Show the arrays contents after completing the first three of the seven passes.
3
10
12
13
8
7
2
5
b. Selection sort: Show t
CS 360 Quiz 21
Spring 2013
Solution
1. Write the running time of each algorithm below as a simplest function of n=|V| and m=|E|.
Breadth-first search, using adjacency lists
(n+m)
(n2)
Breadth-first search, using an adjacency matrix
Depth-first search, usi
CS 360 Quiz 23
Spring 2013
Solution
1. For each recurrence below, write its solution T(n) as the simplest function of n.
a. T(n) = 16 T(n/2) + n2
(n4)
b. T(n) = 16 T(n/2) + n4
(n4 lg n)
c. T(n) = 16 T(n/2) + n6
(n6)
d. T(n) = 64 T(n/2) + n6
(n6 lg n)
e. T
CS 360 Quiz 25
Spring 2013
Solution
1. Trace the dynamic programming algorithm for the 0-1 knapsack problem using size n=4 and
capacity M=6, and with profits P[14] and weights W[14] as shown. Complete all the entries
in the tables below, and also specify
CS 360 Quiz 22
Spring 2013
Solution
Trace the Huffman coding algorithm for the alphabet and frequencies given below.
Draw the Huffman tree, and write the binary code for each letter.
Letter Frequency
A
13
C
1
D
4
E
21
H
6
I
10
L
2
N
9
O
12
R
5
S
8
T
14
Co