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

C Sharp (programming language) wikipedia , lookup

Go (programming language) wikipedia , lookup

Sieve of Eratosthenes wikipedia , lookup

Program optimization wikipedia , lookup

Corecursion wikipedia , lookup

Travelling salesman problem wikipedia , lookup

Genetic algorithm wikipedia , lookup

K-nearest neighbors algorithm wikipedia , lookup

Recursion (computer science) wikipedia , lookup

Selection algorithm wikipedia , lookup

Fast Fourier transform wikipedia , lookup

Fisher–Yates shuffle wikipedia , lookup

Operational transformation wikipedia , lookup

Quicksort wikipedia , lookup

Smith–Waterman algorithm wikipedia , lookup

Simplex algorithm wikipedia , lookup

Factorization of polynomials over finite fields wikipedia , lookup

Algorithm wikipedia , lookup

Algorithm characterizations wikipedia , lookup

Transcript
CUSTOMER_CODE
SMUDE
DIVISION_CODE
SMUDE
EVENT_CODE
SMUJAN15
ASSESSMENT_CODE MIT203_SMUJAN15
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
13757
QUESTION_TEXT Explain the concepts algorithm, program and psuedocode
SCHEME OF
EVALUATION
An algorithm is a finite set of unambiguous statement to solve a
problem in finite amount of time. It can be natural language
expressions designed for any common man.(2 marks)
A program can be called as an algorithm implemented using the
required data structures. It is the expression of an algorithm in a
programming language with all the language specific coded.
Procedure, function and subroutine are synonyms for a program.(2
marks)
A pseudocode is a compact, informal environment-independent
description of a computer programming algorithm. It uses the
structural conventions of a programming language, but only humans
can read it and not machines. Pseudocode omits details that are not
essential for human understanding of the algorithm, such as variable
declarations, system-specific code and subroutines. There is no
specific standard for pseudocode syntax (4 marks)
Consider the example of bubble sort, which is a straightforward and
simplistic method of sorting an array of numbers. (2 marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
13759
QUESTION_TEXT Describe the Analysis of prefixAvg1 algorithm?
SCHEME OF
EVALUATION
Analysis of the algorithm prefixAvg1 helps us to make the following
deductions:
Initiating the array N at the beginning of the algorithm and returning it
at the end is done with a constant number of primitive operations and
takes O(n) time.(2 marks)
In the algorithm, p and q are the counter variables that control the two
nested ‘for loops’. The outer ‘for loop’ which has the counter p
executes for n times, (for p = 0 to n – 1). Therefore the statements b =
0 and N[p] = b/(p – 1) also execute n times. This means that the two
statements and the testing and incrementing of counter p corresponds
to the number of primitive operations and takes O(n) time.
(2 marks)
The inner ‘for loop’ which has the counter q executes for p + 1 times
depending on the present value of the counter p of outer for loop.
Therefore the statement b = b+M[p] executes n (n + 1)/2 times which
means that it corresponds to two primitive operations, incrementing
and testing, and takes O(n 2) times.(2 marks)
The sum of three terms where the first and the second term are O(n)
and the third term is O(n 2) gives the running time of the algorithm
prefixAvg1. Therefore the running time of the algorithm prefixAvg1 is
O(n 2).(4 marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
72457
QUESTION_TEXT Explain the time efficiency of non-recursive algorithms
SCHEME OF
EVALUATION
Time efficiency approximation depends on the type of definition that is
needed to describe the steps involved in an algorithm. The time
required to perform a step should always bound above by a constant. In
some instances, count of addition of two numbers might be as one step.
In such cases approximation of time efficient becomes critical. This
consideration might not justify certain situations. If the numbers
involved in a computation are randomly large, then the time required
for performing single addition is no longer considered as constant. (5
marks)
The steps involved in mathematical analysis of non-recursive
algorithms are
 Decide the parameter n based on the input size
 Identify the basic execution of algorithm
 Determine the worst, average, and best case for the size of input
(n)
 Set up a sum for C(n) which represents the loop structure of the
algorithm
 Simplify the sum using standard formulas (5 marks)
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
119099
QUESTION_TEXT
What are the rules to be kept in mind while deciding on using
recursion?
1.
We can use recursion if the problem definition requires a
recursive solution, provided it follows the next point.
SCHEME OF
EVALUATION
2.
We have to analyze the time and memory space of the
recursive solution. If we can solve it using a non recursive way, with
lesser time and space then go for it
3.
Do not use lots of recursion to solve a single problem. It
becomes complex to track every sub solution.
4.
If we get a small and elegant recursion, then go for it.
5.
A recursive function with its last line as a recursive call,
does not waste lots of memory. We can use this optimized way to
write a recursive function.
(2*5 = 10M)
QUESTION_TYPE DESCRIPTIVE_QUESTION
QUESTION_ID
119102
QUESTION_TEXT Explain the Floyd’s algorithm to find the shortest path.
Floyd’s algorithm (2 marks)
Tracing of Floyd’s algorithm (2 marks)
Explanation of Floyd’s algorithm with an example (6 marks)
We can generate the distance matrix with an algorithm that is very
similar to Warshall's algorithm. It is called Floyd's algorithm, after its
inventor R. Floyd. It is applicable to both undirected and directed
'weighted graphs provided that they do not contain a cycle of negative
length.
SCHEME OF
EVALUATION
The all-pairs-shortest paths problem asks to find the distances from
each vertex to all other vertices in a weighted connected graph. For our
convenience to record the lengths of the shortest paths we use an n x n
matrix D called the distance matrix. The element dg in the ith row and
the jth column of this matrix indicates the length of the shortest path
from the ith vertex to the jth vertex (1<= i, j <= n).
QUESTION_TYPE
DESCRIPTIVE_QUESTION
QUESTION_ID
169007
QUESTION_TEXT
Explain the 6 steps of analyzing the efficiency of recursive algorithm
1) Decide the size of the input based on a parameter n.
2) Identify and analyze the basic operations of the recursive
algorithm.
3) Determine the number of times the basic operations are used.
Check whether the basic operations require more size than the
decided input size n.
SCHEME OF
EVALUATION
4) Determine the best, worst and average cases for the input size
n.
We have to analyze the cases separately if the basic operations
depend on it.
5) To solve the basic operation, set a recurrence relation.
6) Solve the recurrence relation using the forward and backward
substitution method. We can prove the solution using mathematical
induction.