Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Discuss about Algorithmic complexity and its types?

Answer»

The complexity of an algorithm f(n) gives the running time and/or the storage space required by the algorithm in terms of n as the size of input data.

Time Complexity:

The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.

Space Complexity:

Space complexity of an algorithm is the amount of memory required to run to its completion.

2.

Discuss about Linear search algorithm.?

Answer»

Linear Search:

Linear search also called sequential search is a sequential method for finding a particular value in a list. This method checks the search element with each element in sequence until the desired element is found or the list is exhausted. In this searching algorithm, list need not be ordered.

Pseudo code:

(I) Traverse the array using for loop

(II) In every iteration, compare the target search key value with the current value of the list.

1. If the values match, display the current index and value of the array

2. If the values do not match, move on to the next array element.

(III) If no match is found, display the search element not found. To search the number 25 in the array given below, linear search will go step by step in a sequential order starting from the first element in the given array if the search element is found that index is returned otherwise the search is continued till the last index of the array. In this example number 25 is found at index number 3.

index01234
values1012202530

Example 1:

Input: values[ ] = {5, 34, 65, 12, 77, 35}

target = 77

Output: 4 

Example 2:

Input: values[ ] = {101, 392, 1, 54, 32, 22, 90, 93} 

target = 200

Output: -1 (not found)

3.

List the characteristics of an algorithm?

Answer»

Input, Output, Finiteness, Definiteness, Effectiveness, Correctness, Simplicity, Unambiguous, Feasibility, Portable and Independent.

4.

What is searching? Write its types?

Answer»

A search algorithm is the step-by-step procedure used to locate specific data among a collection of data.

Types of searching algorithms are

1. Linear search

2. Binary search

3. Hash search

4. Binary Tree search

5.

Which one of the following is not an Asymptotic notations?(a) Big(b) Big(c) Big Ω(d) Big ⊗

Answer»

Big ⊗ is not an Asymptotic notations

6.

……… is called performance measurement.(a) A posteriori testing(b) A priori estimates(c) A preposition(d) A post preori

Answer»

(a) A posteriori testing

7.

Which one of the following is a theoretical performance analysis of an algorithm?(a) A posteriori testing(b) A priori estimates(c) A preposition(d) A post preori

Answer»

(b) A priori estimates

8.

Explain the characteristics of an algorithm?

Answer»

1. Input – Zero or more quantities to be supplied.

2. Output – At least one quantity is produced.

3. Finiteness – Algorithms must terminate after finite number of steps.

4. Definiteness – All operations should be well defined. For example operations involving division by zero or taking square root for negative number are unacceptable.

5. Effectiveness – Every instruction must be carried out effectively.

6. Correctness – The algorithms should be error free.

7. Simplicity – Easy to implement.

8. Unambiguous – Algorithm should be clear and unambiguous. Each of its steps and their inputs/outputs should be clear and must lead to only one meaning.

9. Feasibility – Should be feasible with the available resources.

10. Portable – An algorithm should be generic, independent of any programming language or an operating system able to handle all range of inputs. 

11. Independent – An algorithm should have stepby-step directions, which should be independent of any programming code.

9.

Write a note on Asymptotic notation?

Answer»

Asymptotic Notations:

Asymptotic Notations are languages that uses meaningful statements about time and space complexity.

(I) Big O

Big O is often used to describe the worst – case of an algorithm.

(II) Big Ω

Big Omega is the reverse Big O, if Bi O is used to describe the upper bound (worst – case) of a asymptotic function, Big Omega is used to describe the lower bound (best-case). 

(III) Big Θ

When an algorithm has a complexity with lower bound = upper bound, say that an algorithm has a complexity O (n log n) and Ω (n log n), it’s actually has the complexity Θ (n log n), which means the running time of that algorithm always falls in n log n in the best – case and worst – case.

10.

How many asymptotic notations are used to represent time complexity of an algorithms?(a) 1(b) 2(c) 3(d) 4

Answer»

3 asymptotic notations are used to represent time complexity of an algorithms.

11.

Which is true related to the efficiency of an algorithm? (I) Less time, more storage space(II) More time, very little space(a) I is correct(b) II is correct(c) Both are correct(d) Both are wrong

Answer»

(c) Both are correct

12.

Which of the following statement is true?(a) Space Factor is the maximum memory space required by an algorithm(b) Space Factor is the minimum memory spaces required by an algorithm

Answer»

(a) Space Factor is the maximum memory space required by an algorithm

13.

Which search technique is also called sequential search techniques?(a) Binary (b) Binary Tree (c) Hash(d) Linear

Answer»

Linear is also called sequential search techniques

14.

