NEW
Font size
WorksheetsCode Master - CN
Total questions: 53
Worksheet time: 29mins
What is the purpose of the `#include <stdio.h>` directive in C?
To include standard input/output functions
To define a macro
To include math functions
To include string manipulation functions
What is the output of `printf("%d", sizeof(char))`
1
2
4
depends on compiler
Which sorting algorithm has the worst-case time complexity of O(n^2)
Merge Sort
Quick Sort
Bubble Sort
Insertion Sort
In a binary search tree (BST), what is the maximum number of children a node can have?
3
2
1
undefined
What does FIFO stand for?
First In, First Out
First Input, First Output
First In, First Ordered
First Index, First Out
Which of the following data structures is not linear
Array
Linked List
Stack
Tree
What is the output of `print("hello" + 3)` in Python
hello3
hellohellohello
Error
None of the above
What does the `pop()` method do on a Python list
Removes the last element from the list and returns it
Adds an element to the end of the list
Returns the index of the specified element
Sorts the list in ascending order
Which of the following is not a valid way to open a file in Python
open("file.txt", "r")
open("file.txt", "write")
open("file.txt", "a")
open("file.txt", "rb")
Which of the following is not a valid data type in C
float
boolean
char
double
What is the purpose of the `sizeof` operator in C
Returns the size of a variable in bytes
Returns the value of a variable
Returns the address of a variable
None of the above
What is the main advantage of using a hash table
Constant time insertion and deletion
Constant time search
Constant time sorting
Constant time access
In a priority queue implemented using a binary heap, what is the time complexity of extracting the maximum element?
O(1)
O(log n)
O(n)
O(n log n)
Which of the following is not a type of tree
Binary Tree
AVL Tree
Linked Tree
B-tree
Which data structure follows the Last In, First Out (LIFO) principle
Queue
Stack
Linked List
Tree
What is the time complexity of inserting an element at the end of a dynamic array (assuming no resizing is needed)
O(1)
O(log n)
O(n)
O(n^2)
What is the output of `print(10 / 3)` in Python
3.3333
3
3.0
Error
What does the `len()` function return in Python
Number of elements in a list
Length of a string
Number of keys in a dictionary
All of the above
What is the output of `3 * 'abc'` in Python
abcabcabc
abcabc
abc
Error
Which of the following is an immutable data type in Python
List
Dictionary
Tuple
Set
How is Level-1 ?
Dead Easy 😆
Yup!!! Can do it!! 😌
Hard 😱
Why do you ask such questions ? 😠
What is the output of the following C code snippet :
#include <stdio.h>
int main() {
int x = 5;
printf("%d", x++);
return 0;
}
5
6
4
Error
In Python, which of the following is a correct way to comment a single line of code
// This is a comment
# This is a comment
/* This is a comment */
-- This is a comment
What is the correct syntax to open a file named "example.txt" for reading in Python
open("example.txt", "r")
open("example.txt", "w")
open("example.txt", "a")
open("example.txt", "rb")
What will be the output of the following Python code?
x = [1, 2, 3]
y = x
y.append(4)
print(x)
[1, 2, 3]
[1, 2, 3, 4]
[1, 2, 3, 4, 4]
Error
Which of the following is not a valid data type in C
float
double
string
unsigned char
Consider the following C code snippet:
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[5]);
return 0;
}
What will be the output of this code?
5
4
Error
Undefined
Which of the following statements is true about Python lists?
Lists cannot store different data types.
Lists are immutable.
Lists can contain duplicate elements.
Lists are accessed using curly braces `{}
In C, what does the `sizeof()` operator return?
The size of the variable
The size of the data type
The number of elements in an array
The address of the variable
What is the correct way to declare a function in Python
function myFunction():
define myFunction():
def myFunction():
def my_function(x :
What will be the output of the following code snippet?
public class Main {
public static void main(String[] args) {
String str1 = "hello";
String str2 = new String("hello");
System.out.println(str1 == str2);
}
}
true
false
Compilation Error
Runtime Error
Which of the following is a correct way to initialize an empty list in Python?
list = {}
list = []
list = [None]
list = None
What will be the output of the following C code?
#include <stdio.h>
int main() {
int x = 0;
for (; x < 5; x++) {
printf("%d", x);
}
return 0;
}
01234
12345
54321
00000
What will be the output of the following C code
#include <stdio.h>
int main() {
int x = 5;
if (x == 5)
printf("Hello");
else
printf("World");
return 0;
}
Hello
World
HelloWorld
No output
In C, what is the output of the following code snippet?
#include <stdio.h>
int main() {
int x = 10;
int *ptr = &x;
printf("%d", *ptr);
return 0;
}
10
error
garbage values
Address of x
What will be the output of the following Python code?
def foo(x, y=[]):
y.append(x)
return y
print(foo(1))
print(foo(2))
[1] [2]
[1, 2] [2]
[1] [1, 2]
[1] [1] [2] [2]
How is Level-2?
Dead Easy 😆
Yup!!! Can do it!! 😌
Hard 😱
Why do you ask such questions ? 😠
What will be the output of the following C code?
#include <stdio.h>
int main() {
int x = 5;
int *ptr = &x;
printf("%d", *ptr++);
return 0;
}
5
6
Error
Undefined
Which of the following statements about linked lists is true
They have constant-time access to arbitrary elements.
They use contiguous memory allocation.
They have O(n) time complexity for both insertion and deletion operations.
They cannot be traversed in reverse.
What is the time complexity of binary search in the worst case?
O(1)
O(log n)
O(n)
O(n^2)
Which sorting algorithm has the best worst-case time complexity?
Bubble Sort
Merge Sort
Quick Sort
Insertion Sort
What does the following C code do?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
int *ptr = arr + 2;
printf("%d", *ptr);
return 0;
}
Prints 1
Prints 2
Prints 3
Prints 4
What is the output of the following Python code?
x = 5
y = 7
z = x if x > y else y
print(z)
5
7
Error
None
What is the time complexity of searching in a hash table with chaining
O(1)
O(log n)
O(n)
O(n^2)
What will be the output of the following C code?
#include <stdio.h>
int main() {
char str[] = "Hello";
printf("%c", str[5]);
return 0;
}
Error
Undefined
Space
Null Character
Which of the following data structures uses dynamic memory allocation?
Which of the following statements about binary trees is true?
What will be the output of the following code snippet?
public class Main {
public static void main(String[] args) {
int x = 5;
System.out.println(x++ + ++x);
}
}
10
11
12
13
Which of the following functions could be used with filter() to remove all negative numbers from a list?
lambda x: x < 0
lambda x: x == 0
lambda x: x > 1
lambda x: x % 2 == 0
What is the output of the following code?
from functools import reduce
lst = [1, 2, 3, 4, 5]
result = reduce(lambda x, y: x + y, lst)
print(result)
15
20
120
30
What is the time complexity of inserting an element into a heap?
O(1)
O(log n)
O(n)
O(n^2)
What will be the output of the following Python code?
def my_func(x):
if x > 0:
return "Positive"
elif x < 0:
return "Negative"
else:
return "Zero"
print(my_func(0))
How is Code Master ?
Not Bad
🙂
Good
✌🏻
Exciting
🎉
Super Exciting
🥳🎉💃🏻
