Algorithms MCQ Quiz in తెలుగు - Objective Question with Answer for Algorithms - ముఫ్త్ [PDF] డౌన్‌లోడ్ కరెన్

Last updated on Mar 11, 2025

పొందండి Algorithms సమాధానాలు మరియు వివరణాత్మక పరిష్కారాలతో బహుళ ఎంపిక ప్రశ్నలు (MCQ క్విజ్). వీటిని ఉచితంగా డౌన్‌లోడ్ చేసుకోండి Algorithms MCQ క్విజ్ Pdf మరియు బ్యాంకింగ్, SSC, రైల్వే, UPSC, స్టేట్ PSC వంటి మీ రాబోయే పరీక్షల కోసం సిద్ధం చేయండి.

Latest Algorithms MCQ Objective Questions

Top Algorithms MCQ Objective Questions

Algorithms Question 1:

What will be the output of the following code?

def linearSearch(list, key):

    for index in range(0,len(list)-1):

        if list[index] == key:

            return index+1

    return None

 

list1 = [19, 32, 45, 56, 77, 89]

n = 89

pos = linearSearch(list1,n)

if pos is None:

    print (n,"is not found in the list")

else:

    print( n,"is found at position", pos)

  1. 89 is found at position 5

  2. 89 is found at position 6
  3. 89 is found at position 7
  4. 89 is not found in the list

Answer (Detailed Solution Below)

Option 4 : 89 is not found in the list

Algorithms Question 1 Detailed Solution

Correct answer: Option 4

Explanation:

  • The program contains a logical error in the 2nd line.
  • The range of the loop is specified from 0 to len(list)-1.
  • The range function goes up to 1 less than the given upper limit.
  • As a result, the loop in the given program runs from index values 0 to 4, because len(list) returns a value 6.
  • The value 89 is located at index value 5. Since the loop never reaches that location, it terminates the loop and returns None to the calling function. Therefore, the program outputs that the value is not found in the list.
  • If the erroneous statement is corrected, the program will output that the value 89 is found at position 6.

Algorithms Question 2:

The given statements are:

Statement 1: The amount of space an algorithm takes to process a given data, can be called its time complexity.

Statement 2: The algorithms whose time complexity is n2 are also known as Quadratic time algorithms.

  1. Statement 1 is false and Statement 2 is false.
  2. Statement 1 is false and Statement 2 is true.
  3. Statement 1 is true and Statement 2 is true.
  4. Statement 2 is false and Statement 1 is true.

Answer (Detailed Solution Below)

Option 2 : Statement 1 is false and Statement 2 is true.

Algorithms Question 2 Detailed Solution

Let's analyze the Statements in detail - 

Statement 1 - The amount of time that an algorithm takes to complete its execution or to process the data is called Time complexity, ( In ques is defined as Space complexity, Not time complexity. )Time complexity is determined mainly by the loop execution time rest of the process takes smaller time than loop execution  Space complexity is the stack space taken by the program to run or complete its execution. So, this statement is FALSE. 

Statement 2 - Quadratic time algorithms are those algorithms in which The timely execution of an algorithm is directly proportional to the square size of the input size. 
Here, n is the number of elements ( input size ). Quadratic time algorithms are much faster than the Linear ones ( For the bigger value of n ) 

Example of quadratic time complexity - When 2 nested loop runs simultaneously in a program. So, this statement is true. 

So, Statement 1 is False and Statement 2 is True, and option 2 turns out to be the correct answer. 
 

Algorithms Question 3:

In python, Fill the following black in the given binary search algorithm?

Consider array is Arr, size of the array is n, and searching element is target

def binarySearch(Arr, n, target) :
start, end = 0, n-1
while start <= end :
mid = (start + end) / 2
if Arr[mid] == target :
return  ____________ ? 
elif Arr[mid] < target :
start = _____________ ?
else :
end = mid - 1;
return -1

  1. mid,  mid + 1
  2. mid, mid-1
  3. mid, start
  4. mid, end

Answer (Detailed Solution Below)

Option 1 : mid,  mid + 1

Algorithms Question 3 Detailed Solution

The correct answer is option 1.
Concept:
Binary Search:
Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half.
Explanation:
The given python code is,
Binary search example in Python here Arr is an of integer type, n is the size of array and target is an element to be found.
def binarySearch(Arr, n, target) :
Here set stating and ending index is 0 and n-1 respec
start, end = 0, n-1
while start <= end :
mid = (start + end) / 2
Here if we found a match in the middle then searching is successful.
if Arr[mid] == target :
return mid
Here if the middle element is less than the searching element then go to the right side. Hence the starting index is mid+1.
elif Arr[mid] < target :
start = mid + 1
Here if the middle element is greater than the searching element then go to the left side. Hence the ending index is mid-1.
else :
end = mid - 1;
If we can not able search the element then the element is not present in the list.
return -1
Hence the correct answer is mid,  mid + 1.

Algorithms Question 4:

In the Optimized bubble sort algorithm, If there are no swaps then the array becomes in sorted order. Fill the below blank to run the Optimized bubble sort algorithm behaviour.

def bubble_sort(array):
  for i in range(len(array)):
    swapped = False
    for j in range(0, len(array) - i - 1):
      if array[j] > array[j + 1]:
        temp = array[j]
        array[j] = array[j+1]
        array[j+1] = temp
        swapped = True
    if not swapped:
      ________________ ?
