wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

202508500004

Total questions: 40

Worksheet time: 40mins

Name
Class
Date
1.

Which approach is optimal to find the smallest missing positive number in an unsorted array?

a)

Sorting

b)

HashMap

c)

In-place Indexing

d)

Binary Search

e)

Greedy

2.

What is the time complexity of rotating an array of n elements by k positions (using reversal algorithm)?

a)

O(nk)

b)

O(log n)

c)

O(n)

d)

O(k)

e)

O(n log n)

3.

What’s the optimal way to design a circular queue using array?

a)

Push from front

b)

Push using two arrays

c)

Use front and rear pointers with modulo

d)

Doubly Linked List

e)

Prefix tree

4.

Time complexity to reverse a doubly linked list?

a)

O(log n)

b)

O(n)

c)

O(1)

d)

O(n²)

e)

O(n log n)

5.

Which of the following cannot be implemented using a linked list?

a)

Stack

b)

Queue

c)

Hash Table

d)

Random Access Array

e)

Deque

6.

In a Binary Tree, the diameter is the:

a)

Max number of leaves

b)

Depth of root

c)

Longest path between any two nodes

d)

Height + width

e)

Sum of left subtree

7.

Which of the following trees is ideal for implementing priority queues?

a)

Binary Search Tree

b)

AVL Tree

c)

Heap

d)

Red-Black Tree

e)

Segment Tree

8.

Which algorithm finds all pairs shortest paths in a graph?

a)

Dijkstra

b)

Prim

c)

Floyd-Warshall

d)

DFS

e)

Kruskal

9.

Which sorting is NOT stable?

a)

Merge Sort

b)

Insertion Sort

c)

Bubble Sort

d)

Heap Sort

e)

Tim Sort

10.

Which sorting algorithm is best suited for large data that doesn’t fit into memory (external sort)?

a)

QuickSort

b)

HeapSort

c)

MergeSort

d)

Insertion Sort

e)

Bubble Sort

11.

Which sorting algorithm is stable and not in-place?

a)

Heap Sort

b)

Quick Sort

c)

Merge Sort

d)

Selection Sort

e)

Shell Sort

12.

Which of the following problems is not typically solved using dynamic programming?

a)

Longest Common Subsequence

b)

Matrix Chain Multiplication

c)

Dijkstra's Algorithm

d)

Longest Increasing Subsequence

e)

Coin Change

13.

Which technique converts a recursive algorithm into a bottom-up form?

a)

Top-down DP

b)

Memoization

c)

Tabulation

d)

Divide and Conquer

e)

Greedy method

14.

In a social media app, you need to suggest mutual friends using common connections. Which algorithm is best suited for this?

a)

Dijkstra

b)

Kruskal

c)

DFS

d)

BFS

e)

Floyd-Warshall

15.

Which statement about NULL in SQL is true?

a)

NULL = NULL is TRUE

b)

NULL can be indexed

c)

NULL is a string

d)

NULL cannot be compared directly

e)

NULLs are stored as 0

16.

A transaction must ensure other transactions cannot view its intermediate states. Which ACID property is this?

a)

Atomicity

b)

Consistency

c)

Isolation

d)

Durability

e)

Idempotency

17.

Which constraint ensures that two rows in a relation do not have the same value for a certain attribute?

a)

Foreign Key

b)

Check

c)

Primary Key

d)

Not Null

e)

Index

18.

You're using 3NF, but find that data anomalies still occur due to transitive dependencies. What should you normalize to?

a)

2NF

b)

BCNF

c)

4NF

d)

3NF

19.

Which join returns Cartesian product?

a)

INNER JOIN

b)

LEFT JOIN

c)

RIGHT JOIN

d)

FULL JOIN

e)

CROSS JOIN

20.

Which SQL clause restricts the number of rows returned?

a)

OFFSET

b)

WHERE

c)

LIMIT

d)

COUNT

e)

ORDER BY

21.

What is the result of SELECT NULL + 100; in SQL?

a)

100

b)

NULL

c)

Error

d)

0

e)

1

22.

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);

