Problem-Solving Techniques
Short question’s and Answer’s
Problem-Solving and Algorithm Development
1. Q: What is a problem instance?
A: A problem instance is a specific input for a problem. For example, sorting the list [3,
1, 4] is an instance of the sorting problem.
2. Q: What is the difference between generalization and specialization in problem-solving?
A: Generalization broadens a problem to cover more cases; specialization narrows it to
specific scenarios.
3. Q: Name three types of computational problems.
A: Decision problems, optimization problems, and search problems.
4. Q: What does it mean to classify a problem?
A: It means categorizing it based on complexity, type (e.g., NP-complete), or domain
(e.g., numerical, string-based).
5. Q: What is the role of data structures in problem-solving?
A: They organize data efficiently, enabling faster access and manipulation (e.g., arrays,
stacks, trees).
6. Q: What are the four steps in problem-solving?
A: Understand the problem, Plan, Execute, Review.
7. Q: What is input validation?
A: Ensuring that user input meets required criteria before processing.
8. Q: Define preconditions and postconditions.
A: Preconditions are conditions that must be true before execution; postconditions must
be true after execution.
9. Q: What is algorithm efficiency?
A: It refers to how well an algorithm uses resources like time and memory.
10. Q: How do you break a problem into subproblems?
A: By identifying smaller tasks that can be solved independently and combined for the
final solution.
Structured Programming Concepts
1. Q: What are the three basic control structures?
A: Sequence, Selection, and Repetition.
2. Q: What is the difference between entry-controlled and exit-controlled loops?
A: Entry-controlled (e.g., for, while) checks condition before execution; exit-controlled
(do-while) checks after.
3. Q: What is a sentinel-controlled loop?
A: A loop that ends when a special value (sentinel) is encountered.
4. Q: What is nesting in control structures?
A: Placing one control structure inside another (e.g., if inside a for loop).
5. Q: What is the purpose of pseudocode?
A: To outline logic in plain language before coding.
6. Q: What is a flowchart?
A: A diagram that represents the flow of a program using symbols.
7. Q: Define definite and indefinite loops.
A: Definite loops run a known number of times; indefinite loops run until a condition is
met.
8. Q: What is control structure stacking?
A: Using multiple control structures sequentially.
9. Q: What is the difference between if and if-else?
A: if executes when true; if-else provides an alternative path when false.
10. Q: What is the role of assignment statements?
A: They assign values to variables (e.g., x = 5).
Algorithms and Patterns
1. Q: What are the characteristics of a good algorithm?
A: Correctness, efficiency, clarity, and finiteness.
2. Q: What is the standard format of an algorithm?
A: Input, Output, Steps (procedure).
3. Q: What is an arithmetic progression?
A: A sequence where each term increases by a constant difference.
4. Q: What is a geometric progression?
A: A sequence where each term is multiplied by a constant ratio.
5. Q: How do you display a triangle pattern using loops?
A: Use nested loops to print increasing numbers of symbols per row.
6. Q: What is the formula for sine in programming?
A: Use sin(x) from math libraries (e.g., math.h in C).
7. Q: How do you generate Fibonacci numbers?
A: Start with 0 and 1, then add the last two numbers to get the next.
8. Q: What is nesting in pattern generation?
A: Using loops inside loops to control rows and columns.
9. Q: What is an approximate value in algorithms?
A: A value close to the actual result, often used in numerical methods.
10. Q: What is a series in programming?
A: A sequence of numbers generated by a rule or formula.
Computer Memory and Representation
1. Q: What is 1’s complement?
A: Inverting all bits of a binary number.
2. Q: What is 2’s complement?
A: 1’s complement + 1; used for representing negative numbers.
3. Q: What is signed magnitude representation?
A: Uses one bit for sign and remaining for magnitude.
4. Q: What is ASCII?
A: A character encoding standard using 7 or 8 bits.
5. Q: What is UNICODE?
A: A universal character encoding standard supporting multiple languages.
6. Q: What is IEEE 754 format?
A: Standard for representing floating-point numbers.
7. Q: What is a real number in computing?
A: A number with a fractional part, represented using floating-point.
8. Q: What is the difference between memory and storage?
A: Memory is temporary (RAM); storage is permanent (HDD/SSD).
9. Q: What is a bit and byte?
A: Bit is the smallest data unit; byte = 8 bits.
10. Q: How are characters stored in memory?
A: Using encoding schemes like ASCII or UNICODE.
C Language and Basic Programming Constructs
1. Q: What is the purpose of scanf() in C?
A: It reads formatted input from the user.
2. Q: What does printf() do?
A: It displays formatted output to the screen.
3. Q: What are the basic data types in C?
A: int, float, char, double, and void.
4. Q: What is the use of relational operators?
A: They compare values (e.g., ==, !=, <, >).
5. Q: What is the difference between while and do-while loops?
A: while checks the condition before execution; do-while checks after.
6. Q: What is the role of logical operators?
A: They combine multiple conditions (&&, ||, !).
7. Q: What is an empty C program?
A: A program with only the main function and no statements.
8. Q: How do you translate pseudo code to C?
A: By converting logical steps into C syntax using variables, loops, and conditions.
9. Q: What is incremental compilation?
A: Compiling and testing parts of a program step-by-step.
10. Q: What are good coding practices in C?
A: Clear naming, indentation, comments, modular design, and error handling.
Problems on Numbers and Basic Statistical Operations
1. Q: How do you extract digits from a number left to right?
A: Convert to string or use division and modulus with powers of 10.
2. Q: What is a palindrome number?
A: A number that reads the same forward and backward (e.g., 121).
3. Q: What is a prime number?
A: A number greater than 1 with no divisors other than 1 and itself.
4. Q: What are prime factors?
A: Prime numbers that multiply to give the original number.
5. Q: What is an amicable number?
A: A pair of numbers where each is the sum of the proper divisors of the other.
6. Q: What is a perfect number?
A: A number equal to the sum of its proper divisors (e.g., 28).
7. Q: What is an Armstrong number?
A: A number equal to the sum of its digits raised to the power of the number of digits
(e.g., 153).
8. Q: How do you convert a number from one base to another?
A: Use repeated division and store remainders for conversion.
9. Q: How do you calculate average from a sequence?
A: Sum all numbers and divide by the count.
10. Q: What is sentinel-controlled repetition?
A: Looping until a special value (sentinel) is entered to stop.
Modular Programming and Arrays
1. Q: What is modular programming?
A: Dividing a program into independent, reusable functions.
2. Q: What is recursion?
A: A function calling itself to solve smaller instances of a problem.
3. Q: What is the top-down approach?
A: Start with the main problem and break it into sub problems.
4. Q: What is the bottom-up approach?
A: Build solutions to sub problems first, then combine them.
5. Q: How do you read array elements in C?
A: Using loops and indexing (e.g., arr[i]).
6. Q: How do you find the median of an array?
A: Sort the array and pick the middle value(s).
7. Q: What is the mode of an array?
A: The value that appears most frequently.
8. Q: What is sequential search?
A: Checking each element one by one until the target is found.
9. Q: What is binary search?
A: Repeatedly dividing a sorted array to find the target.
10. Q: Name one sorting algorithm.
A: Bubble sort: repeatedly swap adjacent elements if they’re in the wrong order.
Matrix Operations and C Implementation
1. Q: How do you declare a 2D array in C?
A: int matrix[rows][cols];
2. Q: What is a function prototype?
A: A declaration of a function before its definition.
3. Q: What is the role of the return statement?
A: It sends a value back to the calling function.
4. Q: What is the difference between 1D and 2D arrays?
A: 1D stores a list; 2D stores a table/grid.
5. Q: How do you perform matrix addition?
A: Add corresponding elements of two matrices.
6. Q: What is operator precedence?
A: Rules that determine the order of operations in expressions.
7. Q: What is associativity in operators?
A: Direction in which operators of the same precedence are evaluated.
8. Q: What are string functions in C?
A: Functions like strlen(), strcpy(), strcmp() for string manipulation.
9. Q: What is the use of break in loops?
A: It exits the loop immediately.
10. Q: What does continue do in a loop?
A: Skips the current iteration and moves to the next.
Debugging Techniques
1. Q: What is debugging?
A: The process of finding and fixing errors in code.
2. Q: What are syntax errors?
A: Mistakes in code structure (e.g., missing semicolon).
3. Q: What are logical errors?
A: Errors in the program’s logic that produce incorrect results.
4. Q: What is a runtime error?
A: An error that occurs during program execution (e.g., divide by zero).
5. Q: What is dry run debugging?
A: Manually tracing code to check logic.
6. Q: What is the role of a debugger tool?
A: It helps step through code, inspect variables, and set breakpoints.
7. Q: What is a breakpoint?
A: A marker that pauses execution at a specific line.
8. Q: What is watch in debugging?
A: Monitoring the value of a variable during execution.
9. Q: What is error handling?
A: Managing unexpected conditions gracefully.
10. Q: What is the benefit of modular debugging?
A: Easier to isolate and fix issues in smaller code units.