Problem Solving: Understanding the Process and Tools for Effective Algorithm Development, Exercises of C programming

An introduction to problem solving, a crucial skill for both everyday life and software development. It covers various types of problems, the process of finding solutions, and problem solving tools such as algorithms, pseudo code, flowcharts, and data flow diagrams. The document also includes examples and pseudo code for linear search, as well as flowcharts for various programming constructs.

Typology: Exercises

2019/2020

Uploaded on 09/24/2020

venkatme83
venkatme83 🇮🇳

5 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Problem Solving: Understanding the Process and Tools for Effective Algorithm Development and more Exercises C programming in PDF only on Docsity!

Introduction to problem Solving

  • (^) As in our day to day life, while developing software also we come across variety of situations(problem) that we need to deal with and overcome
  • (^) examples
  • (^) calculation
  • (^) searching
  • (^) listprocessing
  • (^) Graph processing
  • (^) Image processing
  • (^) Sound processing
  • (^) Storage
  • (^) Sharing and more

steps to solve a problem

  • (^) understand and analysis the problem(why and which)
  • (^) Design the solution by using appropriate problem solving tool
  • (^) code- the solution by using appropriate programming language
  • (^) Run and test the solution for correctness and efficiency
  • (^) document solution

Problem solving tools It help us to design solutions to problem

  • (^) Algorithm
  • (^) pseudo code
  • (^) Flowchart
  • (^) DFD(Data flow diagram)
  • (^) UML(Unified Modeling Language)

Pseudo code

  • (^) Pseudo code(natural language + programming language[words and phrases, expressions]
  • (^) pseudo meaning is false. Hence pseudo code is not an actual code instead of statements/instructions/words/ phrases/expressions
  • (^) pseudo codes are written with respect to programming language but programming language syntax or grammar is not strictly followed
  • (^) pseudo code is minimized version of an algorithm
  • (^) its nither algorithm nor program

Characteristics of good algorithm

  • (^) input: Accept zero or more inputs
  • (^) Definite: steps are precisely defined and unambiguous
  • (^) output: produces one or more correct outputs(Correct)
  • (^) Finite: algorithm should terminate after finite steps
  • (^) Efficient: memory and time efficient

Flow chart symbols

Peudocode for Linear Search

FUNCTION linearSearch(list, searchTerm): FOR index FROM 0 -> length(list): IF list[index] == searchTerm THEN RETURN index ENDIF ENDLOOP RETURN - END FUNCTION

Program for Linear Search

int search(int arr[], int n, int x) { int i; for (i = 0; i < n; i++) if (arr[i] == x) return i; return -1; }

Flowchart of If.. Else statement

Flowchart of nested if...else statement

Flowchart of for loop

Flowchart of while loop