Course Code CSE1021 Introduction to Problem Solving and Programming Unit -1 (8-Hours) Dr. Sandip Mal VIT Bhopal VIT Bhopal University Bhopal-Indore Highway, Kothrikalan, Sehore, Madhya Pradesh – 466114. Credits 4 Lecture -1
01 Unit Introduction to Computer Problem Solving
Unit -1 Introduction to Computer Problem Solving: ●Introduction – Problem Solving Aspect ●Top-Down Design ●Implementation of Algorithms (flowcharts, pseudo code, programming language) ●Program Verification ●Efficiency of Algorithms ●Analysis of Algorithms.
Introduction • Number of problems in our daily life. • Suppose we have to calculate Simple Interest. • Suppose we have to prepare a mark sheet.  A computer is a DUMB machine.  A computer cannot do anything alone without software i.e. Program
Types of Computer Software Overview Describe here the topic of the section System Software Example:-Operating system is the type of system software Application Software Example is Microsoft Office Topic Features Programming Languages C, C++,java, Python
Software • A software is a set of programs written to solve a particular problem • Software is a set of instructions on the basis of which computer gives output/result. • If the instructions are not correct, the computer gives wrong result.
Never Ever Forget • Just writing code is not sufficient to solve a problem. • Program must be planned before coding in any computer language available. • There are many activities to be done before and after writing code.
Fig. Steps in problem solving Algorithm Development Flowcharting Documentation Debugging and Testing Compilation and Execution Program Coding Problem Analysis
Problem Analysis • Process of becoming familiar with the problem. • We need to analyze and understand it well before solving. • The user’s requirements cannot be fulfilled without clear understanding of his/her problem in depth. • Inadequate identification of problem may cause program less useful and insufficient. • Example: Banking Solution, Hospital Medical Study
Banking Problem Solved by Software ●Digital transformation( Cash Deposit and Withdraw) ●Core Banking ●ATM- Solution ●Point of sale(POS) ●Third party( VISA, MasterCard) ●Policies run by Governments and other
Please find the process for availing the flipped course on VITyarthi ● Go to https://vityarthi.com. ● Click on login. ● Click on the "Sign in" button on the top navigation bar. ● Click on the "Login with google" button and login using the University Email ID. ● Go to the URL : https://vityarthi.com/ and Click on Courses for the course details. ● Click on the course you want to register and Click on "Add to Cart" ● Find the Cart Symbol on top of the page and click to " Go to Cart". ● You will see the Course that you want to register for. Below find the Coupon Section. ● Apply the coupon code VITFLIPPED2023B2 and validate for availing INR 60% discount on the course. ● Then Proceed to Checkout. ● After 24hours, the course will be visible on the Dashboard ● If not, the amount will be refunded to the original payment mode and the student has to buy the course again. ● Submit details of payment here https://forms.gle/xLoGxXtEV6CgJcxG9 Note : In case of any payment related issues, please ask the student to write an email to info@vityarthi.com.
Algorithm Development ● A procedure for solving a mathematical problem in a finite number of steps that may frequently involves repetition of an operation. OR ● A step-by-step procedure for solving a problem or accomplishing some end OR ● Developing an algorithm is a step of program design.
Differences Between Program And Algorithm Criteria Algorithm Program Use Design Time Implementation Time Who Domain Knowledge Programmer Write In Any Language Programming Language H/w & Software Independent Dependent Performance Analyze Testing
Step 1: Start Step 2: Assume two numbers x and y and a variable sum=0 Step 3: Add two numbers x and y; store the value in variable sum Step 4: If you want to try again with different numbers then goto step 2 else goto step 5 ●Step 5: END An Example of algorithm to find sum of two numbers
An algorithm to find sum of two numbers: Step 1: Start Step 2: Declare variables num1, num2 and sum. Step 3: Read values num1 and num2. Step 4: Add num1 and num2 and assign the result to sum. sum←num1+num2 Step 5: Display sum Step 6: Stop
Flowcharting • Graphical representation of an algorithm using standard symbols. • Includes a set of various standard shaped boxes that are interconnected by flow lines. • Flow lines have arrows(direction of flow). • Activities are written within boxes in English. • Communicates between programmers and business persons.
STAR T END Read two Numbers, A and B Display C as Sum of A and B C = A + B Input Start Output End Processing
Coding • The process of transforming the program logic design into computer language format. • An act of transforming operations in each box of the flowchart in terms of the statement of the program. • The code written using programming language is also known ● as source code. • Coding isn’t the only task to be done to solve a problem using computer. • Anyone can code. TRUST ME!!
Compilation • Process of changing high level language into machine level language. • It is done by special software, COMPILER • The compilation process tests the program whether it ● contains syntax errors or not. • If syntax errors are present, compiler can not compile the code.
Execution • Once the compilation is completed then the program is linked with other object programs needed for execution, there by resulting in a binary program and then the program is loaded in the memory for the purpose of execution and finally it is executed. • The program may ask user for inputs and generates outputs after processing the inputs.
Debugging and Testing • Testing ensures that program performs correctly the required task. • Verification ensures that program does what the programmer intends to do. • Validation ensures that the program produces the correct results for a set of test data. • Test data are supplied to the program and output is observed. • Expected output = Error free
Program Documentation • Helps to those who use, maintain and extend the program in future. • A program may be difficult to understand even to programmer who wrote the code after some days. • Properly documented program is necessary which will be useful and efficient in debugging, testing, maintenance and redesign process.
Two types of documentations 1. Programmer’s Documentation (Technical Documentation) • Maintain, redesign and upgrade • Logic, DFD, E-R, algorithm and flowchart 2. User Documentation (User Manual) • Support to the user of the program • Instructions for installation of the program
Types or levels of Programming Languages • High Level ● Low-level – Machine Level – Assembly Level
Low Level Language • Statement or instruction is directly translated into a single machine code. • It is machine dependent, i.e. A particular low- level language works only for a certain machine.
Machine-level Language • Language that a computer actually understands. • 1’s and 0’s. • A sequence of instructions written in the form of binary numbers consisting of 1’s and 0’s • It executes fast as computer don’t need any translation.
Problem Solving ● Solving problems is the core of computer science. ● Programmers must first understand how a human solves a problem. ● Then understand how to translate this "algorithm" into something a computer can do. ● finally how to "write" the specific syntax (required by a computer) to get the job done. ● It is sometimes the case that a machine will solve a problem in a completely different way than a human.
Machine Language ADVANTAGE DISADVANTAGE Computer directly understands machine instructions Difficult to use Directly starts executing Machine dependent Takes less execution time Difficult to Debug and modify It is relatively easy for writing programs in assembly languages, but is slow in execution as it has to be converted into machine language before execution.
Some examples of instructions for assembly languages are as follows: CODE Meaning ADD Addition SUB Subtraction INR Increase DCR Decrease CMP Compare
High Level Language • User friendly, Similar to natural languages • Platform independent • Easy to write or remember • Easy to learn and work • While execution: translated into assembly language then to machine language. • Slow in execution but is efficient for developing programs. • Ex: C, C++, Python, Java etc.
High Level Language Advantages Disadvantages Easy to use More execution time Portability Needs own translator Easy Debugging Easy and Fast Development of software
Compiler • A high level source program must be translated into a form machine can understand. This done by software called the compiler. • Source code => Machine language code(Object code) • During the process of translation, the compiler reads the source ● programs statement-wise and checks for syntax errors. • In case of any error, the computer generates message about the error. • Ex: C, C++, Java, FORTRAN, pascal etc.
Interpreter • Like compiler, it is also a translator which translates high level to machine level language. • Translates and executes the program line by line. • Each line is checked for syntax error and then converted to ● the equivalent machine code. • Ex. QBASIC, PERL, PHP, ASP, PYTHON, RUBY
Difference between compiler and interpreter Compiler Interpreter Compiler scans the entire program before translating it into machine code Interpreter translates and executes the program line by line Syntax errors are found only after the compilation of complete programs Syntax errors can be trapped after translations of every line It takes large amount of time to analyze the source code but the overall execution time is comparatively faster. It takes less amount of time to analyze the source code but the overall execution time is slower. Generates intermediate object code which further requires linking, hence requires more memory. No intermediate object code is generated, hence are memory efficient.
Top-Down Design ●If you have a big problem to solve, then a very effective method of working towards a solution is to break it down into smaller, more manageable problems. ●This is the idea behind 'top-down design'. Another term used is 'Stepwise refinement'.
Example A software program is needed to handle the lights in a concert stadium. There are hundreds of lights, all producing complicated sequences and effects. Approach Before a single line of code is written, a structure chart is drawn. Something like this:
Conti…. • A 'module' is ideally a self-contained block of code. • The code within has a clearly defined set of inputs and outputs, this is called an 'interface'. • Each module has a specific function to perform. Its actions are controlled by a master program loop. • This is like the conductor in an orchestra, making the whole thing work in harmony.
Conti.. ●The control module is concerned with controlling the hardware. It does this by communicating and controlling a number of sub-modules. ●These sub-modules are responsible for certain types of light.
Divide-and-conquer algorithm ● A divide-and-conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved directly. ● Divide/Break: This involves dividing the problem into some sub problems. ● Conquer/Solve: Sub problem by calling recursively until sub problem solved. ● Combine/Merge: The sub problem solved so that we will get find problem solution.
For example: sorting
Thanks! Do you have any questions? sandip.mal@vitbhopal.ac.in

