Font size
WorksheetsDSA Basics
Total questions: 67
Worksheet time: 1hrs 15mins
Example of linear data structure except
array
tree
queue
stack
If you want the method to return a value, you can use a primitive data type instead of void, and use the (a) keyword inside the method.
(use small letters and space if necessary)
A data structure which is a programming technique you can use in which a method calls itself to solve a problem.
(use small letters and space if necessary)
(a)
(a) is a collection of elements used to store the same type of data.
(use small letters and space if necessary)
int num[ ] = {11, 2, 99, 4, 33, 14, 18};
How would you access the fourth element in num.
(no spacing in writing the answer)
(a)
A recursive method is ________
a method that cannot be called more than once
a method that will never iterate infinitely
a method that invokes itself by name within the method
Index values of an array ranges from ________.
0 to length
1 to length
1 to length
0 to length-1
The program may run out of memory in a ___
non-recursive function call
condition when too many variables are declared
recursive function call
none of the above
Which of the following problems can be solved using recursion?
finding the factorial of a number
finding Nth number of the Fibonacci sequence
finding the length of a string
all of the above
(a) act as variables inside the method.
(plural form, use small letters and space if necessary)
Name the condition at which the recursive method will stop calling itself.
(use small letters and space if necessary)
(a)
float numarr[4];
What is the range of the index?
(use numerical value and write "to" in-between the range, use space if necessary)
(a)
When a parameter is passed to the method, it is called an (a) .
(singular form, use small letters and space if necessary)
int[] arr;
Write the instantiating code with the length of 5.
(use proper symbol, space before and after "=" symbol)
(a)
What is the error in the following code fragment?
float ave[20];
ave[20]=10.44;
a cast is required
a two-dimensional array is required
data not initialized
array out-of-bounds
What would happen if the base case if not defined in the recursive method?
stack underflow
index out of bounds
stack overflow
none of the above
What is the output?
(a)
Methods are used to perform certain actions, and they are also known as (a) . (plural form, use small letters and space if necessary)
Java code to display the size of an array name studname[ ].
System.out.println("The size is " + studentname[ index ]);
System.out.println("The size is " + length.length);
System.out.println("The size is " + studentname);
System.out.println("The size is " + studname.length);
Identify the name of the array based on the code segment below:
for(int j=0; j<studnum.length; j++) {
System.out.print("Enter student number: ");
(a)
}
Insert the missing part in creating and instantiating an array.
int[] arr = { 77, 22, 44}
(a)
An algorithm should be in the right order.
Write T if the statement is TRUE otherwise F.
(a)
A mathematical-model with a collection of operations defined on that model is called _____.
algorithm
data structure
data type
abstract data type
When you write an algorithm you need to include ________, step-by-step instructions.
ambiguous
multiple
clear
precise
It is a property to get the size of an array.
(use small letters and spacing if necessary)
(a)
double[][] arr = {{4.2, 4.3, 4.0}, {4.1, 4.4} };
What is the element in arr[1][0] ?
(a)
How is the 2nd element in an array accessed based on pointer notation?
*a + 2
*(a + 2)
*(*a + 2)
&(a + 2)
Which of the following is example of in-place algorithm?
Bubble Sort
Merge Sort
Insertion Sort
All of the above
The data structure required to check whether an expression contains a balanced parenthesis is?
Stack
Queue
Array
All of the above
When does the ArrayIndexOutOfBoundsException occur?
Compile-time
Run-time
Not an error
Not an exception at all
What is the speciality about the inorder traversal of a binary search tree?
It traverses in a non increasing order
It traverses in an increasing order
It traverses in a random fashion
It traverses based on priority of the node
What is the time complexity of inserting at the end in dynamic arrays?
O(1)
O(n)
O(logn)
Either O(1) or O(n)
The following formula will produce
Fn = Fn-1 + Fn-2
Armstrong Number
Fibonacci Series
Euler Number
Prime Number
A priority queue can efficiently implemented using which of the following data structures? Assume that the number of insert and peek (operation to see the current highest priority item) and extraction (remove the highest priority item) operations are almost same.
Linked List
Array
Heap Data Structures like Binary Heap, Fibonacci Heap
None of the Above
Which of the following is a true about Binary Trees
Every binary tree is either complete or full.
Every complete binary tree is also a full binary tree.
Every full binary tree is also a complete binary tree.
No binary tree is both complete and full.
None of the Above
The preorder traversal sequence of a binary search tree is 30, 20, 10, 15, 25, 23, 39, 35, 42. Which one of the following is the postorder traversal sequence of the same tree?
30, 20, 15, 23, 25, 35, 42, 39, 10
30, 10, 25, 23, 20, 42, 35, 39, 15
30, 20, 10, 23, 25, 42, 35, 39, 15
15, 10, 23, 25, 20, 35, 42, 39, 30
Which of the following traversal outputs the data in sorted order in a BST?
Preorder
Inorder
Postorder
Level Order
Consider a node X in a Binary Tree. Given that X has two children, let Y be Inorder successor of X. Which of the following is true about Y?
Y has no right child
Y has no left child
Y has both children
None of the above
In binary tree,the maximum number of nodes at any level n is:
n
2^n
n+1
2*n
.What is the best case time complexity of the binary search algorithm
O(1)
O(n)
O(log(2*n))
O(n^2)
In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into EMPTY queue?
Only front pointer
Only rear pointer
Both front and rear pointer
No pointer will be changed
What is the worst case complexity of selection sort?
O(nlogn)
O(logn)
O(n)
O(n^2)
What is the value of the postfix expression 6 3 2 4 + - * ?
1
40
74
-18
The operation of processing each element in the list is known as
Sorting
Merging
Inserting
Traversal
What programming language are you most comfortable with?
C
Python
Java
On a scale of 1-10, how comfortable are you with coding?
1-3 (Beginner)
4-7 (Intermediate)
8-10 (Expert)
What is your favorite data structure?
Array
Stack
Tree
I have no favorite/I don't know any data structures.
How do you usually handle a new programming problem?
I jump straight into coding
I take time to design the solution on paper first
I discuss it with others to gather ideas
What is your previous experience with computer security?
No experience
Some online courses
A lot of self-study
Professional experience
Which of the following real-world scenarios do you think DSA could most impact?
Speeding up a slow computer
Optimizing a company's data storage
Helping an artist organize their digital assets
If you were tasked to design a secure system for a bank, which of the following would be your primary concern?
Ensuring fast and efficient transactions
Preventing unauthorized access to customer data
Making sure the system is always available
Which scenario is an example of a security vulnerability caused by improper implementation of a data structure?
A music streaming application is unable to recommend songs based on a user's past listening history.
A software application stores user passwords in plain text, instead of using a hashed data structure.
An online store's search function takes too long to return results, causing users to leave the website
If you could use one word to describe your feelings about data structures and algorithms course, what would it be?
What are your expectations from this course?
Which of the following is not a stable sorting algorithm?
Bubble sort
Selection sort
Quick sort
None of these
Which of the following is/are in-place sorting algorithm(s)?
Selection sort
Bubble sort
Quick sort
Merge sort
The worst-case time complexity of a quick sort algorithm?
O(nlogn)
O(logn)
O(n^2)
O(n^2logn)
The no.of comparisons in first pass in bubble sort to sort n numbers is....?
n
n(n-1)/2
n-1
n^2
The maximum no.of swappings in first pass of selection sort to sort n numbers is....?
1
n(n-1)/2
n-1
n^2
In quick sort, based on key or pivot element position, the list is partitioned into how many sub-lists?
1
2
3
4
If the list is almost sorted, then which of the following algorithm gives the better performance?
Bubble sort
Selection sort
Quick sort
All of these
If the list is almost sorted, then which of the following algorithm is/are not suitable?
Bubble sort
Selection sort
Quick sort
All of these
In bubble sort, what will be the sequence of the following elements after 7 passes?
20 15 14 45 11 18 78 95
(a)
In bubble sort, what will be the sequence of the following elements after 1st pass?
2 1 4 45 11 18 78 95
(a)
In selection sort, what will be the sequence of the following elements after 2nd pass?
8 6 3 7 63 4 10 103 61
(a)
The no.of passes in selection sort to sort n numbers is .....?
n
n-1
n^2
logn
The no.of swapings in selection sort to sort n numbers is .....?
n
n-1
n^2
logn
