Font size
WorksheetsDSA(Data Structures & Algo)
Total questions: 48
Worksheet time: 25mins
What is an array?
A collection of different data types
A collection of similar data types stored in contiguous memory locations
A collection of pointers
A user-defined data type
A user-defined data type
Which of the following correctly declares an integer array of size 10 in C?
int a(10);
int a[10];
array int a[10];
int a{10};
Array indices in C start from:
1
0
-1
Depends on compiler
Which of the following is true about arrays?
Array size can be changed at runtime
Array elements are stored randomly
Array elements are stored in contiguous memory locations
Arrays can store mixed data types
What is a structure in C?
A built-in data type
A collection of similar data types
A collection of different data types under one name
A pointer data type
Which keyword is used to define a structure in C?
struct
structure
define
typedef
How do you access a structure member using a structure variable s?
s->member
s.member
s/member
member.s
Which operator is used to access structure members through a pointer?
.
*
->
&
An array of structures is used when:
We need to store multiple values of the same data type
We need to store multiple records of similar data
We need dynamic memory allocation
We need recursion
Which of the following statements is correct?
Structures cannot contain array
Arrays cannot contain structures
Structures can contain arrays
Both B and C
Which algorithm is used to solve optimization problems?
Greedy
Backtracking
Divide and Conquer
Randomized algorithms
Which of the following is a Greedy based problem?
Knapsack Problem
Sorting
Tower of Hanoi
N Queens Problem
Which of the following concept is used in Merge Sort Algorithm?
Functions
Loops
Recursion
All of The Above
Which approach does Backtracking algo use?
Divide and Conquer
Brute Force
Dynamic Programming
Dynamic Programming
What time complexity does the statement have .. where n=10
int sum=0;
for(int i=0 ; i<n ; i ++){
sum+=i;
}
O(1)
O(n)
O(n log n)
O(n ^ 2)
What time complexity does the statement ...... n=1000
int sum=0;
sum=n*(n+1)/2;
O( log n )
O( N ! )
O(n log n)
O(1)
O( n log n) is a
Quasilinear Time
Logarithmic time
Constant Time
Quadratic Time
Which symbol is used to declare a pointer?
&
&
*
#
%
What does & operator do?
Multiplies values
Stores address
Gives address of a variable
Declares pointer
What will *ptr represent?
Address of ptr
Value stored at address ptr
Pointer name
Size of pointer
Which of the following is a correct pointer declaration?
int ptr;
*int ptr;
int *ptr;
int &ptr;
If ptr is a structure pointer, how do you access member x?
ptr.x
*ptr.x
ptr->x
(*ptr).x
Which of the following is equivalent to ptr->a?
*ptr.a
(*ptr).a
ptr.(*a)
ptr.a
What is the correct way to assign a structure address to a pointer?
ptr = s;
ptr = &s;
ptr = *s;
ptr = s.address;
A self-referential structure is one that contains:
Only integers
Only pointers
A pointer to the same structure type
A function
Which of the following is a self-referential structure?
struct node {
int a;
};
struct node {
int a;
node *next;
};
struct node {
int *a;
};
struct node {
float a;
};
In a linked list, the next pointer stores:
Data
Previous node
Address of next node
Index of node
Which pointer in a doubly linked list points to the previous node?
next
ptr
prv
back
Which of the following is NOT true about pointers?
Pointers store addresses
Pointers improve memory use
Pointers store data directly
Pointers are used in dynamic memory
Which operator is used to allocate memory dynamically in C++?
malloc
calloc
new
create
Which pointer points to the first node of a linked list?
temp
last
head
tail
Which condition represents an empty singly linked list?
head → next = NULL
head = 0
head = NULL
head → data = NULL
In a singly linked list, traversal is possible in:
Forward direction only
Backward direction only
Both directions
Random order
Which operation is fastest in a singly linked list?
Insertion at end
Deletion at end
Insertion at beginning
Searching
What does the last node’s pointer contain?
Address of first node
Address of previous node
NULL
Garbage value
A doubly linked list node contains:
Data + one pointer
Data + two pointers
Only pointers
Data only
In a doubly linked list, the first node’s prev pointer contains:
Address of last node
Address of next node
NULL
Garbage value
Traversal in a doubly linked list is possible in:
Forward only
Forward only
Both forward and backward
Random order
Compared to singly linked list, doubly linked list requires:
Less memory
Same memory
More memory
No memory
Deletion of a node is easier in doubly linked list because:
Nodes are indexed
Previous node address is available
Memory is continuous
Data is sorted
Insertion at the beginning of both singly and doubly linked list takes:
O(n) time
O(log n) time
O(1) time
O(n²) time
Which of the following is true?
Singly linked list allows backward traversal
Doubly linked list uses one pointer
Singly linked list uses less memory
Doubly linked list cannot delete nodes
The Tower Of Hanoi is a
Recursive Problem
Back Tracking Problem
Greedy Problem
Sorting
Which loop is typically used to traverse a Link List;
while
do while
for
do
What does the above code do
.....?
Searching
Sorting
Removes Duplicates
Reverses an Array
Calloc(), Malloc(), Free(), Realloc() functions come under the header file in c
math.h
stdlib.h
stdio.h
cmath.h
What time complexity does the below algorithm have...
O(n)
O( n log n)
O( 1 )
O( n ^2 )
The below code is an example of
Subtraction from Pointer to Pointer
Pointer Decrement
Pointer Increment
All of the above
