





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Read the following now.
int n=10; int *p, *q; int **r; q = &n; r = &p; p = new int[5]; for (int i=0; i<5; i++) p[i] = *q - i; p = p + 1; *r = *r + 1; cout << *p;
(c) (5pt) Argue in one sentence that the graph is not connected.
(d) (15pt) Using vertex 4 as the starting point, show the contents of the pred and dist arrays of the Dijkstra’s algorithm after the completion of 4 iterations.
54 , 33 , 21 , 25 , 60 , 40 , 75 , 83 , 62 , 34 , 79 , 90
(a) (10pt) Show the contents of the array after applying the partition() routine, the first phase in the quicksort algorithm, to the array.
(b) (10pt) Using the heapsort algorithm, show the contents of the array after inserting 6 data items into the heap.
template
private: ListNode** neighbors_list; T* labels; int vertex_count; int max_size; ... you can add new private members here ... };
Your task is to implement a second array reference operator
int operator[] (T& label);
so that the user of the Digraph class, when given the label or name of a vertex, can easily obtain the number of the vertex. To illustrate the use of the routine, consider a “Digraph
(a) (10pt) Discuss in four or less sentences how you are going to implement the routine. Note that for this question C++ coding is unnecessary, not welcome actually. Just clearly present your “idea.”
(b) (10pt) List the additional, private data members you need to add to class Digraph in order to implement the routine. For each item you add, explain its use/purpose in one sentence.