Q1. What SQL query finds the second highest salary?
a) SELECT MAX(salary) FROM employee
b) SELECT MAX(salary) FROM employee WHERE salary < (SELECT MAX(salary)
FROM employee)
c) SELECT salary FROM employee LIMIT 2
d) SELECT salary FROM employee WHERE salary != MAX(salary)
Q2. What is the behavior of operation D in arrays under typical usage?
a) Crashes the program b) Executes in O(1) c) Executes in O(n) d) Returns null
Q3. Kadane’s Algorithm is used to:
a) Find pivot index
b) Find min subarray
c) Find max subarray sum
d) Find subarray product
Q4. What will the expression str1 + str2 do in Python if both are strings?
a) Replace str1 b) Concatenate the strings c) Compare them d) Return the length
Q5. What is the most efficient approach for solving Two Sum problem?
a) Brute force
b) Sorting
c) Hash Map
d) Binary Search
Q6. What is the worst-case time complexity for pushing n elements into a stack?
a) O(log n) b) O(n) c) O(n log n) d) O(1)
Q7. What is the output of sliding window max for [1,3,-1,-3,5,3,6,7], k=3?
a) [3, 3, 5, 5, 6, 7] b) [1, 3, -1, -3] c) [1, 1, 1, 1] d) [7, 6, 5, 3]
Q8. Which SQL clause is used to sort the result set?
a) GROUP BY b) WHERE c) ORDER BY d) HAVING
Q9. Which of these data structures supports LIFO order?
a) Queue b) Stack c) Array d) Tree
Q10. To remove the Nth node from the end, which technique is ideal?
a) Recursion b) Double pointer method c) Brute-force d) Hashing
Q11. What is the behavior of operation C in strings under typical usage?
a) Crashes the program b) Executes in O(1) c) Executes in O(n) d) Returns null
Q12. Which operation is used to insert a node at the beginning of a singly linked list?
a) append() b) insertTail() c) insertHead() d) deleteHead()
Q13. How do you detect a cycle in a linked list?
a) DFS b) Recursion c) Floyd’s cycle-finding algorithm d) Binary Search
Q14. Grouping anagrams efficiently requires:
a) Bubble Sort b) HashMap of sorted strings c) Brute force d) Tree
Q15. What is the time complexity to reverse a singly linked list?
a) O(1) b) O(log n) c) O(n) d) O(n²)
Q16. What is the purpose of maintaining another stack in a Min Stack?
a) Recursion b) Track min values c) Sorting d) Hashing
Q17. Which of the following is not a string manipulation function in SQL?
a) CONCAT() b) LENGTH() c) SUBSTR() d) POWER()
Q18. What is the behavior of operation B in databases under typical usage?
a) Crashes the program b) Executes in O(1) c) Executes in O(n) d) Returns null
Q19. In a stream of characters, how is the first non-repeating character efficiently tracked?
a) Stack b) HashMap + Queue c) Array d) Heap
Q20. Evaluate Reverse Polish Notation: ["2", "3", "1", "*", "+", "9", "-"]
a) -2 b) 2 c) 4 d) -4
Q21. Longest substring without repeating characters uses:
a) Stack b) Sliding Window + HashSet c) Recursion d) Heap
Q22. What does the DENSE_RANK() function do?
a) Skips ranks b) Assigns same rank for ties without gaps c) Unique ranks d) Ranks
by time
Q23. What happens when you merge two sorted linked lists?
a) One becomes empty b) Random merge c) New sorted list d) No change
Q24. Which algorithm is used to find the majority element (>n/2 times)?
a) Binary Search b) Kadane's c) Boyer-Moore Voting Algorithm d) Merge Sort
Q25. What is the space complexity of a queue storing n elements?
a) O(log n) b) O(1) c) O(n) d) O(n²)
Q26. What is the result of len("abcde") in Python?
a) 6 b) 5 c) 4 d) Error
Q27. What SQL is used to find duplicate emails?
a) WHERE COUNT > 1 b) GROUP BY + HAVING c) WHERE email = duplicate d)
WHERE duplicate = true
Q28. What is the main idea behind Dutch National Flag problem?
a) Merge Sort b) Three pointers c) Insertion Sort d) Two stacks
Q29. Which method helps avoid overflow in circular queue?
a) Hashing b) Recursion c) Rear wraps to front d) Sentinel node
Q30. What is the best approach to find the first repeating element in an array?
a) Brute Force b) Hash Set c) Binary Search d) Stack
Q31. What is the behavior of operation A in stacks under typical usage?
a) Crashes the program b) Executes in O(1) c) Executes in O(n) d) Returns null
Q32. What SQL clause gets department with highest avg salary?
a) GROUP BY only b) GROUP + HAVING c) GROUP BY + ORDER BY + LIMIT
d) Subquery
Q33. To check if two strings are rotations of each other:
a) Reverse one b) Concatenate + check substring c) Sort d) Count characters
Q34. What is the behavior of operation C in linked lists under typical usage?
a) Crashes the program b) Executes in O(1) c) Executes in O(n) d) Returns null
Q35. Which data structure is ideal for checking balanced parentheses in an expression?
a) Queue b) Linked List c) Hash Map d) Stack
Q36. What is the behavior of operation D in arrays under typical usage?
a) Crashes the program b) Executes in O(1) c) Executes in O(n) d) Returns null
Q37. What SQL clause is used to combine rows from two or more tables?
a) DELETE b) ADD c) JOIN d) UPDATE
Q38. Compress the string “aabcccccaaa”:
a) abc5a3 b) a2bc5a3 c) a2b1c5a3 d) aabcccccaaa
Q39. Which of the following requires O(n) in a queue using two stacks?
a) isEmpty() b) Enqueue c) Dequeue d) Peek
Q40. What happens when stack pop() is called on empty stack?
a) 0 b) -1 c) Underflow Error d) None
Q41. Which is the best data structure for BFS?
a) Stack b) Queue c) Tree d) Graph
Q42. What does GROUP BY do in SQL?
a) Filters rows b) Groups rows by field c) Orders output d) Removes duplicates
Q43. How do you track the minimum value in a Min Stack?
a) Use sorting b) Maintain auxiliary stack c) Recursion d) Counter
Q44. What is the best method for majority element (>n/2)?
a) Divide and conquer b) Binary search c) Boyer-Moore algorithm d) Counting sort
Q45. Which data structure is used in backtracking problems like recursion calls?
a) Queue b) Stack c) Heap d) Linked List
Q46. How to reverse a singly linked list?
a) Recursively b) Stack c) Tail pointer d) Iteratively O(n)
Q47. SQL command to remove duplicates from result?
a) DISTINCT b) SELECT DISTINCT c) UNIQUE d) REMOVE
Q48. What is the result of 3 + 4 * 2 in postfix?
a) 14 b) 11 c) 10 d) 12
Q49. What is the time complexity of enqueue in queue?
a) O(1) b) O(1) c) O(n) d) O(log n)
Q50. Which Python method returns length of a string?
a) size() b) count() c) len() d) length()
Q51. How to remove the tail node in a singly linked list?
a) Update head b) Swap nodes c) Traverse till second last and set next to NULL d)
Pop front
Q52. Optimal way to check if a string is a palindrome?
a) Hashing b) Stack c) Two pointers d) Heap
Q53. Fastest method to implement multiple queues?
a) List of stacks b) Hash table c) Array with multiple front/rear d) Deque
Q54. Best data structure for undo functionality?
a) Queue b) Stack c) Array d) Graph
Q55. What is the complexity of finding max in unsorted array?
a) O(log n) b) O(n) c) O(n²) d) O(1)
Q56. Hash table resolves collision by:
a) Stacks b) Queues c) Chaining or open addressing d) Sorting
Q57. Which SQL clause filters records before grouping?
a) HAVING b) WHERE c) ORDER BY d) GROUP BY
Q58. What’s a property of stack?
a) FIFO b) LIFO c) LILO d) FILO
Q59. What’s the fastest way to reverse a string in Python?
a) reverse() b) [::-1] slicing c) loop d) stack
Q60. Data structure for implementing recursion internally?
a) Heap b) Stack c) Queue d) Tree
Q61. What’s used to process printer tasks?
a) Stack b) Queue c) Heap d) Graph
Q62. Which operation is faster in array than linked list?
a) Insertion b) Deletion c) Access by index d) Append
Q63. What causes stack overflow?
a) Emptying a stack b) Infinite recursion c) Exceeding stack size d) Popping from stack
Q64. Which is not a basic SQL type?
a) INT b) VARCHAR c) BOOLEAN d) STRING
Q65. Max subarray sum can be found using:
a) Divide & Conquer b) Merge Sort c) Kadane’s Algorithm d) Binary Search
Q66. What is the time complexity of traversing a linked list?
a) O(1) b) O(n) c) O(log n) d) O(n²)
Q67. Which method efficiently handles duplicates in an array?
a) Stack b) Hash Map c) Linked List d) Queue
Q68. What SQL clause removes duplicates?
a) REMOVE b) DISTINCT c) UNIQUE d) OMIT
Q69. Two Sum optimized solution uses:
a) Sorting b) Hashing c) Brute Force d) Searching
Q70. Which is best for insert/delete at beginning?
a) Array b) Stack c) Linked List d) Hash Table
Q71. In a queue, front points to:
a) Last element b) First element c) Middle d) None
Q72. What’s the output of int(3.5) in Python?
a) 4 b) 3 c) 3.5 d) Error
Q73. What is used to track all recursive calls?
a) Queue b) Call Stack c) Heap d) Function List
Q74. HashMap in Python is implemented as:
a) Array b) List c) Dictionary d) Tuple
Q75. Which algorithm is used to find LIS?
a) Kadane b) DP with Binary Search c) Brute force d) Merge Sort
Q76. What is str[::2] in Python?
a) Reverses string b) Duplicates it c) Skips every second char d) Throws error
Q77. Which is a non-primitive data type?
a) int b) float c) Linked List d) char
Q78. What is peek in stack?
a) Return top element without removing b) Insert top c) Delete all d) Reverse
Q79. What does SQL HAVING filter?
a) Before grouping b) WHERE clause results c) After GROUP BY d) JOINs
Q80. In C/C++, what is the NULL pointer?
a) -1 b) 0 c) 1 d) None
Q81. Best data structure for LRU cache?
a) Stack b) HashMap + Doubly Linked List c) Queue d) Tree
Q82. Advantage of array over linked list?
a) Deletion b) Dynamic size c) Random access d) Memory use
Q83. What SQL keyword renames a column?
a) RENAME b) AS c) CHANGE d) LABEL
Q84. Which one is stable sorting algorithm?
a) Selection Sort b) Merge Sort c) Heap Sort d) Quick Sort
Q85. Time complexity to insert in middle of array?
a) O(log n) b) O(n) c) O(1) d) O(n log n)
Q86. What’s time to insert into stack?
a) O(n) b) O(1) c) O(log n) d) O(n²)
Q87. How to access last character of string s?
a) s[length] b) s[len(s)] c) s[-1] d) s[0]
Q88. Which is not SQL join type?
a) INNER b) OUTER c) CENTER d) LEFT
Q89. Array index starts from:
a) 1 b) 0 c) 2 d) -1
Q90. To reverse a queue efficiently, we use:
a) Hashing b) Stack c) Graph d) Tree
Q91. What is the default return of function in C with no return?
a) 1 b) Garbage or undefined c) 0 d) NULL
Q92. Best way to avoid duplicate records in DB?
a) Index b) Trigger c) Unique key d) Primary key
Q93. In SQL, COUNT(*) returns:
a) Total rows b) NULLs only c) Strings d) Column count
Q94. Best structure for "Undo" functionality in editor?
a) Array b) Stack c) Queue d) Tree
Q95. Which method is used to append in Python list?
a) add() b) insert() c) append() d) extend()
Q96. Is Python case-sensitive?
a) No b) Yes c) Sometimes d) Only for numbers
Q97. What is ASCII of 'A'?
a) 64 b) 65 c) 66 d) 67
Q98. Best way to remove last item in list?
a) pop(0) b) pop() c) del[0] d) remove()
Q99. Which one is immutable in Python?
a) List b) Tuple c) Dictionary d) Set
Q100. What is used to import SQL tables into Python?
a) NumPy b) Matplotlib c) Pandas d) Seaborn