Consider a single-linked list of character elements, for example:
Write a non-recursive function, in the language of your choice, which reverses all of the pointers, for example:
The function should return a pointer to the last node in the list (and this node is effectively the new head of the list). An initial call would be:
The nodes in the list just have a single pointer, not two pointers. Do not build a new list. Simply modify the pointers in the current list. The running time of your function should be O(n) (where n is the number of list entries) and should only use O(1) extra memory. Declare your data structures and do not include a dummy header.
Consider a MinHeap (Priority Queue) of integer keys. Assume these integer keys are inserted into the heap in this order: 10, 4, 12, 8, 3, 9, 15, 7.
a) [5 points] Draw the heap after the insertion of the keys.
b) [15 points] Code the "insert" function in the language of your choice. Assume, as usual, that the MinHeap is implemented as an array. Declare your data structure and the prototype of your function.
Let G be a connected weighted graph with n vertices and m edges. The edges are stored using the adjacency matrix implementation. The vertices are v0, ..., vn-1
a) Write a routine to construct the shortest path from vertex u to vertex w. Code in the language of your choice. For fundamental local data structures (stack, queues, priority queues, etc.), you may call functions for the basic operations without writing the actual code.
b) State in BIG-THETA (Q) terms the worst case runtime of your routine. Your answer should be the best description as a function of n and m. Note the fundamental local data structure implementations if they affect the result. Justify your answer.
Describe as precisely as possible the containment and equality relationships among the following complexity classes. Clearly distinguish between proved relationships and generally assumed relationships, and briefly justify your reasoning.
PSPACE, Turing-Recognizable (or Turing-Acceptable), NP, Decidable, NPSPACE, P, NP-Complete