Q. How do stacks help in the execution of function calls in programming languages?
-
A.
They store global variables.
-
B.
They manage the order of execution.
-
C.
They keep track of local variables and return addresses.
-
D.
They optimize memory usage.
Solution
Stacks keep track of local variables and return addresses during function calls, enabling proper execution flow.
Correct Answer:
C
— They keep track of local variables and return addresses.
Learn More →
Q. In which scenario would a circular queue be preferred over a regular queue?
-
A.
When memory is limited
-
B.
When elements need to be sorted
-
C.
When implementing a stack
-
D.
When processing data in a LIFO manner
Solution
Circular queues are preferred in scenarios with limited memory as they efficiently utilize available space.
Correct Answer:
A
— When memory is limited
Learn More →
Q. In which scenario would a queue be the most appropriate data structure to use?
-
A.
Reversing a string
-
B.
Processing tasks in a printer
-
C.
Evaluating expressions
-
D.
Implementing a backtracking algorithm
Solution
Queues are ideal for processing tasks in a printer, as they follow the First-In-First-Out (FIFO) principle.
Correct Answer:
B
— Processing tasks in a printer
Learn More →
Q. What is a common use of stacks in web browsers?
-
A.
Storing bookmarks
-
B.
Managing history of visited pages
-
C.
Downloading files
-
D.
Rendering web pages
Solution
Stacks are used to manage the history of visited pages, allowing users to navigate back and forth.
Correct Answer:
B
— Managing history of visited pages
Learn More →
Q. What is a practical use of a stack in parsing expressions?
-
A.
To store operands
-
B.
To evaluate postfix expressions
-
C.
To manage memory allocation
-
D.
To sort elements
Solution
Stacks are used to evaluate postfix expressions by holding operators and operands in the correct order.
Correct Answer:
B
— To evaluate postfix expressions
Learn More →
Q. What role do stacks play in backtracking algorithms?
-
A.
They store the final result.
-
B.
They keep track of the path taken.
-
C.
They sort the elements.
-
D.
They manage memory allocation.
Solution
Stacks are used in backtracking algorithms to keep track of the path taken, allowing the algorithm to revert to previous states.
Correct Answer:
B
— They keep track of the path taken.
Learn More →
Q. Which data structure would you use to implement a task scheduling system?
-
A.
Stack
-
B.
Queue
-
C.
Linked List
-
D.
Array
Solution
A queue is suitable for task scheduling systems as it processes tasks in the order they arrive.
Correct Answer:
B
— Queue
Learn More →
Q. Which of the following best describes a real-world application of queues?
-
A.
Call center systems
-
B.
File compression algorithms
-
C.
Sorting algorithms
-
D.
Binary search trees
Solution
Queues are commonly used in call center systems to manage incoming calls in the order they are received.
Correct Answer:
A
— Call center systems
Learn More →
Q. Which of the following is a real-world application of a stack?
-
A.
Undo functionality in text editors
-
B.
Managing print jobs in a printer
-
C.
Handling requests in a web server
-
D.
Storing user sessions in a database
Solution
Stacks are used in text editors to implement the undo functionality, allowing users to revert to previous states.
Correct Answer:
A
— Undo functionality in text editors
Learn More →
Showing 1 to 9 of 9 (1 Pages)