Dsa 7
Dsa 7
Q1
Uninitialized static/global variables go in
Stack
Heap
Data
BSS
Q2
What is the purpose of the this keyword in object-oriented programming?
Q3
Based on the pseudo code, under which condition should a packet be retransmitted?
If acknowledgmentNotReceivedWithin(timeout) {
retransmitPacket()
}
Q4
Which of these statements is NOT executable?
Function call
Preprocessor directive
Conditional block
Loop
Q5
Process
Input/Output
Decision
Start/End
127.0.0.1:5500/js/index.html 1/19
11/2/24, 10:42 PM Questions
Q6
3
4
5
Infinite
Q7
Which of the following paradigms typically involves writing code that performs a sequence of steps, with
a focus on control flow?
Object-Oriented Programming
Functional Programming
Procedural Programming
Declarative Programming
Q8
How many return values can a function have?
One
Multiple
Zero
Depends on context
Q9
What section stores global variables?
Stack
Heap
Data
Text
Q10
Use index 0
Use index 1
Use index n
127.0.0.1:5500/js/index.html 2/19
11/2/24, 10:42 PM Questions
Q11
Which programming paradigm is commonly associated with programming languages like Prolog and is
used for rule-based logic and reasoning?
Logic Programming
Functional Programming
Procedural Programming
Declarative Programming
Q12
Can a function have no parameters and still return a value?
No
Yes
Depends on language
Only for built-ins
Q13
Counter() {
count++;
}
void display() {
System.out.println(count);
}
}
1
2
3
Error
Q14
What is the primary benefit of modular programming using procedures and functions?
Reusability
Less code
Fewer bugs
127.0.0.1:5500/js/index.html 3/19
11/2/24, 10:42 PM Questions
Q15
Based on the pseudo code, what is the type of the variable age?
age = 30
String
Integer
Boolean
Float
Q16
If an array is copied into another variable and the first element of the copy is modified, what happens to
the original array?
Q17
Rectangle
Diamond
Oval
Parallelogram
Q18
What does the following pseudo code describe in the context of memory management?
Segmentation
Paging
Dynamic memory allocation
Memory swapping
Q19
127.0.0.1:5500/js/index.html 4/19
11/2/24, 10:42 PM Questions
Variable in function
Actual value passed
Memory location
Function's output
Q20
What is a key characteristic of an interpreter in the context of interpreted languages?
It compiles the entire source code into machine code before execution.
It translates source code into intermediate code or directly into machine code and executes it
immediately.
It optimizes code performance by compiling it once and running it multiple times.
It only executes code that has been pre-compiled.
Q21
STACK: 1, 1, 1, 2, 5, _.
What is the maximum number of operations that can be performed in any sequence from amongst the
above operations, such that no overflow/underflow condition is encountered?
2
3
4
1
Q22
Given a binary max heap that contains 'n' numbers, what is the time complexity to find the smallest
element?
O(n)
O(logn)
0(loglogn)
0(1)
127.0.0.1:5500/js/index.html 5/19
11/2/24, 10:42 PM Questions
Q23
In the balanced binary tree in the below figure, how many nodes will become unbalanced when a node is
inserted as a child of the node “g”?
a
/ \
b e
/ \ /
c d f
/
g
1
2
3
4
Q24
What is the worst-case time complexity of the linear search algorithm?
O(1)
O(N)
O(logN)
O(N^2)
Q25
If the stack is implemented using an array arr = {2, 5, 13, 4, 15, 6, 7, 8, 9} (0-based indexing).
Which element would be at the top of stack, if the last element of the array is inserted first in the stack?
13
5
2
9
Q26
Which algorithm is primarily used for traversing trees?
Dijkstra's Algorithm
Kruskal's Algorithm
Prim's algorithm
Depth-First Search
Q27
Identify the topmost element of the stack after all the operations are performed.
POP(STACK , x)
means the topmost element is popped from the stack and stored in x.
5
8
1
3
Q28
A priority queue is a data structure in every element has priority associated with it. What is the minimum
number of queues needed to build priority queue.
1
2
3
4
Q29
Q30
B) The Prev link of the first node and Next link of the last node of a doubly linked list is NULL.
Q31
127.0.0.1:5500/js/index.html 8/19
11/2/24, 10:42 PM Questions
Q32
Q33
From the following options, select the type of linked list that is described by the following points.
Q34
Set the following in increasing order of their complexity O(log n), O(n!), O(n^n), O(nlogn), O(1),
O(n)?
Q35
Which of the following traversals is sufficient to construct BST from given traversals
1) Inorder
2) Preorder
3) Postorder
1 and 3
2 and 3
127.0.0.1:5500/js/index.html 9/19
11/2/24, 10:42 PM Questions
Either 2 or 3 is sufficient
Any one of the given three traversals is sufficient
Q36
How are the elements in the circular linked list pointed to each other?
The pointer from the last element in the list, points back to the first element
The pointer from the first element in the list, points back to the last element
The pointer from the last element in the list, points to the tail of the list
The pointer from the first element in the list, points to the head of the list
Q37
The steps to write a function in C language that adds a single new node at the start of any linked list are
given in a jumbled order. Select the option that denotes the correct sequence of steps.
D. Make the new node point to the current first node of the list.
A, B, C, D
C, B, D, A
B, C, D, A
B, A, D, C
Q38
Which type of algorithm uses a priority queue?
DFS
BFS
Dijkstra's Algorithm
Kruskal's Algorithm
Q39
From the following options, select the type of linked list that is described by the following points:
127.0.0.1:5500/js/index.html 10/19
11/2/24, 10:42 PM Questions
Q40
Which algorithm, among the ones listed below, offers the most efficient time complexity for determining
the shortest path between two nodes in a weighted graph?
DFS
BFS
Dijkstra's Algorithm
Bellman-Ford Algorithm
Q41
What is the difference between a class method and an instance method in Python OOP?
A class method is called on the class itself, whereas an instance method is called on an instance of
the class.
A class method can access instance variables, whereas an instance method cannot.
A class method is defined using the @classmethod decorator, whereas an instance method is not.
A class method is used for object instantiation, whereas an instance method is used for object
manipulation.
Q42
arr = [10, 3, 7, 1, 9]
What is the value of arr after sorting it in descending order using Python's built-in sort() method?
[10, 9, 7, 3, 1]
[1, 3, 7, 9, 10]
[9, 10, 7, 3, 1]
None of the above
Q43
Which of the following Python expressions is functionally identical to the provided code snippet that
manipulates a dictionary named count?
if key in count:
count[key] = count[key] + 1
else:
count[key] = 1
127.0.0.1:5500/js/index.html 11/19
11/2/24, 10:42 PM Questions
count[key] = count.get(key,0) + 1
count[key] = count.get(key,-1) + 1
count[key] = (count[key] * 1) + 1
Q44
A university is analyzing the student database system to get the names of the students who have
participated in the annual events this academic year. The condition is to be met that if the name of the
student "Steve" matches, then the program should end running.
Choose the correct Python code snippet from the options for getting the following
Output:
Mark
Jacob
Jasmin
Leonard
Steve
#code_start_python
#code_end
#code_start_python
#code_end
#code_start_python
127.0.0.1:5500/js/index.html 12/19
11/2/24, 10:42 PM Questions
#code_end
#code_start_python
#code_end
Q45
my_set = {1, 2, 3, 4, 5}
my_set.add(6)
my_set.remove(2)
print(my_set)
{1, 2, 3, 4, 5, 6}
{1, 3, 4, 5}
{1, 3, 4, 5, 6}
{2, 3, 4, 5, 6}
Q46
A student management system is implemented using Python. One of the functionalities is the printing of
all student details, along with the stu1 name having the value 'Abc'. The student array consists of stu1,
stu2, stu3, and stu4. The following code is written to fulfill this requirement:
#code_start_python
studs = ['stu1', 'stu2', 'stu3']
for _ in studs:
print('Studentdetails')
for st in studs:
print(st)
stu1name = 'Abc'
for x in stu1name:
print(x)
#code_end
Studentdetails
Studentdetails
Studentdetails
Studentdetails
Studentdetails
127.0.0.1:5500/js/index.html 13/19
11/2/24, 10:42 PM Questions
Studentdetails
Studentdetails
Studentdetails
Studentdetails
stu1
stu2
stu3
A
b
c
stu1
stu2
stu3
Abc
Studentdetails
stu1stu2stu3
Abc
Studentdetails
Studentdetails
Studentdetails
stu1
stu2
stu3
A
b
c
Q47
True
False
TypeError
None of the above
Q48
In Python, which statement is used to execute a block of code repeatedly as long as a given condition is
true?
if statement
for loop
while loop
else statement
Q49
127.0.0.1:5500/js/index.html 14/19
11/2/24, 10:42 PM Questions
for i in range(3):
for j in range(2):
if j == 1:
break
print(i, j)
else:
print("End")
00
10
20
End
00
10
20
End
00
01
02
End
Q50
L = [11, 54, 65, 99, 132, 143]
x = list(filter(lambda a: a % 11 == 0, L))
[132, 143]
[54 ,65]
Q51
127.0.0.1:5500/js/index.html 15/19
11/2/24, 10:42 PM Questions
{0, 1, 2, 3, 4}
{0: 0, 1: 1, 2: 4, 3: 9, 4: 16}
{0: 1, 1: 2, 2: 3, 3: 4, 4: 5}
{1: 0, 2: 1, 4: 2, 9: 3, 16: 4}
Q52
21
8
34
13
Q53
2
3
4
5
Q54
for i in range(3):
if i == 2:
break
else:
x = "Done"
0
2
"Done"
NameError
127.0.0.1:5500/js/index.html 16/19
11/2/24, 10:42 PM Questions
Q55
What is the difference between the 'finally' and 'except' clauses in a try-except block?
finally' is always executed, regardless of whether an exception is raised or not, whereas 'except' is
only executed if an exception is raised.
There is no difference - they both handle errors in the same way.
finally' is only executed if an exception is raised, whereas 'except' is always executed whether an
exception is raised or not.
finally' and 'except' are only used in different types of try-except blocks, depending on the type of error
being handled.
Q56
d = {}
d['name'] = 'abc'
d['age'] = 20
d['address'] = 'not found'
print(d)
Q57
print(new_list)
[1, 2, 3, 4]
[4, 2, 1, 3]
[2, 4, 1, 3]
[3, 1, 4, 2]
127.0.0.1:5500/js/index.html 17/19
11/2/24, 10:42 PM Questions
Q58
a = [1,2,[3,4],[5,[6,7],8]]
b = []
for i in a:
if type(i) == list:
for j in i:
b.append(j)
else:
b.append(i)
print(b)
[1, 2, 3, 4, 5, 6, 7, 8]
[1, 2, 3, 4, 5, [6, 7], 8]
[1, 2, [3, 4], 5, [6, 7], 8]
[1, 2, [3, 4], 5, 6, 7, 8]
Q59
class MyClass:
def __init__(self, x):
self.x = x
def my_method(self):
print(self.x)
obj = MyClass(10)
obj.my_method()
10
0
Syntax Error
Q60
Q61
Problem Statement
In the DoSelect Coding Community, people use a language called Coderita, which contains only
lowercase English letters.
If the string ends with s then simply append es at the end of the string, else simply append s.
Input Format
Given a string S.
Constraints
1<=|S|<=1000
S consists of only lowercase English letters.
Output Format
Evaluation Parameters
Sample Input
employee
Sample Output
employees
Explanation
As string does not end with s so we have to simply append s at the end of the string.
127.0.0.1:5500/js/index.html 19/19