UNIT I COMPUTATIONAL THINKING AND PROBLEM SOLVING Computational Thinking refers to the thought processes involved in formulating problems and expressing their solutions in a way that a computer can effectively execute It involves breaking down complex problems into smaller more manageable parts and finding systematic ways to solve them Identification of Computational Problems Computational problems are problems that can be solved using a computer or a computational device These problems can be identified by analyzing the tasks involved and determining if they can be broken down into a series of well defined steps that can be executed by a computer Algorithms An algorithm is a step by step procedure or set of instructions for solving a computational problem It is a precise unambiguous set of rules that should be followed to achieve a desired result Building Blocks of Algorithms 1 Statements Statements are individual instructions that the computer executes 2 State The state refers to the values of variables or data stored in memory at a particular point during the execution of an algorithm 3 Control Flow Control flow refers to the order in which statements are executed It includes constructs like conditionals if else statements and loops for while 4 Functions Functions are reusable blocks of code that perform a specific task They can take input parameters and return values Notation for Representing Algorithms 1 Pseudocode Pseudocode is a plain language description of an algorithm that uses a simplified syntax resembling a programming language 2 Flowcharts Flowcharts are visual representations of an algorithm using boxes of different shapes to represent different types of steps or actions 3 Programming Languages Algorithms can be directly expressed in a programming language such as Python Java or C Algorithmic Problem Solving Algorithmic problem solving involves analyzing a problem breaking it down into smaller subproblems and finding a systematic way to solve each subproblem using algorithms Simple Strategies for Developing Algorithms 1 Iteration Iteration involves repeating a set of steps until a certain condition is met For example iterating through a list to find the minimum value 2 Recursion Recursion is a technique where a function calls itself with a smaller input until a base case is reached For example calculating the factorial of a number using recursion Illustrative Problems 1 Find the minimum value in a list 2 Insert a card into a sorted list of cards 3 Guess an integer number within a given range binary search 4 Towers of Hanoi a recursive problem involving moving disks from one peg to another Example Finding the minimum value in a list In this example the find min function takes a list of numbers as input and iterates through the list keeping track of the minimum value encountered so far It returns the minimum value or None if the list is empty
View Full Document