EmSAT Achieve (UAE) · Computer Science
Algorithms and Python Programming
26 practice questions, each with the answer and an explanation.
Practise Algorithms and Python Programming now
Random questions from this topic, one at a time. You see the answer and the explanation straight after each one.
All 26 questions
- What is the output of the following Python expression: [x**2 for x in range(6) if x % 2 != 0]?
- What is the worst-case time complexity of searching for an element in a balanced binary search tree (AVL tree) containing n nodes?
- What will be printed by the following Python code snippet?
def func(val, lst=[]):
lst.append(val)
return lst
print(func(1))
print(func(2)) - Which abstract data structure operates on a First-In, First-Out (FIFO) ordering principle?
- What is the return value of executing the recursive Python function `mystery(4)`?
def mystery(n):
if n <= 1:
return 1
return n * mystery(n - 1) - What is the worst-case time complexity of the standard QuickSort algorithm when the chosen pivot is consistently the smallest or largest element?
- In Python, which of the following built-in data types is immutable?
- What is the output of the Python expression: 'UnitedArabEmirates'[6:10]?
- How many comparisons does binary search make in the worst case to determine if a target value is present in a sorted array of 1,024 elements?
- What data structure is utilized internally by the runtime call stack to manage nested subroutine execution and local variable scope?
- What is the output of the following Python code snippet?
x = {1: 'a', 2: 'b'}
y = x.get(3, 'default')
print(y) - Which sorting algorithm is guaranteed to have a worst-case time complexity of O(n log n) and is classified as a stable sorting algorithm?
- What is the result of evaluating `bool([]) or bool('False') and not bool(0)` in Python?
- In graph theory, which algorithm is used to find the shortest path from a single source vertex to all other vertices in a weighted graph with non-negative edge weights?
- What is the time complexity of looking up a value by its key in a Python dictionary under average operational conditions?
- What will be the output of executing the following Python list operations?
a = [1, 2, 3]
b = a
b.append(4)
print(len(a)) - What is the purpose of the base case in a recursive function?
- What does the following Python function compute for a positive integer n?
def mystery(n):
count = 0
while n > 0:
count += n & 1
n >>= 1
return count - What is the space complexity of an iterative binary search algorithm implemented without recursion on an array of size n?
- Which Python keyword is used to handle exceptions and guarantee execution of cleanup code regardless of whether an exception occurred?
- What is the output of `list(filter(lambda x: x > 10, [5, 12, 8, 20, 10]))` in Python?
- What is the worst-case time complexity of inserting an element into a singly linked list at the head position?
- What does the Python expression `'abc' * 3` evaluate to?
- What algorithmic design paradigm is employed by MergeSort and QuickSort?
- What will be printed by the following Python code snippet?
x = [1, 2, 3]
y = [4, 5, 6]
print([a + b for a, b in zip(x, y)]) - What is the primary difference between a stack and a queue data structure?
Keep practising
More EmSAT Achieve (UAE) topics
- Functions, Logarithms and Exponential Models29 questions
- Trigonometry, Vectors and Complex Numbers29 questions
- Algebra, Equations and Coordinate Geometry28 questions
- Differential Calculus and Probability Distributions28 questions
- Grammar, Syntax and Sentence Structure26 questions
- Reading Comprehension and Text Analysis26 questions
- Mechanics and Thermodynamics26 questions
- Waves, Electromagnetism and Modern Physics26 questions