Computational Thinking IT Unit-3 Notes PDF
Document Details
![SprightlyWaterfall1819](https://quizgecko.com/images/avatars/avatar-13.webp)
Uploaded by SprightlyWaterfall1819
Graphic Era Deemed to be University
Tags
Related
Summary
These notes provide a summary of computational thinking and IT, focusing on algorithms, sequencing, selection, and iteration. The examples of algorithms, steps and characteristics are detailed. The document is suitable for secondary school students learning about fundamental computer science concepts.
Full Transcript
# COMPUTATIONAL THINKING AND I.T ## Unit-3 ALGORITHMIC THINKING ### ALGORITHMS An Algorithm is a defined set of step-by-step procedures that provides the correct answer to a particular problem. An Algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. It can be formall...
# COMPUTATIONAL THINKING AND I.T ## Unit-3 ALGORITHMIC THINKING ### ALGORITHMS An Algorithm is a defined set of step-by-step procedures that provides the correct answer to a particular problem. An Algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. It can be formally written down and has very practical consequences to achieve software re-use which helps in saving a lot of time for software developers. ### DEFINATION OF ALGORITHM In Computer Science, an algorithm usually means a small procedure that solves a recurrent problem. It abstracts the data, operations and semantics of a problem and then creates a solution using all those abstractions. It describes the process of solving a particular problem. Algorithm play a very important role in designing good software and also help in finding the best solution to a problem. Below is given a list of advantages and disadvantages. ### ADVANTAGES OF ALGORITHM - Logic can be developed independent of a programming Language. - Can be easily transformed to a program in any computer language. - Step-by-step approach assists in finding and correcting errors in programs. - Can be easily understood by a Programmer. - Leads to problem solution in a finite amount of time. ### DISADVANTAGES OF ALGORITHM - Difficult tasks are difficult to be explained using Algorithm. - Time-consuming to develop and prove their accuracy. - It is difficult to show some programming constructs like looping and branching. ### CHARACTERISTICS OF AN ALGORITHM - **INPUT:** It should have the ability to accept zero or more well-defined inputs. - **DEFINITENESS OR UNAMBIGUOUS:** Each step or operation must be well-defined. It means that each instruction must be specified unambiguously. - **EFFECTIVENESS OR FEASIBLE:** Each step should be feasible to be carried out by a person using pencil and paper in a finite amount of time. - **TERMINATE / FINITENESS:** The problems solving process after some steps must lead to a solution of the problem. - **OUTPUT:** It must produce one or more Output as an outcome of following the steps in an algorithm. ### EXAMPLES OF ALGORITHM (Sequencing, Selection, Iteration) #### a) Sequencing - A sequencing algorithm is a set of instructions that are performed in a specific order to complete a task. In a sequencing algorithm, the order of the instructions is important. - If the instructions are not followed in the correct order, the task will be incompleted or ambiguous. **1. Write an algorithm to find the sum of two Numbers.** - **STEP 1:** START - **STEP 2:** [Read two number into a, b] INPUT a, b - **STEP 3:** [Complete the Sum] Sum = a+b - **STEP 4:** [Display the Result] OUTPUT SUM - **STEP 5:** [End of the Algorithm] Exit **2. Write an algorithm to find Area of Circle:** - **STEP 1:** START - **STEP 2:** [Define the value of PI] PI = 3.142 - **STEP 3:** [Read the value of Radius] INPUT - **STEP 4:** [Compute Area] area = PI*γγ - **STEP 5:** [Print the Compound Area] Output area - **STEP 6:** [End of the Algorithm] EXIT **3. Write an algorithm to find Area of Triangle (Heron's formula)** - **STEP 1:** START - **STEP 2:** [Read values length of sides of a triangle] INPUT a, b, c - **STEP 3:** [Compute semi-perimeter,s] S= (a+b+c)/2 - **STEP 4:** [Compute the area] area=SQRT(S*(s-a)*(s-b)*(s-c)) - **STEP 5:** [Print the Computed Area] Output Area. - **STEP 6:** [End of the Algorithm] Exit #### b) Selection - It is an Algorithm to find the smallest value in a set of ordered values. - Selection algorithm can also be used to evaluate components of random solution of Set for a problem. It can also find the median or maximum value in a set. **Write an algorithm to find the largest of three numbers.** - **STEP 1:** START. - **STEP 2:** [Read valve of 3 Numbers] INPUT a, b, c - **STEP 3:** [Assume / 1Assign a to large] large = a - **STEP 4:** [Compare large with b] if (b> large) large = b endif - **STEP 5:** [Compare large with C] if (c> large) large = C end if - **STEP 6:** [Print the largest value] OUTPUT large. - **STEP 7:** [End of the Algorithm] Exit #### c) Iteration - Iteration algorithm means repeating steps, or instruction close instruction. A single Action that can be performed by a computer processor. over and over again. It can solve the complex problems. **1. Write an algorithm to find the factorial of a Number.** - **STEP 1:** START - **STEP 2:** (Read a Number] INPUT n - **STEP 3:** CInitialize Factorial to 1] Jact = 1. - **STEP 4:** [Compute factorial by Progressive multiplication] Repeat For i = 1 ton fact = fact*i [End of STEP 4 for Loop] - **STEP 5:** [Print factorial] OUTPUT facts - **STEP 6:** (End of the Algorithm] Exit **2. Write an Algorithm to find GCD of two Numbers Using Euclid's Algorithm.** - **STEP 1:** START. - **STEP 2:** [Read two numbers] INPUT a, b - **STEP 3:** CGCD Calculation) Repeat while (b!=0) r = a MOD b a = b b = r [End of while Loop] - **STEP 4:** [Print the GCD i-e, last Divisor] Print a - **STEP 5:** [End of the Algorithm] Exit