Download CUSTOMER_CODE SMUDE DIVISION_CODE SMUDE

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Linked list wikipedia , lookup

Lattice model (finance) wikipedia , lookup

Red–black tree wikipedia , lookup

Quadtree wikipedia , lookup

B-tree wikipedia , lookup

Interval tree wikipedia , lookup

Binary search tree wikipedia , lookup

Transcript
CUSTOMER_CODE
SMUDE
DIVISION_CODE
SMUDE
EVENT_CODE
Jan2017
ASSESSMENT_CODE MC0068_Jan2017
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
33835
QUESTION_TEXT
What is linked list? Explain the basic linked list operations.
SCHEME OF
EVALUATION
A linked list is a collection of records called nodes, each containing at least one field
that gives the location of the next node in the list.
The linked list is a very flexible dynamic data structure. It is a low level structure upon
which high level data structure can be built.
3 marks
1. Create: Makes a new linked list
2. Insert: Puts a new node in its place in the list.
3. Remove : Remove a node from the list
4. Traverse: This function allow user to visit each node in the list. (The purpose of
the visit is defined by the list user and it is certain to vary from application to
application)
5. isEmpty : This function returns a true/false indication of whether or not there are
any nodes in the list.
6. isFull: This function return a true/falseindication of whether or not the list is
full.(When the data structure is static, this operation may perform a test. In the typical
dynamic list, it simply returns false).
7 marks
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
33836
QUESTION_TEXT
Explain the following concepts with its algorithm.
a. Relaxation of edges
b. Dijkstra Algorithm
SCHEME OF
EVALUATION
Relaxation: The relaxation process updates the costs of all the vertices, v, connected to
a vertex u, if we could improve the best estimate of the shortest path to v by including
(u,v) in the path to v. The relaxation procedure proceeds as follows:
Initialize_single_source(Graph G, Node s) (1 mark)
For each vertex v in Vertices (G)
G.d[v]:=infinity
G.pi[v]:=nil
G.d[s]:=0
This sets up the graph so that each node has no predecessor (pi[v]=nil) and the
estimates of the cost of each node from the source (d[v]) are infinite, except for the
source node itself(d[s]=0). The relaxation procedure checks if the current best estimate
of the shortest distance to v (d[v]) can be improved by going through u.
(2 marks)
Relax(Node u, Node v, double w[ ] [ ])
If d[v] >d[u]+w[u,v] then
d[v]:=d[u]+w[u,v]
piv]:=u (2 marks)
Dijkstra Algorithm: This solves the problem of finding the shortest path from a point in
a graph to adestination. It is also called single source shortest path problem. This
algorithm keeps two sets of vertices: S (set of vertices whose shortest paths from the
source have already beed determined) and V-S (remaining vertices). The other data
structures needed are: d(array of best estimates of shortest path to each vertex) and pi
(array of predecessors for each vertex) (2 marks)
The basic mode of operation is :
1. Initialise d and pi
2. Set S to empty
3. While there are still vertices in V-S
a. Sort the vertices in V-S according to the current best estimate of their distance from
source
b. Add u, the closest vertex in V-S, to S.
c. Realx all the vertices still in V-S connected to u
(2 marks)
DIJKSTRA(Graph G, Node s)
Initialise_single_source(G,s)
S:={0} //Make S empty
Q:=Vertices(G)
While not empty(Q)
u:=ExtractMin(Q)
Addnode(S,u)
For each vertex v adjacent to u
Relax(u,v,w) (1 mark)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
33837
QUESTION_TEXT
Explain the following algorithms.
a. Bellman-Ford Algorithm
b. Single Source shortest paths in a DAG
c. Floyd Warshall algorithm
SCHEME OF
EVALUATION
Bellman-Ford algorithm: This is a more generalized single-source shortest path
algorithm which can find the shortest path in a graph with negative weighted edges. If
there is no negative cycle in the graph, this algorithm will update each d[v] with the
shortest path from s to v, fill up the predecessor list pi and return TRUE. However, if
there is a negative cycle in the given graph, this algorithm will return FALSE. (1 mark)
BELLMAN_FORD(Graph G, double w[][], Node s)
Initialise_single_source(G,s)
For i=1 to |V[G]|-1
For each edge (u,v) in E[G]
Relax(u,v,w)
For each edge (u,v) in E[G]
If d[v] >d[u]+w(u,v) then
Return FALSE
Return TRUE (2 marks)
Single Source shortest path in DAG:
There exisits a more efficient algorithm O(V+E) for solving Single Source shortest path
in DAG. So if we are sure that the graph is a DAG, then we may consider this algorithm.
(1 mark)
DAG_SHORTEST_PATHS (Graph G, double w[][], Node s)
Topologically sort the vertices of G
Initialise_single_source(G,s)
For each vertex u taken in topologically sorted order
For each vertex v adjacent to u
Relax(u,v,w) (2 marks)
Floyd Warshall Algorithm:
Given a directed graph, this algorithm computes the shortest path between each
pair of nodes in O(n^3)
Given:
w :edge weights
d: distance matrix
p: predecessor matrix
w[i][j]=length of direct edge between i and j
d[i][j]= length of shortest path between i and j
p[i][j]=on a shortest path from I to j, p[i][j] is the last node beforej
Initialization:
for (i=0;i< n;i++)
for (j=0;j< n;i++)
{
d[i][j]=w[i][j]
p[i][j]=i;
}
For (i=0;i< n;i++)
d[i][j]=0; (2 marks)
The Algorithm:
For (k=0;k< n;k++)
For (i=0;i< n;i++)
For (j=0;j< n;j++)
If(d[i][k]+d[k][j]< d[i][j])
{
d[i][j]=d[i][k]+d[k][j]
p[i][j]=p[k][j]
}
(2 marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
73874
QUESTION_TEXT
Explain the various other operations performed by binary search tree.
SCHEME OF
EVALUATION
i. To find maximum value in a tree BST: a node with max value is obtained by
traversing and the right most node in the tree. (2 marks)
ii. To find minimum value in a BST: Given a binary search tree, a node with least
value is obtained by traversing and obtaining the let most node in the tree (2
marks)
iii. Height of tree: Height of the tree is nothing but the maximum level in a tree
plus one. (2 marks)
iv. Count nodes in a tree: The number of nodes in the tree is obtained by
traversing the tree in any of the traversal technique. (2 marks)
v. Count leaves in a tree: A leaf or a terminal node is one which has an empty left
and empty right child. (2 marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
73875
QUESTION_TEXT
Define path. Explain graph representations
SCHEME OF EVALUATION
Path (2 marks)
a. Edge list (2 marks)
b. Adjacency matrix (2 marks)
c. Adjacency list (2 marks)
d. Implicit representation (2 marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
108225
QUESTION_TEXT
Give the applications of stack.
Function calls: (2 marks)
Large number arithmetic (3 marks)
Evaluation of Arithmetic expressions (5 marks)
SCHEME OF EVALUATION - infix
- postfix
- prefix
(Each point has to be explained with example)