Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Problem Solving Using ProgrammingEasy
Q1. First step in programming problem?
- A.Choose the programming language
- B.Start coding right away now
- C.Understand requirements and constraints✓ Correct
- D.Open the IDE and create files
Explanation
Understanding first.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q2. What is a variable?
- A.A constant that never changes
- B.A loop construct in the program
- C.A function definition in code
- D.Named storage with changeable value✓ Correct
Explanation
Named changeable storage.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q3. What is a function?
- A.A data structure for storage
- B.Reusable block for a specific task✓ Correct
- C.A variable type declaration
- D.A file format for saving data
Explanation
Reusable code block.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q4. Purpose of return?
- A.Declare a new variable in scope
- B.Create a new loop construct
- C.Send value back, end the function✓ Correct
- D.Print output to the console
Explanation
Returns value, terminates function.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q5. What is a parameter?
- A.An error in the program logic
- B.Variable receiving value when called✓ Correct
- C.A global variable in the program
- D.The return type of a function
Explanation
Receives passed arguments.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q6. == vs =?
- A.Both are comparison operators
- B.= compares, == assigns values
- C.= assigns, == compares values✓ Correct
- D.They are the same operator
Explanation
Assignment vs equality.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q7. What is a string?
- A.A numeric data type value
- B.A callable function reference
- C.A boolean true/false value
- D.A sequence of characters stored✓ Correct
Explanation
Character sequence.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q8. What is if-else for?
- A.Looping through elements repeatedly
- B.Making decisions based on conditions✓ Correct
- C.Importing external code modules
- D.Declaring new variable bindings
Explanation
Conditional execution.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q9. What is list/array for?
- A.Performing math calculations only
- B.Displaying output on the screen
- C.Ordered collection of multiple values✓ Correct
- D.Storing a single value only
Explanation
Ordered value collection.
Report an error in this question
Problem Solving Using ProgrammingEasy
Q10. What does DRY mean?
- A.Don't Repeat Yourself ever✓ Correct
- B.Do Repeat Yourself always
- C.Dev Run Yield automation
- D.Do Run Yesterday's builds
Explanation
Avoid duplication.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q11. Modular code benefit?
- A.Smaller testable reusable pieces made✓ Correct
- B.It makes the program run slower
- C.It uses significantly more memory
- D.It makes code much longer overall
Explanation
Testable and reusable.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q12. Find max in unsorted array?
- A.Use binary search on the array
- B.Sort the entire array first
- C.Iterate tracking the maximum value✓ Correct
- D.Use a hash table for lookup
Explanation
Iterate tracking the maximum value is the correct answer to this question.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q13. What is variable scope?
- A.The data type of the variable
- B.The current value of the variable
- C.The name given to the variable
- D.The region where it is accessible✓ Correct
Explanation
Accessibility region.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q14. Recursion useful for?
- A.Self-similar sub-problem structures✓ Correct
- B.Replacing all loops in the code
- C.Only Fibonacci number computation
- D.It is always faster than loops
Explanation
Self-similar problems.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q15. Count char frequency efficiently?
- A.Use nested loops over the string
- B.Use hash map in one single pass✓ Correct
- C.Sort the string first then count
- D.Use recursion to count each char
Explanation
Use hash map in one single pass is the correct answer to this question.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q16. What is exception handling?
- A.A testing framework for the app
- B.Ignoring all errors in the code
- C.Handle runtime errors without crashing✓ Correct
- D.A design pattern for structure
Explanation
Graceful error handling.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q17. Reverse linked list?
- A.Sort the list then reverse order
- B.Change next pointers to point back✓ Correct
- C.Copy all elements to an array first
- D.Delete and recreate the whole list
Explanation
O(n) time, O(1) space.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q18. Check balanced parens?
- A.Hash table use
- B.Stack structure✓ Correct
- C.Array scanning
- D.Queue structure
Explanation
Push open, pop on match.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q19. Detect cycle in linked list?
- A.Count all the nodes in the list
- B.Sort the list nodes by value
- C.Check all pairs of nodes found
- D.Floyd's slow and fast pointers✓ Correct
Explanation
Two pointers at different speeds.
Report an error in this question
Problem Solving Using ProgrammingMedium
Q20. What is memoization?
- A.A debugging technique for errors
- B.Writing memos about the code
- C.Caching results to avoid recomputation✓ Correct
- D.A type of loop construct used
Explanation
Cache expensive results.
Report an error in this question
Problem Solving Using ProgrammingHard
Q21. Find LCS?
- A.DP with a 2D table approach✓ Correct
- B.Hashing all subsequences found
- C.Brute force all subsequences
- D.Simple character matching scan
Explanation
DP with 2D table.
Report an error in this question
Problem Solving Using ProgrammingHard
Q22. 0/1 Knapsack optimal?
- A.Sort items by weight first
- B.DP over items and capacities✓ Correct
- C.Greedy algorithm approach
- D.Random selection of items
Explanation
DP over items and capacities is the correct answer to this question.
Report an error in this question
Problem Solving Using ProgrammingHard
Q23. LRU cache efficient implementation?
- A.Only an array data structure
- B.A stack-based data structure
- C.A binary search tree structure
- D.Hash map plus doubly linked list✓ Correct
Explanation
O(1) get and put.
Report an error in this question
Problem Solving Using ProgrammingHard
Q24. All connected components?
- A.BFS/DFS from unvisited vertices✓ Correct
- B.Use hash table for the lookup
- C.Check all pairs of vertex nodes
- D.Sort all the vertices first
Explanation
BFS/DFS from unvisited vertices is the correct answer to this question.
Report an error in this question
Problem Solving Using ProgrammingHard
Q25. What is tree DP?
- A.Sorting the tree node values
- B.Balancing the tree structure
- C.Bottom-up from children results✓ Correct
- D.Simple tree traversal method
Explanation
Computes per subtree bottom-up.
Report an error in this question
Problem Solving Using ProgrammingHard
Q26. Median in stream?
- A.Two heaps: max lower, min upper✓ Correct
- B.Use a single array for storage
- C.Sort the entire stream each time
- D.Use a linked list for ordering
Explanation
O(log n) insert, O(1) median.
Report an error in this question
Problem Solving Using ProgrammingHard
Q27. Bit manipulation for?
- A.Making code completely unreadable
- B.Graphics rendering operations only
- C.Low-level hardware drivers only
- D.Sets, flags, and O(1) optimizations✓ Correct
Explanation
Efficient bit operations.
Report an error in this question
Problem Solving Using ProgrammingHard
Q28. Shortest path unweighted?
- A.BFS from the source vertex✓ Correct
- B.Bellman-Ford algorithm approach
- C.Dijkstra's algorithm approach
- D.DFS from the source vertex
Explanation
BFS from the source vertex is the correct answer to this question.
Report an error in this question
Problem Solving Using ProgrammingHard
Q29. What is segment tree?
- A.Sorting segments of an array
- B.String matching and pattern search
- C.Range queries and updates in O(log n)✓ Correct
- D.Graph traversal and pathfinding
Explanation
Efficient range operations.
Report an error in this question
Problem Solving Using ProgrammingHard
Q30. Find articulation points?
- A.BFS from every vertex in the graph
- B.Sort the graph vertices by degree
- C.Tarjan's DFS with discovery/low values✓ Correct
- D.Check all vertices by removal
Explanation
Tarjan's DFS with discovery/low values is the correct answer to this question.
Report an error in this question