






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Question and answer are shortened. Easy to study.
Typology: Study notes
1 / 30
This page cannot be seen from the preview
Don't miss anything!
Problem solving is the systematic approach to define the problem and creating number of solutions. The problem solving process starts with the problem specifications and ends with a correct program. PROBLEM SOLVING TECHNIQUES Problem solving technique is a set of techniques that helps in providing logic for solving a problem. Problem solving can be expressed in the form of
It is defined as a sequence of instructions that describe a method for solving a problem. In other words it is a step by step procedure for solving a problem
Step2: Geta,bValues Step 3: add c=a+b Step 4: Printc Step 5: Return
Algorithm can be expressed in many different notations, including Natural Language, Pseudo code, flowcharts and programming languages. Natural language tends to be verbose and ambiguous. Pseudocode and flowcharts are represented through structured human language. A notation is a system of characters, expressions, graphics or symbols designs used among each others in problem solving to represent technical facts, created to facilitate the best result for a program Pseudocode Pseudocode is an informal high-level description of the operating principle of a computer program or algorithm. It uses the basic structure of a normal programming language, but is intended for human reading rather than machine reading. It is text based detail design tool. Pseudo means false and code refers to instructions written in programming language. Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules. The pseudocode is written in normal English language which cannot be understood by the computer. Example: Pseudocode: To find sum of two numbers READ num1,num sum=num1+num PRINT sum Basic rules to write pseudocode:
The flowcharts act as a guide or blue print during the system analysis and program development phase. Systematic Testing and Debugging The flowchart helps in testing and debugging the program Efficient Program Maintenance The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part. Disadvantages of Flowchart Complex Logic: Sometimes, the program logic is quite complicated. In that case flowchart becomes complex and difficult to use. Alteration and Modification: If alterations are required the flowchart may require re- drawing completely. Reproduction: As the flowchart symbols cannot be typed, reproduction becomes problematic. Control Structures using flowcharts and Pseudocode Sequence Structure Pseudocode Flow Chart General Structure Process 1 …. Process 2 … Process 3 Example READ a READ b Result c=a+b PRINT c Process 1 Process 3 Process 2 Start a=10,b= c=a+b print c Stop
READ a READ b IF a>b THEN PRINT a is greater Iteration or Looping Structure
o In python DO…WHILE is not supported. o If the loop condition is true then the loop gets into infinite loop, which may lead to system crash Programming Language
Interpreted vs. Compiled Programming Language Interpreted Programming Language Compile Programming Language Translates one statement at a time Scans entire program and translates it as whole into machine code It takes less amount of time to analyze the source code but the overall execution time is slower It takes large amount of time to analyze the source code but the overall execution time is comparatively faster No intermediate object code is generated, hence are memory efficient Generates intermediate object code which further requires linking, hence requires more memory Continues translating the program until first error is met, in which case it stops. Hence debugging is easy. It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. Eg: Python, Ruby Eg: C,C++,Java
Algorithmic problem solving is solving problem that require the formulation of an algorithm for the solution. Understanding the Problem It is the process of finding the input of the problem that the algorithm solves. It is very important to specify exactly the set of inputs the algorithm needs to handle. A correct algorithm is not one that works most of the time, but one that works Correctly for all legitimate inputs. Interpreted vs. Compiled Programming Language Interpreted Programming Language Compile Programming Language Translates one statement at a time Scans entire program and translates it as whole into machine code It takes less amount of time to analyze the source code but the overall execution time is slower It takes large amount of time to analyze the source code but the overall execution time is comparatively faster No intermediate object code is generated, hence are memory efficient Generates intermediate object code which further requires linking, hence requires more memory Continues translating the program until first error is met, in which case it stops. Hence debugging is easy. It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. Eg: Python, Ruby Eg: C,C++,Java
Algorithmic problem solving is solving problem that require the formulation of an algorithm for the solution. Understanding the Problem It is the process of finding the input of the problem that the algorithm solves. It is very important to specify exactly the set of inputs the algorithm needs to handle. A correct algorithm is not one that works most of the time, but one that works Correctly for all legitimate inputs. Interpreted vs. Compiled Programming Language Interpreted Programming Language Compile Programming Language Translates one statement at a time Scans entire program and translates it as whole into machine code It takes less amount of time to analyze the source code but the overall execution time is slower It takes large amount of time to analyze the source code but the overall execution time is comparatively faster No intermediate object code is generated, hence are memory efficient Generates intermediate object code which further requires linking, hence requires more memory Continues translating the program until first error is met, in which case it stops. Hence debugging is easy. It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. Eg: Python, Ruby Eg: C,C++,Java
Algorithmic problem solving is solving problem that require the formulation of an algorithm for the solution. Understanding the Problem It is the process of finding the input of the problem that the algorithm solves. It is very important to specify exactly the set of inputs the algorithm needs to handle. A correct algorithm is not one that works most of the time, but one that works Correctly for all legitimate inputs.
Ascertaining the Capabilities of the Computational Device If the instructions are executed one after another, it is called sequential algorithm Choosing between Exact and Approximate Problem Solving
Recursions:
beensatisfied. Algorithm for factorial of n numbers using recursion: Main function: Step1: Start Step2: Get n Step3: call factorial(n) Step4: print fact Step5: Stop Sub function factorial(n): Step1: if(n==1) then fact=1 return fact Step2: else fact=n*factorial(n-1) and return fact
Pseudo code for factorial using recursion: Main function : BEGIN GET n CALL factorial(n) PRINT fact BIN Sub function factorial(n): IF(n==1) THEN fact= RETURN fact ELSE RETURN fact=n*factorial(n-1)
Flowchart: Read n Read Guess number Guess=input If Guess>n If Guess<n If Guess==n nope Your guess is too high Your guess is too low Good job Stop Start
2 .Find minimum in a list Algorithm: Step 1: Start Step 2: Read n Step 3:Initialize i= Step 4: If i<n, then goto step 4.1, 4.2 else goto step 5 Step4.1: Read a[i] Step 4.2: i=i+1 goto step 4 Step 5: Compute min=a[0] Step 6: Initialize i= Step 7: If i<n, then go to step 8 else goto step 10 Step 8: If a[i]<min, then goto step 8.1,8.2 else goto 8. Step 8.1: min=a[i] Step 8.2: i=i+1 goto 7 Step 9: Print min Step 10: Stop Pseudocode: BEGIN READ n FOR i=0 to n, then READ a[i] INCREMENT i END FOR COMPUTE min=a[0] FOR i=1 to n, then IF a[i]<min, then CALCULATE min=a[i] INCREMENT i ELSE INCREMENT i END IF-ELSE END FOR PRINT min END