Data Structures
CSCI C343, Fall 2013
Quiz 1
Name:
This quiz has 3 questions, for a total of 10 points.
1. 3 points Suppose the Flood-It! board is in the below conguration.
How many tiles are in the flooded list?
If the player chooses purple, how many tile
/a simple BST tree (so we call it BSTJr) for C343
public class BSTJr <K extends Comparable<?super K> cfw_
BinNode<K> root;
BinNode<K> curr;
/for balance checking: if a node is unbalanced, the tree will be
unbalanced
BinNode<K> unbalanced = null;
public BS
public class BinNode<Key, E> cfw_
private Key key;
private E value;
private BinNode<Key, E> left;
private BinNode<Key, E> right;
public BinNode(Key k, E e) cfw_
key = k;
value = e;
left = right = null;
public Key getKey() cfw_ return key;
public E getVa
/a simple implementation of Graph using adjacency list
/C343 2016, with Prim's algorithm (mstPrim) to be implemented by students
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Vector;
public class AdjGraph implements Graph cfw_
/a simple class for binary node (C343)
public class BinNode <K extends Comparable<?super K>cfw_
private K key; /only key, no value
private BinNode<K> left; /left child
private BinNode<K> right; /right child
private int size; /the size (#nodes) of the subt
public class MinHeap <Key extends Comparable<? super Key>, E> cfw_
/* store the elements in an array, listArray */
private BinNode<Key, E>[] listArray;
private int listSize;
private int maxSize;
public MinHeap(int maxn, int num, BinNode<Key, E>[] inp) cfw
import java.util.Arrays;
/ KD tree with insert and exact match functions
/ getNeighbors(Key[] key, int r) is going to be implemented by the students
public class KDtree<Key extends Comparable<?super Key>, E> cfw_
private BinNode<Key, E> root;
private int
From WikiPedia
In computer science, a data structure is a particular way of storing and organizing data
in a computer so that it can be used efficiently.
Different kinds of data structures are suited to different kinds of applications,
and some are high
/a simple BST tree (so we call it BSTJr) for C343
public class BSTJr <K extends Comparable<?super K> cfw_
BinNode<K> root;
BinNode<K> curr;
/for balance checking: if a node is unbalanced, the tree will be unbalanced
BinNode<K> unbalanced = null;
public BS
import java.util.LinkedList;
/a simple interface for graph
/C343 2016
public interface Graph cfw_
public void init();
public int length();
public void setVertex(String[] nodes);
public void addVertex(String node);
public void setEdge(int v1, int v2, int w
d a t a b i g d a t a
1
2
3
4
5
6 7
8
9
10 11
Query: data
at a
d
big
5
$
ta $
a
ig d
6
ta$
a
gd
a
ta
data
7
$
8
bigdata$ $
1
10
$
bigdata$
3
11
ta
bigdata$
4
$
9
bigdata$
2
/ Binary node with multiple keys
/ Yuzhen Ye, C343, Spring 2016
public class BinNode<Key, E> cfw_
private Key[] key; /can be any dimension; multiple keys
private E value;
private BinNode<Key, E> left;
private BinNode<Key, E> right;
public BinNode(Key[] k,
Data Structures
CSCI C343, Fall 2013
Quiz 10
Name:
This quiz has 3 questions, for a total of 10 points.
1. 4 points Fill in the blanks to complete this implementation of the Bellman-Ford shortest paths algorithm for a graph represented as an adjacency-lis
Data Structures
CSCI C343, Fall 2013
Quiz 1
Name:
This quiz has 3 questions, for a total of 10 points.
1. 3 points What code needs to be lled into the blanks labeled (a), (b), and (c) to nish
this algorithm that rotates the elements in a non-empty array b
Data Structures
CSCI C343, Fall 2013
Quiz 1
Name:
This quiz has 3 questions, for a total of 10 points.
1. 4 points What is the output of the following Python program?
A = []
A.append(1)
A.append(2,3)
print(A)
print(1 in A)
print(2 in A)
A[1] = 2
print(A)
Data Structures
CSCI C343, Fall 2013
Quiz 2
Name:
This quiz has 3 questions, for a total of 10 points.
1. 3 points Suppose that L is a Python list (array) of length n. Categorize the worstcase execution time of each of the below operations as either
1. co
Data Structures
CSCI C343, Fall 2013
Quiz 2
Name:
This quiz has 3 questions, for a total of 10 points.
1. 3 points Suppose that L is a Python list (array) of length n. Categorize the worstcase execution time of each of the below operations as either
1. co
Data Structures
CSCI C343, Fall 2013
Quiz 2
Name:
This quiz has 3 questions, for a total of 10 points.
1. 3 points Suppose that L is a Python list (array) of length n. Categorize the worstcase execution time of the below operations as either
1. constant t
Data Structures
CSCI C343, Fall 2013
Quiz 3
Name:
This quiz has 4 questions, for a total of 10 points.
1. 2 points What is the output, if any, of the following Python program?
def f1(g, n):
if n = 0:
return
else:
return
def f2(h, n):
if n = 0:
return
else
Data Structures
CSCI C343, Fall 2013
Quiz 3
Name:
This quiz has 4 questions, for a total of 10 points.
1. 3 points Given the following array, which positions of the array will be read from during
a binary search for the number 8? (The number 3 is in posit
Data Structures
CSCI C343, Fall 2013
Quiz 3
Name:
This quiz has 4 questions, for a total of 10 points.
1. 3 points Given the following array, which positions of the array will be read from during
a binary search for the number 8? (The number 3 is in posit
Data Structures
CSCI C343, Fall 2013
Quiz 4
Name:
This quiz has 4 questions, for a total of 10 points.
1. 2 points Write down the sequence of keys from the following Binary Search Tree, ordering according to the post-order traversal strategy.
15
3
@
w
0
7
Data Structures
CSCI C343, Fall 2013
Quiz 4
Name:
This quiz has 4 questions, for a total of 10 points.
1. 3 points What code needs to be lled into the blanks labeled (a), (b), and (c) to nish
this algorithm that searches within a Binary Search Tree rooted
Data Structures
CSCI C343, Fall 2013
Quiz 10
Name:
This quiz has 3 questions, for a total of 10 points.
1. 4 points Fill in the blanks to complete this implementation of the Bellman-Ford shortest paths algorithm for a graph represented as an adjacency-lis