void secret(int arr[], int start_index, int end_index) {
if(start_index >= end_index)
return;
int min_index;
int temp;
/* Assume that minIndex() returns index of minimum value in
array arr[start_index...end_index] */
min_index = minIndex(arr, start_index, end_index);
temp = arr[start_index];
arr[start_index] = arr[min_index];
arr[min_index] = temp;
secret(arr, start_index + 1, end_index);
}
10
/ \
12 15
/ \ / \
25 30 36 42
public static <T> List<T> convertBTreeToArrayList(BinaryTreenode<T> root) {
25, 12, 30, 10, 36, 15, 42
Consider the following directed graph, which is given in adjacency list form:
1: 2, 4, 6 2: 4, 5 3: 1, 2, 6, 9 4: 5 5: 4, 7 6: 1, 5, 7 7: 3, 5 8: 2, 6, 7 9: 1, 7
Part A:
Part B:
39
/ \
25 45
/ \ \
11 33 55
/ \ \ / \
7 17 37 47 57
Show the red-black tree that results from inserting each sequence of integers into a tree that is initially empty. In your answer, you can grapically draw red nodes with their data and use R_ as the prefix and black nodes with B_ as the prefix. An example for this is shown below.
42, 36, 40, 33, 35, 32, 41, 31, 34, 49
2, 1, 4, 5, 9, 3, 6, 7, 11, 10
B_14
/ \
B_7 R_20
/ \ / \
R_1 R_11 B_18 B_23
\
R_29
Consider the following undirected graph, which is given in adjacency matrix form and where vertices have the given labels and edges have non-negative integer weights (no value indicates no edge exists):
v0 v1 v2 v3 v4 v5 v6
+----------------------------
v0 | 3 6 2
|
v1 | 3 1 6
|
v2 | 6 1 3 4
|
v3 | 2 3 8 7
|
v4 | 6 4 8 3 2
|
v5 | 7 3 2
|
v6 | 2 2
| Iteration | List of Visited Vertexes and their shortest distances from start |
Priority Queue's items (listed in increasing order) |
| 0 | - | 0 v0 |
| 1 | v0 0 | 2 v3, 3 v1, 6 v2 |
| 2 | v0 0, v3 2 |
public static List<Integer> setUnion(List<Integer> firstList, List<Integer> secondList) {
...
}