CS Notes Chapter No 1


Q1: Define problem analysis?

Ans: Computer is not as much intelligent that it can solve the problem itself. It is the human, the programmer who writes instruction to solve a particular problem. To analysis the problem a programmer must know the causes. i.e.

  • What is the problem about?
  • How frequently it occurs?
  • When and where does it occur?
  • Who is affected?

Q2: How the solution of the problem is planned?

Ans: After analysis the problem is planned. There may be various solutions for a problem but the most effective solution will be cost effective, speedy and less complex.

Q3: Define candid solution of a problem?

Ans: The candid solution of a problem is the one which will be cost effective, speedy and less complex.

Q4: Define any three problem solving techniques?

Ans:

  • Analogy: Using a solution that solved similar problem.
  • Divide and conquer: Breaking down a large, complex problem for which solutions exist
  • Trial-and-error: Testing possible solutions until the problem is solved.

Q5: List various factor are importance for selecting the best solution of any problem.

Ans: Following factors are important for selecting best solution of problem.

  • Speed: A solution which consumes little time is best solution.
  • Cost: A solution is said to be the best solution if it produces optimal desired result with minimum cost. Cost includes memory, hardware etc.
  • Complicity: The more hardware and software resources required for the solution of a problem, the more the solution will be complex.

Q6: Define an algorithm explain the role of algorithm in problem solving.

Ans: An algorithm is a well-defined set of steps to solve a particular problem. It is written in simple English language. Algorithm is the first step to write a program. An algorithm makes easier to solve complex problem by dividing it into series of steps e.g. to calculate the average of 20 number, algorithm will be written as follows.

step1: Read 20 number

step2: Add these numbers

step3: Calculate average

step4: Print average step5:

Exit

Q7: Describe the criteria for measuring efficiency of an algorithm on the basis of:

  •  Inputs needed
  • Processing to be Completed
  • Decision to be taken
  • Outputs to be provided.

Ans:

  • Input needed: Input is necessary for measuring efficiency of an algorithm. Algorithm may take different time for different input or different time for same input e.g. algorithm for multiplication of large matrices will take more time than small one.
  • Processing to be Completed: It is another factor for measuring efficiency of an algorithm. It is composed of wait time, processing time and cycle time.
  • Decision to be taken: Taking decision is very much important in problem solving. It is used to get best result.
  • Output to be provided: Output is very important factor in solving problem. Correct result shows efficiency of an algorithm.

Q8: What is flowchart? Explain flowchart symbols in detail?

Ans: Flow chart is diagrammatical representation of an algorithm. Here symbols are used for representing the steps used in an algorithm as it makes the logic clear. The steps are connected with the help of arrow lines which show relation and flow of steps. Symbols used in flowchart.

  • OVAL: It is used to show the start and end of a flowchart.

               

 

  • Parallelogram: It is used to show the input and output in a flowchart

             

  • Rectangle: Rectangle shows the process in a flowchart. In this Rectangle formula or expression is written or a variable is initialized.

           

  • Decision symbol: It is diamond shape used to show decision in a flowchart. It has two possible direction i.e. YES or NO (TRUE or FALSE)

            

  • Arrow: These are used to link different steps in flow chart and show the flow of steps.

           

 

Q9: Write an algorithm to calculate the factorial of given number and draw flowchart for it.

Ans:

Step 1: Start

Step 2: Declare Variable N, fact, K

Step 3: Read number from User

Step 4: Initialize Variable fact=1 and K=1

Step 5: Repeat Until K<=N fact=fact*K 5.2 K=K+1

Step 6: Print fact

Step 7: Stop

 

FLOWCHART:

                                        

Q10: Write an algorithm and draw a flow chart to resolve quadratic equation.

Answer:

Step 1. Start

Step 2. Read a, b and c

Step 3. Calculate discriminant = (b*b)–(4*a*c)

Step 4. Calculate x1 = ( -b + sqrt(discriminant)) / (2 * a) Calculate x2 = ( -b - sqrt(discriminant)) / (2 * a)

Step 5. Display x1 and x2

Step 6. Stop

FlowChart: