Option A. USB Pen technology
Option B. Magnetic Disk Technology
Option C. Media to store video data only
Option D. Optical Disk Technology
True Answer D

Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.

Option A. [x in range(1, 1000) if x%3==0]
Option B. [x for x in range(1000) if x%3==0]
Option C. [x%3 for x in range(1, 1000)]
Option D. [x%3=0 for x in range(1, 1000)]
True Answer B

Explanation :

The list comprehension [x for x in range(1000) if x%3==0] produces a list of numbers between 1 and 1000 that are divisible by 3.

Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.

A. [x in range(1, 1000) if x%3==0][x in range(1, 1000) if x%3==0]

B. [x for x in range(1000) if x%3==0][x for x in range(1000) if x%3==0]

C. [x%3 for x in range(1, 1000)][x%3 for x in range(1, 1000)]

D. [x%3=0 for x in range(1, 1000)][x%3=0 for x in range(1, 1000)]

Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort?

Option A. O(log n)
Option B. O(n)
Option C. O(n log n)
Option D. O(n2)
True Answer B

Explanation :

Given: n number To find: Tighest upper bound on number of swaps required to sort n numbers using selection sort. Analysis: In selection sort, in the unsorted part of the array, we find the minimum element and swap it with the value placed at the index where the unsorted array starts. Hence, for each element to put it in its sorted position, we will do some swaps. In each iteration, when we find the minimum and place it in its sorted position, we do only one swap. There are n such iterations, since maximum number of positions to sort is n. Hence, there are n. 0(1) swaps swaps. The solution is (b)

Which one of the following is the tightest upper bound that represents the number of swaps required to sort n numbers using selection sort?