WorksheetsDSA quiz
Total questions: 40
Worksheet time: 23mins
Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
Insertion sort
Quick sort
Heap sort
Merge sort
In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is..
log(2*n)
n\2
log(2*n)-1
n
Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best known algorithm to delete the node Q from the list?
O(n)
O(log2n)
O(log n)
O(1)
The minimum number of stacks needed to implement a queue is
3
2
1
0
Which of the following correctly declares an array?
int sparks[20];
int spark;
sparks{20};
array sparks[20];
Stack A has the entries a, b, c (with a on top). Stack B is empty. An entry popped out of stack A can be printed immediately or pushed to stack B. An entry popped out of the stack B can be only be printed. In this arrangement, which of the following permutations of a, b, c are not possible?
b a c
b c a
c a b
a b c
The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
A
B
C
D
The size of the array should always be _____
POSITIVE
NEGATIVE
WHOLE NUMBER
REAL NUMBER
Which of these methods of class String is used to obtain the length of the String object?
get()
sizeof()
lenghtof()
lenght()
In a circular linked list, the last node points to the____
i don't know
tail node
first node
middle pointer
Nodes in a linked list contain two things:
a pointer and a node
a pointer and a reference
direction and a pointer
data and a pointer
In a stack, if a user tries to remove an element from an empty stack it is called?
empty collection
garbage collection
overflow
underflow
the list of data in which elements can be inserted and removed at the same end is called ____
array
string
stack
none
two basic operation used in queue are
push and pop
enqueue and dequeue
insert and remove
none of these
A tree data structure is a------ data structure
hierarchical
pre-defined
primary
none
Errors that occur during the execution of a program are called?
syntax error
runtime error
logical error
linking error
true definition of systematic error:
Errors that occur because the compiler is unable to understand the written code
those errors in which we think that our code is correct, the code compiles without any error and gives no error while it is running
Errors that occur during the execution (or running) of a program
the errors encountered when the executable file of the code can not be generated even though the code gets compiled successfully.....
Which data structure is used for implementing recursion?
stack
queue
linked list
array
In a depth-first search (DFS) of a graph, what data structure is typically used to keep track of visited vertices?
stack
queue
linked list
array
What is the time complexity of the selection sort algorithm in the worst case?
O(n)
O(n log n)
O(n^2)
O(log n)
I am a searching algorithm known for my efficiency when the data is sorted. What am I?
linear search
binary search
quick search
merge search
Given an array of integers, how can you find the subarray with the maximum sum efficiently?
divide and conquer
dynamic programming
greedy algorithm
backtracking
In the context of sorting algorithms, what is an "in-place" algorithm?
An algorithm that doesn't use any extra memory
An algorithm that sorts the elements in their original order
An algorithm that is stable
An algorithm that uses recursion
What is a programmer's favorite kind of tree?
birch tree
pine tree
binary tree
oak tree
What do you call a linked list that can sing?
melody list
node list
singly linked list
linked choir
Why did the programmer break up with their data structure?
it had too many issues
it was unresponsive
it wasn't their type
they needed more space
What do you call a snake that's good at algorithms?
python
c++
java
ruby
Why do algorithms never argue?
they always return the same result
they have a common language
they use binary logic
they're too logical
If you're stranded on an island and can only bring one algorithm with you for survival, which one would it be?
breadth-first search(BFS)
Depth-First search(DFS)
dijkstra's algorithm
A*Search algorithm
What data structure is like a line at a grocery store, where the first one in is the first one out?
stack
queue
linked list
hash table
What is the purpose of the algorithmic paradigm known as "Backtracking"?
divide and conquer
dynamic programming
incremental
recursive trial-and-error
Which of the following is an NP-complete problem?
shortest path problem
travelling salesman problem
binary search
breadth-first search
In a binary search tree, what is the time complexity for finding the kth smallest element?
O(log n)
O(n)
O(n log n)
O(n^2)
I am a data structure that stores elements in a sorted order. Insertion and deletion are efficient in me. What am I?
array
linked list
heap
queue
Which of the following is an example of a non-linear data structure?
array
linked list
queue
tree
In a binary search tree, what is the key property that distinguishes it from other trees?
nodes can have any number of children
each node has at most two children
all nodes have the same number of children
nodes can have any type of data
What is the purpose of a priority queue?
sorting elements
storing elements in a queue
assigning priority to elements
searching elements
What is the purpose of hashing in data structures?
searching
sorting
indexing
all of the above
What is the primary purpose of the Floyd-Warshall algorithm?
finding the shortest path in a graph
finding the minimum spanning tree in a graph
searching for an element in an array
sorting elements in a queue
In a binary search tree, what is the minimum number of nodes in a tree with height 'h'?
2^h
h
2^(h-1)
h^2
