Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

Data Structures and Algorithms → Introduction to DSA 21

Catalan number C(n) counts?
Distinct BSTs with n keys
click to copy
Which sorting is best for only 0s, 1s, 2s?
Dutch National Flag (3-way partition)
click to copy
Building a heap from n elements time complexity?
O(n)
click to copy
What is a sparse graph?
Few edges relative to vertices
click to copy
2-3 tree is?
B-tree of order 3 (each internal node 2 or 3 children)
click to copy
Python list.pop(0) vs list.pop() difference?
pop(0) removes front O(n); pop() removes end O(1)
click to copy
BTreeSearch returns if key not found?
NIL (NULL)
click to copy
mid in mergesort([5,9,10,1,66])?
2
click to copy
Result of quicksort([56,25,93,15,31,44])?
[15,25,31,44,56,93]
click to copy
Binary search on [12,24,32,39,45,50,54] for 45 returns?
4
click to copy
dict.items() returns?
All key-value pairs as tuples
click to copy
Python set vs list membership check?
List O(n); Set O(1) average
click to copy
Tuple vs list in Python?
Tuple immutable and hashable; List mutable
click to copy
Ford-Fulkerson algorithm solves:
Maximum flow in a network
click to copy
Longest Increasing Subsequence (LIS) of {3,10,2,1,20} has length:
3
click to copy
Matrix Chain Multiplication uses which technique?
Dynamic Programming
click to copy
Edit distance (Levenshtein distance) between "kitten" and "sitting" is:
3
click to copy
Coin change problem (minimum coins) uses:
Dynamic Programming for general case
click to copy
KMP (Knuth-Morris-Pratt) algorithm efficiently solves:
String pattern matching in O(n+m)
click to copy
The failure function in KMP is used to:
Skip unnecessary comparisons by tracking longest proper prefix-suffix
click to copy
Rabin-Karp algorithm uses:
Rolling hash for efficient multi-pattern search
click to copy

Data Structures and Algorithms → Sorting Algorithms 7

Heap sort total time complexity?
O(n log n)
click to copy
Quick sort space complexity?
O(log n) average call stack
click to copy
Merge step of merge sort for two halves of size n/2?
O(n)
click to copy
Selection sort best case time complexity?
O(n²)
click to copy
Number of levels in merge sort for n=8?
3
click to copy
In bubble sort after one pass on [9,16,6,26,0], result?
[9,6,16,0,26]
click to copy
Selection sort result on [5,3,7,1,9,6]?
[1,3,5,6,7,9]
click to copy

Data Structures and Algorithms → Linked List 1

Best sorting for linked list with nearly sorted data?
Insertion sort
click to copy

Data Structures and Algorithms → Binary Search Tree 1

Maximum height of BST with n nodes?
n-1 (skewed tree)
click to copy

Data Structures and Algorithms → Trees 2

In B-tree, keys within each node stored in?
Increasing order
click to copy
B-tree maximum height formula for n keys, order t?
log_t((n+1)/2)
click to copy

Data Structures and Algorithms → Queue 2

deque.appendleft() equivalent to?
Insert at front of queue
click to copy
Queue remaining after enqueue(A,B,C),dequeue(),enqueue(D),dequeue()?
C,D
click to copy

Data Structures and Algorithms → Stack 3

Stack output after push(Amar,Akbar,Anthony,Ram,Iqbal),pop()?
Iqbal
click to copy
Final stack after push(1),push(2),pop(),push(3),push(4),pop(),pop()?
[1]
click to copy
Stack remaining after push(5),push(3),pop(),push(7),push(1),pop(),pop()?
[5]
click to copy

Data Structures and Algorithms → Graphs 1

Kruskal algorithm finds MST by:
Sorting all edges and adding non-cycle-forming edges
click to copy

Data Structures and Algorithms → Dynamic Programming 2

Which problem is solved by dynamic programming with O(nW) complexity?
0/1 Knapsack problem
click to copy
Longest Common Subsequence (LCS) of "ABCBDAB" and "BDCABA" has length:
4
click to copy