Q. Which of the following is a valid application of binary search?
-
A.
Finding the square root of a number
-
B.
Finding an element in a sorted array
-
C.
Sorting an array
-
D.
Searching in a hash table
Solution
Binary search is specifically used for finding an element in a sorted array.
Correct Answer:
B
— Finding an element in a sorted array
Learn More →
Q. Which of the following is a valid application of Dijkstra's algorithm?
-
A.
Finding the minimum spanning tree
-
B.
Finding the shortest path in a road network
-
C.
Finding strongly connected components
-
D.
Sorting a list of numbers
Solution
Dijkstra's algorithm is commonly used to find the shortest path in a road network, where the edges represent distances or travel times.
Correct Answer:
B
— Finding the shortest path in a road network
Learn More →
Q. Which of the following is a valid HTTP status code for a successful request?
-
A.
200
-
B.
301
-
C.
403
-
D.
500
Solution
The HTTP status code 200 indicates a successful request, meaning the server has successfully processed the request.
Correct Answer:
A
— 200
Learn More →
Q. Which of the following is a valid implementation detail of Dijkstra's algorithm?
-
A.
Using a depth-first search approach
-
B.
Updating the distance of adjacent nodes only if they are visited
-
C.
Using a priority queue to select the next node
-
D.
Storing all nodes in a single array
Solution
Dijkstra's algorithm uses a priority queue to efficiently select the next node with the smallest tentative distance.
Correct Answer:
C
— Using a priority queue to select the next node
Learn More →
Q. Which of the following is a valid implementation of binary search in Python?
-
A.
def binary_search(arr, target): ...
-
B.
def binary_search(arr, target): for i in arr: if i == target: return i
-
C.
def binary_search(arr, target): while arr: ...
-
D.
def binary_search(arr, target): return arr.index(target)
Solution
The first option correctly defines a binary search function that takes a sorted array and a target value.
Correct Answer:
A
— def binary_search(arr, target): ...
Learn More →
Q. Which of the following is a valid IPv4 address?
-
A.
192.168.1.256
-
B.
172.16.0.1
-
C.
10.0.0.999
-
D.
255.255.255.256
Solution
A valid IPv4 address must be in the range of 0 to 255 for each octet. 172.16.0.1 is valid.
Correct Answer:
B
— 172.16.0.1
Learn More →
Q. Which of the following is a valid operation for a queue?
-
A.
Push
-
B.
Pop
-
C.
Enqueue
-
D.
Dequeue
Solution
In a queue, the operation to add an element is called 'enqueue', while 'dequeue' is used to remove an element.
Correct Answer:
C
— Enqueue
Learn More →
Q. Which of the following is a valid operation for a stack?
-
A.
Enqueue
-
B.
Dequeue
-
C.
Push
-
D.
Insert
Solution
Push is a valid operation for a stack, allowing you to add an element to the top of the stack.
Correct Answer:
C
— Push
Learn More →
Q. Which of the following is a valid property of AVL trees?
-
A.
The height difference between left and right subtrees can be at most 2.
-
B.
Every node must be black.
-
C.
The height difference between left and right subtrees can be at most 1.
-
D.
All leaves are red.
Solution
In AVL trees, the height difference between left and right subtrees can be at most 1.
Correct Answer:
C
— The height difference between left and right subtrees can be at most 1.
Learn More →
Q. Which of the following is a valid property of Red-Black trees?
-
A.
The height of the tree is always even
-
B.
No two red nodes can be adjacent
-
C.
All nodes must have two children
-
D.
The root can be red
Solution
In Red-Black trees, no two red nodes can be adjacent, which helps maintain balance and ensures that the tree does not become skewed.
Correct Answer:
B
— No two red nodes can be adjacent
Learn More →
Q. Which of the following is a valid sequence of colors for a Red-Black tree?
-
A.
Red, Red, Black
-
B.
Black, Red, Black
-
C.
Red, Black, Red
-
D.
Black, Black, Red
Solution
The sequence Black, Red, Black is valid as it adheres to the Red-Black tree properties.
Correct Answer:
B
— Black, Red, Black
Learn More →
Q. Which of the following is a valid subnet mask for a Class C IP address?
-
A.
255.255.255.0
-
B.
255.255.0.0
-
C.
255.0.0.0
-
D.
255.255.255.255
Solution
A Class C IP address typically uses a subnet mask of 255.255.255.0, allowing for 256 addresses in the subnet.
Correct Answer:
A
— 255.255.255.0
Learn More →
Q. Which of the following is a valid use case for a stack?
-
A.
Undo functionality in applications
-
B.
Managing print jobs
-
C.
Handling requests in a web server
-
D.
All of the above
Solution
A stack is commonly used for undo functionality in applications.
Correct Answer:
A
— Undo functionality in applications
Learn More →
Q. Which of the following is a valid variable declaration in C?
-
A.
int 1number;
-
B.
float number1;
-
C.
char number#;
-
D.
double number@;
Solution
The valid variable declaration in C is float number1; as variable names cannot start with a digit or contain special characters.
Correct Answer:
B
— float number1;
Learn More →
Q. Which of the following is a valid way to append an element to a linked list in Python?
-
A.
list.append(value)
-
B.
linked_list.add(value)
-
C.
linked_list.append(value)
-
D.
list.add(value)
Solution
In Python, a linked list typically has an append method defined, so linked_list.append(value) is correct.
Correct Answer:
C
— linked_list.append(value)
Learn More →
Q. Which of the following is a valid way to implement a binary tree in C++?
-
A.
Using an array
-
B.
Using a linked list
-
C.
Using a struct
-
D.
All of the above
Solution
A binary tree can be implemented using an array, a linked list, or a struct in C++. Each method has its own advantages and use cases.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following is a valid way to implement a binary tree in Python?
-
A.
Using a list
-
B.
Using a dictionary
-
C.
Using a class
-
D.
All of the above
Solution
A binary tree can be implemented using various data structures in Python, including lists, dictionaries, and custom classes.
Correct Answer:
D
— All of the above
Learn More →
Q. Which of the following is a valid way to implement a binary tree node in C++?
-
A.
struct Node { int data; Node* left; Node* right; };
-
B.
class Node { int data; Node left; Node right; };
-
C.
struct Node { int data; Node left; Node right; };
-
D.
class Node { public: int data; Node* left; Node* right; };
Solution
The correct implementation uses pointers for left and right children, and the class should have public access for the members.
Correct Answer:
D
— class Node { public: int data; Node* left; Node* right; };
Learn More →
Q. Which of the following is a valid way to implement a binary tree node in Python?
-
A.
class Node: def __init__(self, value): self.value = value
-
B.
class Node: def __init__(self, value): self.value = value; self.left = None; self.right = None
-
C.
class Node: def __init__(self): self.value = None
-
D.
class Node: def __init__(self, value): self.left = None; self.right = None
Solution
A valid binary tree node implementation includes left and right pointers, allowing for the structure of a binary tree.
Correct Answer:
B
— class Node: def __init__(self, value): self.value = value; self.left = None; self.right = None
Learn More →
Q. Which of the following is a valid way to represent a binary tree node in C++?
-
A.
struct Node { int data; Node* left; Node* right; };
-
B.
class Node { int data; Node* left; Node* right; };
-
C.
struct Node { int data; Node left; Node right; };
-
D.
class Node { int data; Node left; Node right; };
Solution
The correct representation of a binary tree node in C++ is using a struct with pointers to the left and right children.
Correct Answer:
A
— struct Node { int data; Node* left; Node* right; };
Learn More →
Q. Which of the following is an advantage of using intermediate code?
-
A.
It simplifies the parsing process
-
B.
It allows for easier debugging
-
C.
It enables machine-independent optimizations
-
D.
It eliminates the need for a front-end
Solution
Intermediate code allows for optimizations that are independent of the target machine, making it easier to optimize across different architectures.
Correct Answer:
C
— It enables machine-independent optimizations
Learn More →
Q. Which of the following is an application of a queue?
-
A.
Undo functionality in text editors
-
B.
Breadth-first search in graphs
-
C.
Expression evaluation
-
D.
Memory management
Solution
Queues are used in breadth-first search algorithms for traversing graphs, as they process nodes in the order they are discovered.
Correct Answer:
B
— Breadth-first search in graphs
Learn More →
Q. Which of the following is an application of clustering in real-world scenarios?
-
A.
Spam detection in emails
-
B.
Customer segmentation in marketing
-
C.
Predicting stock prices
-
D.
Image classification
Solution
Customer segmentation in marketing uses clustering to group customers based on purchasing behavior.
Correct Answer:
B
— Customer segmentation in marketing
Learn More →
Q. Which of the following is an application of Dijkstra's algorithm?
-
A.
Finding the shortest route in GPS navigation
-
B.
Sorting a list of numbers
-
C.
Searching for an element in a binary search tree
-
D.
Calculating the factorial of a number
Solution
Dijkstra's algorithm is commonly used in GPS navigation systems to find the shortest route between locations.
Correct Answer:
A
— Finding the shortest route in GPS navigation
Learn More →
Q. Which of the following is an application of queues?
-
A.
Undo functionality in text editors
-
B.
Breadth-first search in graphs
-
C.
Expression evaluation
-
D.
Memory management
Solution
Queues are used in breadth-first search algorithms for traversing graphs, as they follow the FIFO (First In, First Out) principle.
Correct Answer:
B
— Breadth-first search in graphs
Learn More →
Q. Which of the following is an example of a classification algorithm?
-
A.
Linear Regression
-
B.
Logistic Regression
-
C.
K-Means Clustering
-
D.
Principal Component Analysis
Solution
Logistic Regression is a classification algorithm used to predict binary outcomes based on input features.
Correct Answer:
B
— Logistic Regression
Learn More →
Q. Which of the following is an example of a cloud service?
-
A.
Google Drive
-
B.
Microsoft Word
-
C.
Adobe Photoshop
-
D.
Notepad
Solution
Google Drive is an example of a cloud service.
Correct Answer:
A
— Google Drive
Learn More →
Q. Which of the following is an example of a problem that can be solved using divide and conquer?
-
A.
Binary search
-
B.
Fibonacci sequence
-
C.
Linear search
-
D.
Bubble sort
Solution
Binary search is an example of a divide and conquer algorithm, as it divides the search space in half.
Correct Answer:
A
— Binary search
Learn More →
Q. Which of the following is an example of a problem that can be solved using dynamic programming?
-
A.
Finding the maximum sum of a contiguous subarray
-
B.
Finding the maximum element in an array
-
C.
Sorting an array of integers
-
D.
Searching for an element in an unsorted array
Solution
Finding the maximum sum of a contiguous subarray can be solved using dynamic programming, specifically with Kadane's algorithm.
Correct Answer:
A
— Finding the maximum sum of a contiguous subarray
Learn More →
Q. Which of the following is an example of a regression algorithm?
-
A.
K-Means
-
B.
Logistic Regression
-
C.
Random Forest
-
D.
Support Vector Classifier
Solution
Logistic Regression is a regression algorithm used for predicting binary outcomes, despite its name suggesting classification.
Correct Answer:
B
— Logistic Regression
Learn More →
Showing 2701 to 2730 of 3237 (108 Pages)