………… describes the worst case of an algorithm. (a) Big Q (b) Big(c) Big O(d) Big C

Answer»

Big O describes the worst case of an algorithm.

15.

How many number of passes are used in the Insertion Sort to get the final sorted list?(a) 0 (b) 1 (c) n(d) n -1

Answer»

Answer is (d) n – 1

16.

…… is the reverse of Big O (a) Big Ω(b) Big(c) Big C(d) Big ⊗

Answer»

Big Ω is the reverse of Big O

17.

Time is measured by counting the number of key operations like comparisons in the sorting algorithm. This is called as ……(a) Space Factor(b) Key Factor(c) Priori Factor(d) Time Factor

Answer»

(d) Time Factor

18.

What is Sorting?

Answer»

Sorting is a method of arranging group of items in an ascending or descending order. Various sorting techniques in algorithms are Bubble Sort, Quick Sort, Heap Sort, Selection Sort, Insertion Sort.

19.

What are the factors that influence time and space complexity?

Answer»

Time Complexity:

The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.

Space Complexity:

Space complexity of an algorithm is the amount of memory required to run to its completion. The space required by an algorithm is equal to the sum of the following two components:

A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm. A variable part is defined as the total space required by variables, which sizes depends on the problem and its iteration. For example: recursion used to calculate factorial of a given value n.

20.

A ……… or …… trade off is a way of solving in less time by using more storage space or by solving a given algorithm in very little space by spending more time.

Answer»

Space – timw, time – memory

21.

Which technique is followed by Binary Search algorithm?(a) Subroutines(b) Mapping (c) Divide and conquer(d) Namespaces

Answer»

(c) Divide and conquer

22.

Which search algorithm is called as Half – Interval search algorithm?(a) Binary(b) Binary Tree(c) Hash(d) Linear

Answer»

Binary is called as Half – Interval search algorithm

23.

………….. describes the lower bound of an algorithm. (a) Big Ω(b) Big(c) Big O(d) Big ⊗

Answer»

Big Ω describes the lower bound of an algorithm.

24.

In selection sort, there will be …… exchange for every pass through the list.(a) 0(b) 1(c) 2(d) 3

Answer»

In selection sort, there will be 1 exchange for every pass through the list.

25.

Which one of the following is not a characteristics of Bubble Sort?(a) Simple(b) Too slow(c) Too fast(d) Less efficient

Answer»

(c) Too fast

26.

…… is a simple sorting algorithm.(a) Binary(b) Bubble(c) Selection(d) Insertion

Answer»

Bubble is a simple sorting algorithm.

27.

The complexity of Bubble Sort is ………

Answer»

The complexity of Bubble Sort is o (n2)

28.

Time complexity of bubble sort in worst case is …….. (a) θ(n) (b) θ(n log n) (c) θ(n2)(d) θ(n(log n)2)

Answer»

Time complexity of bubble sort in worst case is θ(n2)

29.

Match the following.(1) Linear search – (i) o(n ) (2) Binary –(ii) o(n) (3) Bubble Sort –(iii) o(log n) (4) Merge Sort –(iv) o(n log n)(a) 1 – (ii), 2 – (iii), 3 – (i), 4 – (iv)(b) 1 – (i), 2 – (ii), 3 – (iii), 4 – (iv)(c) 1 – (iv), 2 – (iii), 3 – (ii), 4 – (i)(d) 1 – (iv), 2 – (ii), 3 – (i), 4 – (iii)

Answer»

(a) 1 – (ii), 2 – (iii), 3 – (i), 4 – (iv)

30.

……… is an example for dynamic programming approach.(a) Fibonacci (b) Prime (c) Factorial (d) Odd or Even

Answer»

(a) Fibonacci

31.

…….. approach is similar to divide and conquer.

Answer»

Dynamic programming

32.

Design an algorithm to find square of the given number and display the result?

Answer»

Problem: Design an algorithm to find square of the given number and display the result.

The algorithm can be written as:

Step 1 – start the process

Step 2 – get the input x

Step 3 – calculate the square by multiplying the input value ie., square ← x* x

Step 4 – display the result square

Step 5 – stop

Algorithm could be designed to get a solution of a given problem. A problem can be solved in many ways. Among many algorithms the optimistic one can be taken for implementation

33.

What is space – Time Trade off?

Answer»

A space – time or time – memory trade off is a way of solving in less time by using more storage space or by solving a given algorithm in very little space by spending more time.

34.

Define fixed part in the space complexity?

Answer»

A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm.

35.

The word comes from the name of a Persian mathematician Abu Jafar Mohammed ibn – i Musa al Khowarizmi is called?(a) Flow chart(b) Flow(c) Algorithm(d) Syntax

Answer»

(c) Algorithm