wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Quiz

Total questions: 50

Worksheet time: 28mins

Name
Class
Date
1.

Worst- case time complexity of Linear search is

a)

O(1)

b)

O(n)

c)

O(n log n)

d)

O(log n)

2.

What does the sizeof operator in C return?

a)

Size of a variable in bytes

b)

Size of a variable in bits

c)

Number of elements in an array

d)

Length of a string

3.

Which sorting algorithm has the worst-case time complexity of O(n^2)?

a)

All of them

b)

Quick Sort

c)

Bubble Sort

d)

Insertion Sort

4.

What will be the output of the following C code?

a)

1020

b)

2010

c)

2020

d)

Compiler Error

5.

Which traversal method visits the root node, then the left subtree, and finally the right subtree?

a)

Preorder traversal

b)

Inorder traversal

c)

Postorder traversal

d)

Level order traversal

6.

Which year was the C programming language invented?

a)

1968

b)

1971

c)

1972

d)

1973

7.

In a binary tree, what is the maximum number of nodes at level 'k'?

a)

2^(k+1) - 1

b)

k + 1

c)

k

d)

2^k

8.

What is the correct way to allocate memory for an array of 5 integers dynamically in C?

a)

int arr = malloc(5 * sizeof(int));

b)

int arr = malloc(5 * sizeof(int));

c)

int arr[5];

d)

int *arr = malloc(sizeof(int));

9.

How are String represented in memory in C?

a)

An array of characters.

b)

The object of some class.

c)

Same as other primitive data types.

d)

LinkedList of characters.

10.

What will be the output of following C code snippet?

a)

6

b)

8

c)

9

d)

15

11.

Which of the following is the disadvantage of the array?

a)

Stack and Queue data structures can be implemented through an array.

b)

Index of the first element in an array can be negative

c)

Wastage of memory if the elements inserted in an array are lesser than the allocated size

d)

Elements can be accessed sequentially

12.

Difference between break and continue.

a)

break is used to end the program and continue is used for ending the loop

b)

break is used to end a loop and continue skips to the next iteration

c)

break is a keyword and continue is an identifier

d)

None of the above

13.

What is the output of the below code?

a)

10

b)

50

c)

Garbage value

d)

None of the above

14.

Which of the following is true for variable names in C?

a)

They can contain alphanumeric characters as well as special characters

b)

It is not an error to declare a variable to be one of the keywords(like goto, static)

c)

Variable names cannot start with a digit

d)

Variable can be of any length

15.

If the elements '1', '2', '3' and '4' are inserted in a queue, what would be order for the removal?

a)

1234

b)

4321

c)

3241

d)

None of the above

16.

scanf() is a predefined function in____header file.

a)

stdarg. h

b)

stdlib. h

c)

ctype. h

d)

stdio. h

17.

Which data structure is used for implementing recursion?

a)

Stack 

b)

Queue

c)

List

d)

Array

18.

Which of the following declaration is not supported by C language?

a)

String str;

b)

char *str;

c)

float str = 3e2;

d)

Both “String str;” and “float str = 3e2;”

19.

Which data structure is needed to convert infix notation to postfix notation?

a)

Tree

b)

Branch

c)

Stack

d)

Queue

20.

Which of the following typecasting is accepted by C language?

a)

Widening conversions

b)

Narrowing conversions

c)

Widening & Narrowing conversions

d)

None of the mentioned

21.

The data structure required for Breadth First Traversal on a graph is?

a)

Array

b)

Stack

c)

Queue

d)

Tree

22.

What is #include <stdio.h>?

a)

Preprocessor directive

b)

Inclusion directive

c)

File inclusion directive

d)

None of the mentioned

23.

The prefix form of A-B/ (C * D ^ E) is?

a)

-A/BC^DE

b)

-A/BC*^DE

c)

-ABCD*^DE

d)

-/*^ACBDE

24.

Which keyword is used to prevent any changes in the variable within a C program?

a)

immutable

b)

mutable

c)

const

d)

volatile

25.

The data structure required to check whether an expression contains a balanced parenthesis is?

a)

Queue

b)

Stack

c)

Tree

d)

Array

26.

What will happen if the following C code is executed?

a)

It will cause a compile-time error

b)

It will cause a run-time error

c)

It will run without any error and prints 3

d)

It will experience infinite looping

27.

What is the advantage of a hash table as a data structure?

a)

easy to implement

b)

faster access of data

c)

exhibit good locality of reference

d)

very efficient for less number of entries

28.

What is the result of logical or relational expression in C?

a)

True or False

b)

0 or 1

c)

0 if an expression is false and any positive number if an expression is true

d)

None of the mentioned

29.

Which type of data structure is a ternary heap?

a)

Priority Queue

b)

Hash

c)

Array

d)

Priority Stack

30.

Which of the following data structures is NOT a linear data structure?

a)

Stack

b)

Queue

c)

Tree

d)

Heap

31.

What will be the output of the code?

a)

0

b)

10

c)

20

d)

30

32.

What is the time complexity of searching an element in a sorted array of size 𝑛 using binary search?

a)

O(log n)

b)

O(n)

c)

O(n log n)

d)

O(n^2)

33.

What's recursion in programming?

a)

Loop type

b)

Declares variables together

c)

Sorts arrays

d)

Function calls itself

34.

Which of the following operations is typically NOT supported by a Queue data structure?

a)

Enqueue

b)

Dequeue

c)

Pop

d)

Peek

35.

What will be the output of the code?

a)

1

b)

2

c)

3

d)

4

36.

Which sorting algorithm has the best average-case time complexity?

a)

Insertion Sort

b)

Bubble Sort

c)

Quick Sort

d)

Selection Sort

37.

What will be the output of following C code snippet.

a)

6

b)

7

c)

8

d)

Compile Error

38.

Which searching algorithm requires the data to be sorted beforehand?

a)

Linear Search

b)

Binary Search

c)

Depth-First Search

d)

Breadth-First Search

39.

What will be the output of following C code snippet.

a)

Hello

b)

World

c)

Hello World

d)

Compile Error

40.

Which of the following sorting algorithms is stable?

a)

Quick Sort

b)

Heap Sort

c)

Shell Sort

d)

Merge Sort

41.

What will be the output of following C code snippet.

a)

H

b)

e

c)

o

d)

Segmentation Fault

42.

What is the space complexity of Quick Sort in the worst-case scenario?

a)

O(n)

b)

O(log n)

c)

O(n^2)

d)

O(n log n)

43.

What will be the output of following C code snippet.

a)

10 11 12

b)

10 11 11

c)

10 12 12

d)

Undefined behavior

44.

What is the time complexity of inserting an element at the end of an array with n elements, assuming no resizing is required?

a)

O(1)

b)

O(log n)

c)

O(n)

d)

O(n^2)

45.

What will be the output of following C code snippet.

a)

0 1 2 3 4

b)

0 2 4

c)

0 1 2 3

d)

0 1 2 3 4 5

46.

The data structure is required for Depth First Traversal on a graph is?

a)

Array

b)

Stack

c)

Queue

d)

Tree

47.

What is an example of iteration in C?

a)

while

b)

do-while

c)

for

d)

all of the mentioned

48.

Which data structure is based on the Last In First Out (LIFO) principle?

a)

Stack

b)

Queue

c)

Linked List

d)

Tree

49.

The C-preprocessors are specified with ___ symbol.

a)

#

b)

$

c)

” ”

d)

&

50.

Which of the following is not the type of queue?

a)

Priority queue

b)

Circular queue

c)

Single ended queue

d)

Ordinary queue