HomeSubjectsUniversityBlogAbout

Problem Solving Using Programming

Topic in Problem Solving & Analytical Skills

210 total MCQsShowing 30 with explanations10 Easy10 Medium10 Hard

About This Topic

Problem solving using programming means translating an analysed problem into working code with suitable data types, control structures and design. Basic questions cover the first steps of reading requirements and planning input and output, along with strings, arrays, functions and parameters. Strategy items ask how pre-sorting input simplifies duplicate detection or searching, and why top-down design and stepwise refinement keep programs manageable. Object-oriented questions touch encapsulation, inheritance and polymorphism, including the Liskov Substitution Principle and other SOLID guidelines, while concurrency items explore why immutable data avoids shared-state bugs.

Below are 30 practice questions from a pool of 210 Problem Solving Using Programming MCQs, one of 16 topics in Problem Solving & Analytical Skills. Each shows the correct answer with an explanation; when you are ready, take a timed quiz to test recall under exam conditions.

Practice Questions

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?

  1. A.Choose the programming language
  2. B.Start coding right away now
  3. C.Understand requirements and constraints✓ Correct
  4. 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?

  1. A.A constant that never changes
  2. B.A loop construct in the program
  3. C.A function definition in code
  4. 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?

  1. A.A data structure for storage
  2. B.Reusable block for a specific task✓ Correct
  3. C.A variable type declaration
  4. 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?

  1. A.Declare a new variable in scope
  2. B.Create a new loop construct
  3. C.Send value back, end the function✓ Correct
  4. 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?

  1. A.An error in the program logic
  2. B.Variable receiving value when called✓ Correct
  3. C.A global variable in the program
  4. D.The return type of a function

Explanation

Receives passed arguments.

Report an error in this question

Problem Solving Using ProgrammingEasy

Q6. == vs =?

  1. A.Both are comparison operators
  2. B.= compares, == assigns values
  3. C.= assigns, == compares values✓ Correct
  4. 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?

  1. A.A numeric data type value
  2. B.A callable function reference
  3. C.A boolean true/false value
  4. 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?

  1. A.Looping through elements repeatedly
  2. B.Making decisions based on conditions✓ Correct
  3. C.Importing external code modules
  4. D.Declaring new variable bindings

Explanation

Conditional execution.

Report an error in this question

Problem Solving Using ProgrammingEasy

Q9. What is list/array for?

  1. A.Performing math calculations only
  2. B.Displaying output on the screen
  3. C.Ordered collection of multiple values✓ Correct
  4. 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?

  1. A.Don't Repeat Yourself ever✓ Correct
  2. B.Do Repeat Yourself always
  3. C.Dev Run Yield automation
  4. D.Do Run Yesterday's builds

Explanation

Avoid duplication.

Report an error in this question

Problem Solving Using ProgrammingMedium

Q11. Modular code benefit?

  1. A.Smaller testable reusable pieces made✓ Correct
  2. B.It makes the program run slower
  3. C.It uses significantly more memory
  4. 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?

  1. A.Use binary search on the array
  2. B.Sort the entire array first
  3. C.Iterate tracking the maximum value✓ Correct
  4. 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?

  1. A.The data type of the variable
  2. B.The current value of the variable
  3. C.The name given to the variable
  4. 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?

  1. A.Self-similar sub-problem structures✓ Correct
  2. B.Replacing all loops in the code
  3. C.Only Fibonacci number computation
  4. 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?

  1. A.Use nested loops over the string
  2. B.Use hash map in one single pass✓ Correct
  3. C.Sort the string first then count
  4. 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?

  1. A.A testing framework for the app
  2. B.Ignoring all errors in the code
  3. C.Handle runtime errors without crashing✓ Correct
  4. D.A design pattern for structure

Explanation

Graceful error handling.

Report an error in this question

Problem Solving Using ProgrammingMedium

Q17. Reverse linked list?

  1. A.Sort the list then reverse order
  2. B.Change next pointers to point back✓ Correct
  3. C.Copy all elements to an array first
  4. 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?

  1. A.Hash table use
  2. B.Stack structure✓ Correct
  3. C.Array scanning
  4. 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?

  1. A.Count all the nodes in the list
  2. B.Sort the list nodes by value
  3. C.Check all pairs of nodes found
  4. 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?

  1. A.A debugging technique for errors
  2. B.Writing memos about the code
  3. C.Caching results to avoid recomputation✓ Correct
  4. D.A type of loop construct used

Explanation

Cache expensive results.

Report an error in this question

Problem Solving Using ProgrammingHard

Q21. Find LCS?

  1. A.DP with a 2D table approach✓ Correct
  2. B.Hashing all subsequences found
  3. C.Brute force all subsequences
  4. 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?

  1. A.Sort items by weight first
  2. B.DP over items and capacities✓ Correct
  3. C.Greedy algorithm approach
  4. 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?

  1. A.Only an array data structure
  2. B.A stack-based data structure
  3. C.A binary search tree structure
  4. 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?

  1. A.BFS/DFS from unvisited vertices✓ Correct
  2. B.Use hash table for the lookup
  3. C.Check all pairs of vertex nodes
  4. 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?

  1. A.Sorting the tree node values
  2. B.Balancing the tree structure
  3. C.Bottom-up from children results✓ Correct
  4. 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?

  1. A.Two heaps: max lower, min upper✓ Correct
  2. B.Use a single array for storage
  3. C.Sort the entire stream each time
  4. 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?

  1. A.Making code completely unreadable
  2. B.Graphics rendering operations only
  3. C.Low-level hardware drivers only
  4. 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?

  1. A.BFS from the source vertex✓ Correct
  2. B.Bellman-Ford algorithm approach
  3. C.Dijkstra's algorithm approach
  4. 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?

  1. A.Sorting segments of an array
  2. B.String matching and pattern search
  3. C.Range queries and updates in O(log n)✓ Correct
  4. D.Graph traversal and pathfinding

Explanation

Efficient range operations.

Report an error in this question

Problem Solving Using ProgrammingHard

Q30. Find articulation points?

  1. A.BFS from every vertex in the graph
  2. B.Sort the graph vertices by degree
  3. C.Tarjan's DFS with discovery/low values✓ Correct
  4. 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

Ready to test yourself on Problem Solving Using Programming?

Take a timed quiz drawn from 210+ questions on this topic. No signup required — your progress saves in your browser.

Start Problem Solving Using Programming Quiz