NEW
Font size
S
M
L
XL
Worksheetscoding skills (ISCP 02) Tuesday slot2 (11am - 1:00pm) CSE E & G
Total questions: 20
Worksheet time: 20mins
Name
Class
Date
1.
What is the outcome of the following code snippet?
int func(int arr[], int n, int target) {
int left = 0;
int right = n - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (arr[mid] == target)
return mid;
else if (arr[mid] < target)
left = mid + 1;
else
right = mid - 1;
}
return -1;
}
a)
Searching for a target element in a sorted array.
b)
Reversing the order of elements in an array.
c)
Sorting an array in ascending order.
d)
Calculating the sum of elements in an array.
2.
What is the best case complexity of insertion sort?
a)
O(n**2)
b)
O(n)
c)
O(nlogn)
d)
O(n**3)
3.
How many variables are required to implement stack using arrays?
a)
1
b)
2
c)
3
d)
4
4.
Stack can be implemented which of the following concepts?
a)
Array
b)
Linked list
c)
Both a and b
d)
Trees
5.
The process of deleting an element into stack is called?
a)
pop operation
b)
push operation
c)
underflow operation
d)
enqueue operation
6.
The postfix form of A*B+C/D is?
a)
*AB/CD+
b)
AB*CD/+
c)
A*BC+/D
d)
ABCD+/*
7.
The process of deleting an element from the queue is called?
a)
pop operation
b)
push operation
c)
enqueue operation
d)
dequeue operation
8.
Which of the data structure follows FIFO principle?
a)
Stack
b)
Queue
c)
Linked list
d)
Tree
9.
Binary search algorithm can be applicable on …
a)
sorted linked list
b)
unsorted linked list
c)
sorted linear array
d)
pointer array
10.
Is Merge sort algorithm inplace sorting algorithm?
a)
yes
b)
no
c)
can't say
d)
All of the above
11.
If the elements of an array are sorted then …… sorting can be efficient.
a)
Insertion
b)
Heap
c)
Selection
d)
Merge
12.
The complexity of selection sort algorithm is …..
a)
O(n)
b)
O(logn)
c)
O(n2)
d)
O(n logn)
13.
Which of the following is not a stable sorting algorithm
a)
Radix sort
b)
Insertion
c)
Heap
d)
Quick
14.
void insertionSort(int arr[], int n) {
for (int i = 1; i < n; i++) {
int key = arr[i];
int j = i - 1;
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = key;
}
}
In the above Code Snippet, if the input array contains 8 elements, what is the total number of comparisons made during the sorting process?
a)
7
b)
14
c)
21
d)
28
15.
If REAR, FRONT are the queue variables, then identify correct statement while inserting a value
a)
FRONT=1
b)
REAR=REAR+1
c)
REAR=REAR-1
d)
FRONT=FRONT-1
16.
Condition to check stack is underflow is?
a)
top==-1
b)
top==0
c)
top==1
d)
top==MAXSIZE
17.
Complexity of Partition technique in quicksort is ……..
a)
O(n)
b)
O(2**n)
c)
O(n**2)
d)
O(logn)
18.
Maximum possible number of swappings in selection sort on an n elemented integer array?
a)
n*(n+1)/2
b)
no
c)
n*(n+1)*(n+2)/2
d)
(n-1)*n*(n+1)/2
19.
Which of the following sorting algorithm is of divide and conquer technique?
a)
Insertion sort
b)
Merge sort
c)
Bubble sort
d)
Selection sort
20.
Condition to check queue is overflow is?
a)
rear==front+1
b)
rear==front
c)
rear==MAXSIZE
d)
rear==MAXSIZE-1
Reset
