DAA Viva Questions
DAA Viva Questions
An algorithm is a well-defined computational procedure that takes some values or the set of
values, as an input and produces a set of values or some values, as an output.
What is the Complexity of Algorithm?
The complexity of the algorithm is a way to classify how efficient an algorithm is compared
to alternative ones. Its focus is on how execution time increases with the data set to be
processed. The computational complexity of the algorithm is important in computing.
It is very suitable to classify algorithm based on the relative amount of time or relative
amount of space they required and specify the growth of time/ space requirement as a
function of input size.
Time complexity
Time complexity is a Running time of a program as a function of the size of the input.
Space complexity
Space complexity analyzes the algorithms, based on how much space an algorithm needs to
complete its task. Space complexity analysis was critical in the early days of computing
(when storage space on the computer was limited).
Nowadays, the problem of space rarely occurs because space on the computer is broadly
enough.
We achieve the following types of analysis for complexity
Worst-case: f(n)
It is defined by the maximum number of steps taken on any instance of size n.
Best-case: f(n)
It is defined by the minimum number of steps taken on any instance of size n
Average-case: f(n)
It is defined by the average number of steps taken on any instance of size n.
5) What are the Asymptotic Notations?
Asymptotic analysis is used to measure the efficiency of an algorithm that doesn't depend on
machine-specific constants and prevents the algorithm from comparing the time taking
algorithm. Asymptotic notation is a mathematical tool that is used to represent the time
complexity of algorithms for asymptotic analysis.
The three most used asymptotic notation is as follows.
θ Notation
θ Notation defines the exact asymptotic behavior. To define a behavior, it bounds functions
from above and below. A convenient way to get Theta notation of an expression is to drop
low order terms and ignore leading constants.
The Big O notation bounds a function from above, it defines an upper bound of an algorithm.
Let's consider the case of insertion sort; it takes linear time in the best case and quadratic time
in the worst case. The time complexity of insertion sort is O(n2). It is useful when we only
have upper bound on time complexity of an algorithm.
Ω Notation
Just like Big O notation provides an asymptotic upper bound, the Ω Notation provides an
asymptotic lower bound on a function. It is useful when we have lower bound on time
complexity of an algorithm.
6. Specify the algorithms used for constructing Minimum cost spanning tree.
a) Prim’s Algorithm
b) Kruskal’s Algorithm
The order of growth of an algorithm provides a rough estimate of the amount of time needed
to execute a computer program as the size of the input variable increases. The order of
growth does not take into account the constant factor that is required for fixed operations.
Instead, it emphasizes the operations that expand in proportion to the input size.
Bubble sorting involves splitting the list into two parts. They are sorted and unsorted. The
smallest item in a sublist that hasn't been sorted is "bubbled." When the smallest piece of the
wall is shifted, the entire wall shifts forward one space. The idea behind bubble sort was to
highlight the item at the top of the list in a giant bubble. It does not matter if the highest or
lowest item is bubbled. In this variant, two adjacent components are switched around based
on a comparison. Since bubble sort performs a full array check, sorting a record with n
elements can take up to n-1 iterations.
The Quicksort algorithm relies on division to sort the data. The term "partition exchange
sorting" is also used to refer to this technique in some contexts. The quick sort algorithm
involves picking one item from an array and then rearranging the rest of the data so that it
revolves around that item. This item caused the initial list to be divided in half. The "pivot" is
the currently chosen option. Any items whose values are less than the pivot are shifted to the
left, and those whose values are more significant than the pivot are shifted to the right when
the pivot is selected. Until sub-lists containing only one item are found, selecting a pivot and
dividing the list is repeated in a while loop.
Data Access Arrangements (DAAs) connect a computer and modem to a public telephone
network. DAAs, called TLICs, are telephony line interface circuits (or Modules).
Binary search is superior to linear search. On a non-sorted data structure, however, it cannot
be tested. The basis of binary search is the divide-and-conquer tactic. The binary search starts
by testing the central element of the array's data. Doing this can determine whether a specific
event or piece of information occurs in the first or second half. We do not need to check the
second half if the object is found in the first half and vice versa if it is discovered in the
second half.
In both selection and bubble sorts, items are interchanged. In contrast, insertion sort does not
exchange items. Like card insertion, the item is inserted into the insertion sort at the
appropriate location.