wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DSA(Data Structures & Algo)

Total questions: 48

Worksheet time: 25mins

Name
Class
Date
1.

What is an array?

a)

A collection of different data types

b)

A collection of similar data types stored in contiguous memory locations

c)

A collection of pointers

A user-defined data type

d)

A user-defined data type

2.

Which of the following correctly declares an integer array of size 10 in C?

a)

int a(10);

b)

int a[10];

c)

array int a[10];

d)

int a{10};

3.

Array indices in C start from:

a)

1

b)

0

c)

-1

d)

Depends on compiler

4.

Which of the following is true about arrays?

a)

Array size can be changed at runtime

b)

Array elements are stored randomly

c)

Array elements are stored in contiguous memory locations

d)

Arrays can store mixed data types

5.

What is a structure in C?

a)

A built-in data type

b)

A collection of similar data types

c)

A collection of different data types under one name

d)

A pointer data type

6.

Which keyword is used to define a structure in C?

a)

struct

b)

structure

c)

define

d)

typedef

7.

How do you access a structure member using a structure variable s?

a)

s->member

b)

s.member

c)

s/member

d)

member.s

8.

Which operator is used to access structure members through a pointer?

a)

.

b)

*

c)

->

d)

&

9.

An array of structures is used when:

a)

We need to store multiple values of the same data type

b)

We need to store multiple records of similar data

c)

We need dynamic memory allocation

d)

We need recursion

10.

Which of the following statements is correct?

a)

Structures cannot contain array

b)

Arrays cannot contain structures

c)

Structures can contain arrays

d)

Both B and C

11.

Which algorithm is used to solve optimization problems?

a)

Greedy

b)

Backtracking

c)

Divide and Conquer

d)

Randomized algorithms

12.

Which of the following is a Greedy based problem?

a)

Knapsack Problem

b)

Sorting

c)

Tower of Hanoi

d)

N Queens Problem

13.

Which of the following concept is used in Merge Sort Algorithm?

a)

Functions

b)

Loops

c)

Recursion

d)

All of The Above

14.

Which approach does Backtracking algo use?

a)

Divide and Conquer

b)

Brute Force

c)

Dynamic Programming

d)

Dynamic Programming

15.

What time complexity does the statement have .. where n=10

int sum=0;

for(int i=0 ; i<n ; i ++){

sum+=i;

}

a)

O(1)

b)

O(n)

c)

O(n log n)

d)

O(n ^ 2)

16.

What time complexity does the statement ...... n=1000

int sum=0;

sum=n*(n+1)/2;

a)

O( log n )

b)

O( N ! )

c)

O(n log n)

d)

O(1)

17.

O( n log n) is a

a)

Quasilinear Time

b)

Logarithmic time

c)

Constant Time

d)

Quadratic Time

18.

Which symbol is used to declare a pointer?
&

a)

&

b)

*

c)

#

d)

%

19.

What does & operator do?

a)

Multiplies values

b)

Stores address

c)

Gives address of a variable

d)

Declares pointer

20.

What will *ptr represent?

a)

Address of ptr

b)

Value stored at address ptr

c)

Pointer name

d)

Size of pointer

21.

Which of the following is a correct pointer declaration?

a)

int ptr;

b)

*int ptr;

c)

int *ptr;

d)

int &ptr;

22.

If ptr is a structure pointer, how do you access member x?

a)

ptr.x

b)

*ptr.x

c)

ptr->x

d)

(*ptr).x

23.

Which of the following is equivalent to ptr->a?

a)

*ptr.a

b)

(*ptr).a

c)

ptr.(*a)

d)

ptr.a

24.

What is the correct way to assign a structure address to a pointer?

a)

ptr = s;

b)

ptr = &s;

c)

ptr = *s;

d)

ptr = s.address;

25.

A self-referential structure is one that contains:

a)

Only integers

b)

Only pointers

c)

A pointer to the same structure type

d)

A function

26.

Which of the following is a self-referential structure?

a)

struct node {

int a;

};

b)

struct node {

int a;

node *next;

};

c)

struct node {

int *a;

};

d)

struct node {

float a;

};

27.

In a linked list, the next pointer stores:

a)

Data

b)

Previous node

c)

Address of next node

d)

Index of node

28.

Which pointer in a doubly linked list points to the previous node?

a)

next

b)

ptr

c)

prv

d)

back

29.

Which of the following is NOT true about pointers?

a)

Pointers store addresses

b)

Pointers improve memory use

c)

Pointers store data directly

d)

Pointers are used in dynamic memory

30.

Which operator is used to allocate memory dynamically in C++?

a)

malloc

b)

calloc

c)

new

d)

create

31.

Which pointer points to the first node of a linked list?

a)

temp

b)

last

c)

head

d)

tail

32.

Which condition represents an empty singly linked list?

a)

head → next = NULL

b)

head = 0

c)

head = NULL

d)

head → data = NULL

33.

In a singly linked list, traversal is possible in:

a)

Forward direction only

b)

Backward direction only

c)

Both directions

d)

Random order

34.

Which operation is fastest in a singly linked list?

a)

Insertion at end

b)

Deletion at end

c)

Insertion at beginning

d)

Searching

35.

What does the last node’s pointer contain?

a)

Address of first node

b)

Address of previous node

c)

NULL

d)

Garbage value

36.

A doubly linked list node contains:

a)

Data + one pointer

b)

Data + two pointers

c)

Only pointers

d)

Data only

37.

In a doubly linked list, the first node’s prev pointer contains:

a)

Address of last node

b)

Address of next node

c)

NULL

d)

Garbage value

38.

Traversal in a doubly linked list is possible in:

a)

Forward only

b)

Forward only

c)

Both forward and backward

d)

Random order

39.

Compared to singly linked list, doubly linked list requires:

a)

Less memory

b)

Same memory

c)

More memory

d)

No memory

40.

Deletion of a node is easier in doubly linked list because:

a)

Nodes are indexed

b)

Previous node address is available

c)

Memory is continuous

d)

Data is sorted

41.

Insertion at the beginning of both singly and doubly linked list takes:

a)

O(n) time

b)

O(log n) time

c)

O(1) time

d)

O(n²) time

42.

Which of the following is true?

a)

Singly linked list allows backward traversal

b)

Doubly linked list uses one pointer

c)

Singly linked list uses less memory

d)

Doubly linked list cannot delete nodes

43.

The Tower Of Hanoi is a

a)

Recursive Problem

b)

Back Tracking Problem

c)

Greedy Problem

d)

Sorting

44.

Which loop is typically used to traverse a Link List;

a)

while

b)

do while

c)

for

d)

do

45.

What does the above code do

.....?

a)

Searching

b)

Sorting

c)

Removes Duplicates

d)

Reverses an Array

46.

Calloc(), Malloc(), Free(), Realloc() functions come under the header file in c

a)

math.h

b)

stdlib.h

c)

stdio.h

d)

cmath.h

47.

What time complexity does the below algorithm have...

a)

O(n)

b)

O( n log n)

c)

O( 1 )

d)

O( n ^2 )

48.

The below code is an example of

a)

Subtraction from Pointer to Pointer

b)

Pointer Decrement

c)

Pointer Increment

d)

All of the above