NEW
Font size
Worksheets202508500004
Total questions: 40
Worksheet time: 40mins
Which approach is optimal to find the smallest missing positive number in an unsorted array?
Sorting
HashMap
In-place Indexing
Binary Search
Greedy
What is the time complexity of rotating an array of n elements by k positions (using reversal algorithm)?
O(nk)
O(log n)
O(n)
O(k)
O(n log n)
What’s the optimal way to design a circular queue using array?
Push from front
Push using two arrays
Use front and rear pointers with modulo
Doubly Linked List
Prefix tree
Time complexity to reverse a doubly linked list?
O(log n)
O(n)
O(1)
O(n²)
O(n log n)
Which of the following cannot be implemented using a linked list?
Stack
Queue
Hash Table
Random Access Array
Deque
In a Binary Tree, the diameter is the:
Max number of leaves
Depth of root
Longest path between any two nodes
Height + width
Sum of left subtree
Which of the following trees is ideal for implementing priority queues?
Binary Search Tree
AVL Tree
Heap
Red-Black Tree
Segment Tree
Which algorithm finds all pairs shortest paths in a graph?
Dijkstra
Prim
Floyd-Warshall
DFS
Kruskal
Which sorting is NOT stable?
Merge Sort
Insertion Sort
Bubble Sort
Heap Sort
Tim Sort
Which sorting algorithm is best suited for large data that doesn’t fit into memory (external sort)?
QuickSort
HeapSort
MergeSort
Insertion Sort
Bubble Sort
Which sorting algorithm is stable and not in-place?
Heap Sort
Quick Sort
Merge Sort
Selection Sort
Shell Sort
Which of the following problems is not typically solved using dynamic programming?
Longest Common Subsequence
Matrix Chain Multiplication
Dijkstra's Algorithm
Longest Increasing Subsequence
Coin Change
Which technique converts a recursive algorithm into a bottom-up form?
Top-down DP
Memoization
Tabulation
Divide and Conquer
Greedy method
In a social media app, you need to suggest mutual friends using common connections. Which algorithm is best suited for this?
Dijkstra
Kruskal
DFS
BFS
Floyd-Warshall
Which statement about NULL in SQL is true?
NULL = NULL is TRUE
NULL can be indexed
NULL is a string
NULL cannot be compared directly
NULLs are stored as 0
A transaction must ensure other transactions cannot view its intermediate states. Which ACID property is this?
Atomicity
Consistency
Isolation
Durability
Idempotency
Which constraint ensures that two rows in a relation do not have the same value for a certain attribute?
Foreign Key
Check
Primary Key
Not Null
Index
You're using 3NF, but find that data anomalies still occur due to transitive dependencies. What should you normalize to?
2NF
BCNF
4NF
3NF
Which join returns Cartesian product?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL JOIN
CROSS JOIN
Which SQL clause restricts the number of rows returned?
OFFSET
WHERE
LIMIT
COUNT
ORDER BY
What is the result of SELECT NULL + 100; in SQL?
100
NULL
Error
0
1
Is below SQL statement returns employees whose salary is greater than the average salary of their department?
SELECT name FROM employees e
WHERE salary > (SELECT AVG(salary)
FROM employees
WHERE department_id = e.department_id);
Valid
Invalid subquery
Needs GROUP BY
Must use JOIN
Missing WHERE
Choose the correct statement to fetch the third highest salary:
SELECT TOP 3 salary FROM employees ORDER BY salary DESC;
SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 2,1;
SELECT salary FROM employees ORDER BY salary DESC LIMIT 2,1;
SELECT salary FROM (SELECT salary FROM employees ORDER BY salary DESC LIMIT 3) ORDER BY salary LIMIT 1;
SELECT salary FROM employees WHERE ROWNUM = 3;
To get the total salary department-wise, you should use the function __________ with GROUP BY.
COUNT
AVG
MAX
SUM
In a JOIN condition, you link two tables using the __________ keyword.
ON
USING
WHERE
FROM
CONNECT
The __________ statement is used to remove all records from a table but retain its structure.
DROP
DELETE
ERASE
TRUNCATE
Which query finds the total salary per department for departments with more than 2 employees?
SELECT department_id, SUM(salary) FROM employees GROUP BY department_id HAVING COUNT(*) > 2;
SELECT department_id, salary FROM employees HAVING COUNT(*) > 2;
SELECT department_id, SUM(salary) FROM employees WHERE COUNT(*) > 2;
SELECT SUM(salary) FROM employees GROUP BY salary;
SELECT department_id, salary FROM employees WHERE salary > 50000;
What is true about the following query? SELECT * FROM employees e1 WHERE EXISTS (SELECT 1 FROM employees e2 WHERE e1.salary = e2.salary AND e1.employee_id <> e2.employee_id);
Returns all employees with unique salaries
Returns employees who share the same salary with others
Returns NULL
Returns top-paid employees
Returns department heads
A subclass redefines a method from its superclass. What is this called?
Overloading
Overriding
Overruling
None of the mentioned
Masking
You want a class to inherit properties from multiple unrelated classes. What should you use in a language that doesn't support multiple inheritance?
Interfaces
Abstract classes
Friend functions
Static members
Composition only
If class Dog inherits from Animal and overrides speak(), and is used in a method expecting Animal, this is an example of:
Covariant return types
Polymorphism
Composition
Type casting
Interface Segregation
In a payment system, you use a base interface PaymentMethod and classes like CreditCard, UPI, NetBanking. Which OOP feature allows this?
Abstraction
Polymorphism
Encapsulation
Inheritance
Delegation
What is meant by an abstract class?
Cannot be instantiated
Cannot have methods
Can only be used once
Only has static members
Cannot be inherited
What is polymorphic behavior in OOP?
Method overloading
Static method reuse
Behavior change at runtime
Method chaining
Data hiding
Which of the following is a violation of encapsulation?
Use of private fields
Public getters/setters
Making all data public
Hiding internal implementation
Using access modifiers
What is the Diamond Problem in OOP?
Recursion depth exceeded
Memory allocation failure
Multiple inheritance ambiguity
Overriding failure
Object slicing
What’s the advantage of IPv6 over IPv4?
Less bandwidth
Shorter addresses
More address space
Easier subnetting
Lower latency
Which of the following is not connection-oriented?
TCP
SCTP
FTP
UDP
Telnet
How many bits are used in IPv6 address?
32
48
64
128
256
Which one is used in LRU page replacement?
FIFO queue
Priority queue
Stack
Circular queue
Random selection