data = [-2, 45, 0, 11, -9]
bubble_sort(data)
print(data)

  1. break
  2. go to
  3. continue
  4. return 0

Answer (Detailed Solution Below)

Option 1 : break

Algorithms Question 4 Detailed Solution

The correct answer is option 1.

Concept:

The correct answer is option 1.

Concept:

The code is an optimized bubble sort algorithm. It means if there are no swaps then the array is in sorted order. Hence it can not perform any iterations or passes.

Explanation:

The given python code is an Optimized Bubble sort in Python.

def bubble_sor(array):   
Here loop through each element of the array.
  for i in range(len(array)):     
Here is swapped variable is true it keeps track of swapping
    swapped = False
Here is the loop to compare array elements.
    for j in range(0, len(array) - i - 1):

Here compare two adjacent elements change > to < to sort in descending order
      if array[j] > array[j + 1]:

Here swapping occurs if elements are not in the intended order.
        temp = array[j]
        array[j] = array[j+1]
        array[j+1] = temp

        swapped = True    
Here no swapping means the array is already sorted so no need for further comparison.
    if not swapped:
      break

The driver code or the main function call  from here:

data = [-2, 45, 0, 11, -9]

bubble_sor(data)

Here is the array Sorted Array in Ascending Order.
print(data)

Note:

go to, continue or return 0 will not work and it can not break the loop when there is no swaps in the previous iterations.

Hence the correct answer is break.

Algorithms Question 5:

What is output for the given python code.

def test(array):
  for i in range(len(array)):
    swapped = False
    for j in range(0, len(array) - i - 1):
      if array[j] > array[j + 1]:
        temp = array[j]
        array[j] = array[j+1]
        array[j+1] = temp
        swapped = True
    if not swapped:
      break
data = [-2, 45, 0, 11, -9]
test(data)
print(data)

  1. [-9, -2, 0, 11, 45]
  2. [45, 11, 0, -2, -9]
  3. [-45, -11, -9, -2, 0]
  4. [45, 11, 9, 2, 0]

Answer (Detailed Solution Below)

Option 1 : [-9, -2, 0, 11, 45]

Algorithms Question 5 Detailed Solution

The correct answer is option 1.

Concept:

The code is an optimized bubble sort algorithm. It means if there are no swaps then the array is in sorted order. Hence it can not perform any iterations or passes.

Explanation:

The given python code is an Optimized Bubble sort in Python

def test(array):   
Here loop through each element of the array.
  for i in range(len(array)):     
Here is swapped variable is true it keeps track of swapping
    swapped = False
Here is the loop to compare array elements.
    for j in range(0, len(array) - i - 1):

Here compare two adjacent elements change > to < to sort in descending order
      if array[j] > array[j + 1]:

Here swapping occurs if elements are not in the intended order.
        temp = array[j]
        array[j] = array[j+1]
        array[j+1] = temp

        swapped = True    
Here no swapping means the array is already sorted so no need for further comparison.
    if not swapped:
      break

data = [-2, 45, 0, 11, -9]

test(data)

Here is the array Sorted Array in Ascending Order.
print(data)

Hence the correct answer is [-9, -2, 0, 11, 45]

Algorithms Question 6:

What is the expected output for the given python code ?

def test(array, size):
    for step in range(size):
        min_idx = step
        for i in range(step + 1, size):
            if array[i] < array[min_idx]:
                min_idx = i
        (array[step], array[min_idx]) = (array[min_idx], array[step])
data = [12, 34,-2, 45,1, -25]
size = len(data)
test(data, size)
print(data)

  1. It uses selection sort technique and prints in descending sorted order
  2. It uses selection sort technique and prints in ascending sorted order
  3. It uses selection sort technique and prints ONLY positive number ascending sorted order
  4. It uses selection sort technique and prints ONLY negative number ascending sorted order

Answer (Detailed Solution Below)

Option 2 : It uses selection sort technique and prints in ascending sorted order

Algorithms Question 6 Detailed Solution

The correct answer is option 2.

Concept:

The given python code is a selection sort technique and prints in ascending sorted order.

Explanation:

def test(array, size):
    for step in range(size):
        min_idx = step

        for i in range(step + 1, size):

Here, It sort in descending order, change > to < in this line select the minimum element in each loop
            if array[i] < array[min_idx]:
                min_idx = i
         
 Here, It put min at the correct position
        (array[step], array[min_idx]) = (array[min_idx], array[step])


data = [12, 34,-2, 45,1, -25]
size = len(data)
test(data, size)
Here, Sorted Array in Ascending Order.
print(data)

The output is, 

[-25, -2, 1, 12, 34, 45]

Option 2: It uses the selection sort technique and prints in descending sorted order

False, The above algorithm can not prints [45, 34, 12, 1, -2, -25].

Option 3: It uses the selection sort technique and prints ONLY positive numbers ascending sorted order

False, The above algorithm can not print [1, 12, 34, 45].

Option 4:It uses the selection sort technique and prints ONLY negative numbers ascending sorted order.

False, The above algorithm can not print [-25, -2].

Hence the correct answer is It uses the selection sort technique and prints in ascending sorted order.

Get Free Access Now
Hot Links: teen patti master purana teen patti download teen patti - 3patti cards game downloadable content