introduction to problem solving and programming

  • 1.
    Course Code CSE1021 Introduction toProblem Solving and Programming Unit -1 (8-Hours) Dr. Sandip Mal VIT Bhopal VIT Bhopal University Bhopal-Indore Highway, Kothrikalan, Sehore, Madhya Pradesh – 466114. Credits 4 Lecture -1
  • 3.
  • 4.
    Unit -1 Introduction toComputer Problem Solving: ●Introduction – Problem Solving Aspect ●Top-Down Design ●Implementation of Algorithms (flowcharts, pseudo code, programming language) ●Program Verification ●Efficiency of Algorithms ●Analysis of Algorithms.
  • 5.
    Introduction • Number ofproblems in our daily life. • Suppose we have to calculate Simple Interest. • Suppose we have to prepare a mark sheet.  A computer is a DUMB machine.  A computer cannot do anything alone without software i.e. Program
  • 6.
    Types of Computer Software Overview Describe herethe topic of the section System Software Example:-Operating system is the type of system software Application Software Example is Microsoft Office Topic Features Programming Languages C, C++,java, Python
  • 7.
    Software • A softwareis a set of programs written to solve a particular problem • Software is a set of instructions on the basis of which computer gives output/result. • If the instructions are not correct, the computer gives wrong result.
  • 8.
    Never Ever Forget •Just writing code is not sufficient to solve a problem. • Program must be planned before coding in any computer language available. • There are many activities to be done before and after writing code.
  • 9.
    Fig. Steps inproblem solving Algorithm Development Flowcharting Documentation Debugging and Testing Compilation and Execution Program Coding Problem Analysis
  • 10.
    Problem Analysis • Processof becoming familiar with the problem. • We need to analyze and understand it well before solving. • The user’s requirements cannot be fulfilled without clear understanding of his/her problem in depth. • Inadequate identification of problem may cause program less useful and insufficient. • Example: Banking Solution, Hospital Medical Study
  • 11.
    Banking Problem Solvedby Software ●Digital transformation( Cash Deposit and Withdraw) ●Core Banking ●ATM- Solution ●Point of sale(POS) ●Third party( VISA, MasterCard) ●Policies run by Governments and other
  • 12.
    Please find theprocess for availing the flipped course on VITyarthi ● Go to https://vityarthi.com. ● Click on login. ● Click on the "Sign in" button on the top navigation bar. ● Click on the "Login with google" button and login using the University Email ID. ● Go to the URL : https://vityarthi.com/ and Click on Courses for the course details. ● Click on the course you want to register and Click on "Add to Cart" ● Find the Cart Symbol on top of the page and click to " Go to Cart". ● You will see the Course that you want to register for. Below find the Coupon Section. ● Apply the coupon code VITFLIPPED2023B2 and validate for availing INR 60% discount on the course. ● Then Proceed to Checkout. ● After 24hours, the course will be visible on the Dashboard ● If not, the amount will be refunded to the original payment mode and the student has to buy the course again. ● Submit details of payment here https://forms.gle/xLoGxXtEV6CgJcxG9 Note : In case of any payment related issues, please ask the student to write an email to info@vityarthi.com.
  • 13.
    Algorithm Development ● Aprocedure for solving a mathematical problem in a finite number of steps that may frequently involves repetition of an operation. OR ● A step-by-step procedure for solving a problem or accomplishing some end OR ● Developing an algorithm is a step of program design.
  • 14.
    Differences Between Program AndAlgorithm Criteria Algorithm Program Use Design Time Implementation Time Who Domain Knowledge Programmer Write In Any Language Programming Language H/w & Software Independent Dependent Performance Analyze Testing
  • 17.
    Step 1: Start Step2: Assume two numbers x and y and a variable sum=0 Step 3: Add two numbers x and y; store the value in variable sum Step 4: If you want to try again with different numbers then goto step 2 else goto step 5 ●Step 5: END An Example of algorithm to find sum of two numbers
  • 18.
    An algorithm tofind sum of two numbers: Step 1: Start Step 2: Declare variables num1, num2 and sum. Step 3: Read values num1 and num2. Step 4: Add num1 and num2 and assign the result to sum. sum←num1+num2 Step 5: Display sum Step 6: Stop
  • 19.
    Flowcharting • Graphical representationof an algorithm using standard symbols. • Includes a set of various standard shaped boxes that are interconnected by flow lines. • Flow lines have arrows(direction of flow). • Activities are written within boxes in English. • Communicates between programmers and business persons.
  • 20.
    STAR T END Read two Numbers, Aand B Display C as Sum of A and B C = A + B Input Start Output End Processing
  • 22.
    Coding • The processof transforming the program logic design into computer language format. • An act of transforming operations in each box of the flowchart in terms of the statement of the program. • The code written using programming language is also known ● as source code. • Coding isn’t the only task to be done to solve a problem using computer. • Anyone can code. TRUST ME!!
  • 23.
    Compilation • Process ofchanging high level language into machine level language. • It is done by special software, COMPILER • The compilation process tests the program whether it ● contains syntax errors or not. • If syntax errors are present, compiler can not compile the code.
  • 24.
    Execution • Once thecompilation is completed then the program is linked with other object programs needed for execution, there by resulting in a binary program and then the program is loaded in the memory for the purpose of execution and finally it is executed. • The program may ask user for inputs and generates outputs after processing the inputs.
  • 25.
    Debugging and Testing •Testing ensures that program performs correctly the required task. • Verification ensures that program does what the programmer intends to do. • Validation ensures that the program produces the correct results for a set of test data. • Test data are supplied to the program and output is observed. • Expected output = Error free
  • 26.
    Program Documentation • Helpsto those who use, maintain and extend the program in future. • A program may be difficult to understand even to programmer who wrote the code after some days. • Properly documented program is necessary which will be useful and efficient in debugging, testing, maintenance and redesign process.
  • 27.
    Two types ofdocumentations 1. Programmer’s Documentation (Technical Documentation) • Maintain, redesign and upgrade • Logic, DFD, E-R, algorithm and flowchart 2. User Documentation (User Manual) • Support to the user of the program • Instructions for installation of the program
  • 28.
    Types or levelsof Programming Languages • High Level ● Low-level – Machine Level – Assembly Level
  • 29.
    Low Level Language •Statement or instruction is directly translated into a single machine code. • It is machine dependent, i.e. A particular low- level language works only for a certain machine.
  • 30.
    Machine-level Language • Languagethat a computer actually understands. • 1’s and 0’s. • A sequence of instructions written in the form of binary numbers consisting of 1’s and 0’s • It executes fast as computer don’t need any translation.
  • 31.
    Problem Solving ● Solvingproblems is the core of computer science. ● Programmers must first understand how a human solves a problem. ● Then understand how to translate this "algorithm" into something a computer can do. ● finally how to "write" the specific syntax (required by a computer) to get the job done. ● It is sometimes the case that a machine will solve a problem in a completely different way than a human.
  • 32.
    Machine Language ADVANTAGE DISADVANTAGE Computerdirectly understands machine instructions Difficult to use Directly starts executing Machine dependent Takes less execution time Difficult to Debug and modify It is relatively easy for writing programs in assembly languages, but is slow in execution as it has to be converted into machine language before execution.
  • 33.
    Some examples ofinstructions for assembly languages are as follows: CODE Meaning ADD Addition SUB Subtraction INR Increase DCR Decrease CMP Compare
  • 34.
    High Level Language •User friendly, Similar to natural languages • Platform independent • Easy to write or remember • Easy to learn and work • While execution: translated into assembly language then to machine language. • Slow in execution but is efficient for developing programs. • Ex: C, C++, Python, Java etc.
  • 35.
    High Level Language AdvantagesDisadvantages Easy to use More execution time Portability Needs own translator Easy Debugging Easy and Fast Development of software
  • 36.
    Compiler • A highlevel source program must be translated into a form machine can understand. This done by software called the compiler. • Source code => Machine language code(Object code) • During the process of translation, the compiler reads the source ● programs statement-wise and checks for syntax errors. • In case of any error, the computer generates message about the error. • Ex: C, C++, Java, FORTRAN, pascal etc.
  • 37.
    Interpreter • Like compiler,it is also a translator which translates high level to machine level language. • Translates and executes the program line by line. • Each line is checked for syntax error and then converted to ● the equivalent machine code. • Ex. QBASIC, PERL, PHP, ASP, PYTHON, RUBY
  • 38.
    Difference between compiler andinterpreter Compiler Interpreter Compiler scans the entire program before translating it into machine code Interpreter translates and executes the program line by line Syntax errors are found only after the compilation of complete programs Syntax errors can be trapped after translations of every line It takes large amount of time to analyze the source code but the overall execution time is comparatively faster. It takes less amount of time to analyze the source code but the overall execution time is slower. Generates intermediate object code which further requires linking, hence requires more memory. No intermediate object code is generated, hence are memory efficient.
  • 39.
    Top-Down Design ●If youhave a big problem to solve, then a very effective method of working towards a solution is to break it down into smaller, more manageable problems. ●This is the idea behind 'top-down design'. Another term used is 'Stepwise refinement'.
  • 40.
    Example A software programis needed to handle the lights in a concert stadium. There are hundreds of lights, all producing complicated sequences and effects. Approach Before a single line of code is written, a structure chart is drawn. Something like this:
  • 41.
    Conti…. • A 'module'is ideally a self-contained block of code. • The code within has a clearly defined set of inputs and outputs, this is called an 'interface'. • Each module has a specific function to perform. Its actions are controlled by a master program loop. • This is like the conductor in an orchestra, making the whole thing work in harmony.
  • 42.
    Conti.. ●The control moduleis concerned with controlling the hardware. It does this by communicating and controlling a number of sub-modules. ●These sub-modules are responsible for certain types of light.
  • 46.
    Divide-and-conquer algorithm ● A divide-and-conqueralgorithm works by recursively breaking down a problem into two or more sub-problems of the same or related type, until these become simple enough to be solved directly. ● Divide/Break: This involves dividing the problem into some sub problems. ● Conquer/Solve: Sub problem by calling recursively until sub problem solved. ● Combine/Merge: The sub problem solved so that we will get find problem solution.
  • 47.
  • 49.
    Thanks! Do you haveany questions? sandip.mal@vitbhopal.ac.in