a)

Valid

b)

Invalid subquery

c)

Needs GROUP BY

d)

Must use JOIN

e)

Missing WHERE

23.

Choose the correct statement to fetch the third highest salary:

a)

SELECT TOP 3 salary FROM employees ORDER BY salary DESC;

b)

SELECT DISTINCT salary FROM employees ORDER BY salary DESC LIMIT 2,1;

c)

SELECT salary FROM employees ORDER BY salary DESC LIMIT 2,1;

d)

SELECT salary FROM (SELECT salary FROM employees ORDER BY salary DESC LIMIT 3) ORDER BY salary LIMIT 1;

e)

SELECT salary FROM employees WHERE ROWNUM = 3;

24.

To get the total salary department-wise, you should use the function __________ with GROUP BY.

a)

COUNT

b)

AVG

c)

MAX

d)

SUM

25.

In a JOIN condition, you link two tables using the __________ keyword.

a)

ON

b)

USING

c)

WHERE

d)

FROM

e)

CONNECT

26.

The __________ statement is used to remove all records from a table but retain its structure.

a)

DROP

b)

DELETE

c)

ERASE

d)

TRUNCATE

27.

Which query finds the total salary per department for departments with more than 2 employees?

a)

SELECT department_id, SUM(salary) FROM employees GROUP BY department_id HAVING COUNT(*) > 2;

b)

SELECT department_id, salary FROM employees HAVING COUNT(*) > 2;

c)

SELECT department_id, SUM(salary) FROM employees WHERE COUNT(*) > 2;

d)

SELECT SUM(salary) FROM employees GROUP BY salary;

e)

SELECT department_id, salary FROM employees WHERE salary > 50000;

28.

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);

a)

Returns all employees with unique salaries

b)

Returns employees who share the same salary with others

c)

Returns NULL

d)

Returns top-paid employees

e)

Returns department heads

29.

A subclass redefines a method from its superclass. What is this called?

a)

Overloading

b)

Overriding

c)

Overruling

d)

None of the mentioned

e)

Masking

30.

You want a class to inherit properties from multiple unrelated classes. What should you use in a language that doesn't support multiple inheritance?

a)

Interfaces

b)

Abstract classes

c)

Friend functions

d)

Static members

e)

Composition only

31.

If class Dog inherits from Animal and overrides speak(), and is used in a method expecting Animal, this is an example of:

a)

Covariant return types

b)

Polymorphism

c)

Composition

d)

Type casting

e)

Interface Segregation

32.

In a payment system, you use a base interface PaymentMethod and classes like CreditCard, UPI, NetBanking. Which OOP feature allows this?

a)

Abstraction

b)

Polymorphism

c)

Encapsulation

d)

Inheritance

e)

Delegation

33.

What is meant by an abstract class?

a)

Cannot be instantiated

b)

Cannot have methods

c)

Can only be used once

d)

Only has static members

e)

Cannot be inherited

34.

What is polymorphic behavior in OOP?

a)

Method overloading

b)

Static method reuse

c)

Behavior change at runtime

d)

Method chaining

e)

Data hiding

35.

Which of the following is a violation of encapsulation?

a)

Use of private fields

b)

Public getters/setters

c)

Making all data public

d)

Hiding internal implementation

e)

Using access modifiers

36.

What is the Diamond Problem in OOP?

a)

Recursion depth exceeded

b)

Memory allocation failure

c)

Multiple inheritance ambiguity

d)

Overriding failure

e)

Object slicing

37.

What’s the advantage of IPv6 over IPv4?

a)

Less bandwidth

b)

Shorter addresses

c)

More address space

d)

Easier subnetting

e)

Lower latency

38.

Which of the following is not connection-oriented?

a)

TCP

b)

SCTP

c)

FTP

d)

UDP

e)

Telnet

39.

How many bits are used in IPv6 address?

a)

32

b)

48

c)

64

d)

128

e)

256

40.

Which one is used in LRU page replacement?

a)

FIFO queue

b)

Priority queue

c)

Stack

d)

Circular queue

e)

Random selection