The document provides an overview of problem-solving concepts in computer science, including definitions of algorithms, pseudocode, and computational thinking. It includes short and long answer questions with algorithms and pseudocode examples for various problems, such as calculating averages, factorials, and Fibonacci series. Additionally, it emphasizes the importance of algorithms in programming and problem-solving strategies.
The document provides an overview of problem-solving concepts in computer science, including definitions of algorithms, pseudocode, and computational thinking. It includes short and long answer questions with algorithms and pseudocode examples for various problems, such as calculating averages, factorials, and Fibonacci series. Additionally, it emphasizes the importance of algorithms in programming and problem-solving strategies.
Section B: Unsolved Questions A. Short answer type questions. 1. What is an algorithm? Ans. It is a problem-solving strategy that gives you step-by-step instructions for achieving a desired outcome. 2. What is a pseudocode? Ans. A pseudocode can be written in text-based instructions and does not require any programming language syntax. It is used for creating an outline or a rough draft of a program. 3. What is the difference between coding and testing? Ans. Coding: Coding is also known as programming. It is an art of creating a solution of a problem in a programming language. There are many programming languages that can be used depending on the requirements. Testing: The testing process verifies the expected output (i.e., it is working in the same way as per the requirement), checks for all the possible inputs, and ensures that it can handle errors. In short, it verifies the correct behaviour of the program. 4. Explain the need for an algorithm. Ans. Algorithms are used in almost every aspect of computer science. An algorithm is a set of instructions that allow a computer to accomplish any activity, such as running a calculator or solving a complex mathematical problem. It is a fundamental step in programming. 5. Define pattern recognition. Ans. It focuses on making connections between similar problems and experiences. The main objective of pattern recognition is to find similarities and differences among objects. 6. Define computational thinking. Ans. Computational thinking is an approach to solve a problem. It formulates to logically organise and analyse data using different methodologies and tools. The methods for creating solutions to the problem are algorithms, flowcharts, and pseudocodes. B. Long answer type questions. 1. Write an algorithm to find the average age of a group of 10 players. Ans. 1. Start 2. N = 10 (number of players ) 3. a = 1 (player’s count) 4. SUM = 0 5. while (a<=10): Input AGE Add AGE to SUM Add 1 to a 6. AVG = SUM/N 7. Print("AVG") 8. Stop 2. Ayaan…….Write an algorithm. Ans. 1. Start 2. Amount = ((2*50) + (35*1.5 )+ (10*2.5) + (15*1)) 3. Print("Total amount is", Amount) 3. Print("Total amount is", Amount) 4. If (Amount < 500): Leftamt = 500 - Amount Else print (Amount is greater than 500) 5. Print ("Your left amount is", Leftamt) 6. Stop 3. Write an algorithm and pseudocode to find the factorial of N. Ans. Algorithm to find the factorial of N Step 1: Start Step 2: Declare variables n, fact, i Step 3: Initialise variable fact=1 and i=1 Step 4: Repeat until i < = n 4.1 fact = fact * i 4.2 i = i + 1 Step 6: Print fact Step 7: Stop Pseudocode to find the factorial of N Read number Fact = 1 i=1 WHILE I <= number Fact = Fact * i i=i+1 ENDWHILE WRITE Fact 4. Draw a flowchart to find the sum of first 100 natural numbers. Also, write the pseudocode for the same. Ans. Pseudocode BEGIN N = 1, Sum = 0 WHILE N <= 100 WHILE N <= 100 Sum = Sum + N N=N+1 OUTPUT Sum WHILEEND 5. Draw a flowchart to find largest of three numbers X, Y, and Z. Ans. 6. Draw a flowchart to find prime numbers between 1 to 100. Ans. 8. Draw a flowchart which generates the first 50 items of the Fibonacci Series: Ans
9. Write an algorithm and pseudocode to print the cube of numbers
till N, where N is obtained by the user. Ans. Algorithm Step 1: Start Step 2 : Input N Step 2: for i from 1 to N Calculate cube of number as i * i * i Print cube of number Step 3: Stop Pseudocode BEGIN Input N Loop : for i from 1 to N Calculate cube of number as i * i * i Print cube of number End Loop END Q. Write an algorithm to convert a decimal number, n, to binary format. Ans. Step 1: Start Step 2: Divide the number by 2 through % (modulus operator) and store the remainder in an array. Step 3: Divide the number by 2 through / (division operator) Step 4: Repeat Step 2 until number is greater than 0. Step 5: Stop Q. Design a flowchart to compute the sum of the following series: 1+2+3+4+5+…….+n Step 1: Start Step 2: Input value of N Step 3: i=1, sum=0 Step 4: if (i>N) Go to Step 8 Endif Step 5: sum = sum+i Step 6: i = i + 1 Step 7: Go to step 4 Step 8: Display value of sum Step 9: Stop