**DOWNLOAD FREE PDF** **<<CLICK HERE>>**

## Data Structure Questions and Answers-Search an Element in an Array using Recursion

Congratulations - you have completed *Data Structure Questions and Answers-Search an Element in an Array using Recursion*.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%

Your answers are highlighted below.

Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Which of the following techniques can be used to search an element in an unsorted array?

Iterative linear search | |

Recursive binary search | |

Iterative binary search | |

All of the mentioned |

Question 1 Explanation:

Iterative linear search can be used to search an element in an unsorted array.

Note: Binary search can be used only when the array is sorted.

Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Consider the array {1, 1, 1, 1, 1}:

Which of the following techniques can be used to search an element in the above array?

Iterative linear search | |

Recursive linear search | |

Recursive binary search | |

All of the mentioned |

Question 2 Explanation:

All of the above mentioned techniques can be used to search an element in the above array.

Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

What does the following code do?

#include<stdio.h> int search....num(int *arr, int num, int len) { int i; for(i = 0; i < len; i++) if(arr[i] == num) return i; return -1; } int main() { int arr[5] ={1, 2, 3, 4, 5}, num=3, len = 5; int indx = search....num(arr, num, len); printf("Index of %d is %d", num, indx); return 0; }

Finds the index of all the occurrences of the number that is searched | |

Finds the index of the first occurrence of the number that is searched | |

Finds the index of the last occurrence of the number that is searched | |

None of the mentioned |

Question 3 Explanation:

The code finds the index of the first occurrence of the number that is searched.

Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

What is the output of the following code?

#include<stdio.h> int search....num(int *arr, int num, int len) { int i; for(i = 0; i < len; i++) if(arr[i] == num) return i; return -1; } int main() { int arr[5] ={1, 3, 3, 3, 5}, num=3, len = 5; int indx = search....num(arr, num, len); printf("Index of %d is %d", num, indx); return 0; }

Index of 3 is 0 | |

Index of 3 is 1 | |

Index of 3 is 2 | |

Index of 3 is 3 |

Question 4 Explanation:

The program prints the index of the first occurrence of 3, which is 1.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

What is the time complexity of the above code used to search an element in an array?

O(1) | |

O(n) | |

O(n ^{2}) | |

O(n ^{3}) |

Question 5 Explanation:

The time complexity of the above code used to search an element in an array is O(n).

Once you are finished, click the button below. Any items you have not completed will be marked incorrect.

There are 5 questions to complete.