Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

URGENT PLEASE Section A: Multiple Choice Questions (10 marks, Tick () the correct answer) Q1: Consider searching element 45 using binary search in an array

URGENT PLEASE

Section A: Multiple Choice Questions (10 marks, Tick () the correct answer)

Q1: Consider searching element 45 using binary search in an array A [ ] = { 23, 34, 45, 67, 78, 54, 87, 91 }. The returned index would be

  1. Index [0]
  2. Index [2]
  3. Index [3]
  4. None of these

Q2: In the context of recursive search

  1. Recursion terminates when the item is found
  2. Same function is called again and again
  3. Slower than iterative search
  4. All options are correct

Q3: Which one of the following is an approach for a systematic trial and error to search an item?

  1. Binary search
  2. Backtracking
  3. Recursion
  4. Iteration

Q4: In terms of time efficiency, the following method is ____.

public int function(int n) { int result = 1; for (int k = 1; k <= n; k++) result = result * k; return result; }

  1. O(1)
  2. O(n)
  3. O(n2)
  4. O(n log n)

Q5: Which one of the following do not match with others?

  1. pop
  2. push
  3. enqueue
  4. peek

Q6: The quicksort is being used to sort an array in the ascending order. Which one of the following is not true ?

  1. All the elements in the left subarray are less than or equal to the pivot
  2. All the elements in the right subarray are larger than the pivot
  3. The pivot is placed between the two subarrays
  4. All the elements in the right subarray are less than or equal to the pivot

Q7: Which of the following syntax is true with respect to generic declaration:

  1. methodModifiers returnType methodName(methodParameters)
  2. methodModifiers < > returnType methodName(methodParameters)
  3. methodModifiers returnType methodName (methodParameters)
  4. methodModifiers returnType methodName(methodParameters)

Q8: Given a function f(n) = n2 + 20n on an input parameter n, which of the following is true

  1. f(n)=O(1)
  2. f(n)=O(n)
  3. f(n)=O(logn)
  4. f(n)=O(n3)

Q9: A normal queue, if implemented using an array of size MAX_SIZE, gets full when-

  1. Rear = MAX_SIZE 1
  2. Front = (rear + 1)mod MAX_SIZE
  3. Front = rear + 1
  4. Rear = front

Q10: Consider the given function. The function grows at a __________ rate

public static int search(int[] x, int target) {

for(int i=0; i < x.length; i++) { if (x[i]==target) return i; }

return -1; // target not found

}

  1. Constant
  2. Logarithm
  3. Linear
  4. Quadratic

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

How corrections and modifications are implemented

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago