# algorithm,flow chart and data flow diagram

August 5, 2017 | Author: Pawan Thareja | Category: Algorithms, Software Development, Software, Areas Of Computer Science, Computer Programming

#### Short Description

really good .......easily explained...

#### Description

3

CHAPTER

Overview of Algorithm, Flowcharts and DFD INSIDE THIS CHAPTER 3.1. 3.2. 3.3. 3.4.

Problem Design Flow to Solve a Problem Algorithms Flow Chart

3.5. Data Flow Diagram (DFD) 3.6. Text Editor 3.7. VI Editor

3. 1 . PR OBLEM 3.1 PROBLEM IMPORTANT NOTES

Problems are obstacles or undesirable situations that prevent us from getting an objective. So there is thirst to solve the problem in order to get objective. We n n n n n n n n n n

can classify the problems into categories : Mathematical Logical Political Social Economical Physical Chemical Engineering Medical Environmental

32

DO YOU KNO W KNOW At present, we are always try to solve either Mathematical or Logical problems in every context of life.

33

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

In the present context, we are interested in problems & solutions of Mathematical & Logical categories.

3.2. DESIGN FL O W TTO O SOL VE A PR OBLEM FLO SOLVE PROBLEM DO YOU KNO W KNOW

D E SIG N ID E A

This explains that, you should know what you do.

SP EC IFIC ATIO N

What are the things that you require to do the design?

A LG ORITH M S

Step-by-step solution of problem in English Language or in Engish- Program-Style.

FLOW C H A R T

Flow Chart is a modeling tool to describe our algorithm pictorially or graphically, this is easy to understand

D ATA FLO W D IA G RA M

DFD is a modeling tool, which contains some functional/process through which data flow from one location to another location

IM P LEM E N TATIO N U S IN G A N Y LA N G UA GE

Whatever you write in algorithm, we have to just design it using any program language like C, C++, Java, and Dotnet etc.

All the phases mentioned above are very important to understand to implement or develop software. Now in the next session we are trying to explain all these above Phases, mainly Algorithms, Flow charts & Data flow Diagram, which are very important part of the problem designing & analysis.

3.3. AL GORITHMS ALGORITHMS A simple way of solving any problem is to make its Algorithm and flowchart. IMPORTANT NOTES

An Algorithm is the step-by-step procedure to solve a particular problem in either in pure english language or in english programming style. Any Algorithm can be written in any style i.e. either in English or in English programming style etc. For Example : To assign the values to the variables A & B using an algorithm in English Language style just write the following line :

Assign the inputs, which is obtained from user, to A & B

DO YOU KNO W KNOW Algorithm is used to calculate the time & space, a program takes for its execution and storage respectively (i.e. running time).

+0)26-4 !

Implementation of a problem using any programming language is just weighted 20% of the complete project & the remaining 80% weightage uses the documentation part i.e. Algorithms, Flow-Charts, Data Flow Diagram.

34

INTRODUCTION TO PROGRAMMING

To assign the values to the variables A & B using an algorithm in English Programming style just write the following lines:

set A c

No

Print b is sm allest

print a is sm alle st

Yes

Print c is s m allest

STOP

Fig. 3.3.

Example 4. Draw the flow chart to find average of 3 numbers ? Solution.

STA RT

INP U T a, b, c

AVE R AGE = (a + b + c)/3

PRIN T AV ERA G E

STOP

Fig. 3.4.

+0)26-4 !

Yes

42

INTRODUCTION TO PROGRAMMING

Example 5.

STAR T

SU M = 0

N=0

N=N+1

SU M = S U M + N

Is N = 5 0 ? Yes PR IN T SUM

EN D

Fig. 3.4. Softw are Development

Example 6.

Start

D esig n

C oding Testing Yes

No

No

D esig n E rror? Yes

End

Fig. 3.5.

Example 7.

Sta rt

In put N M = 1 F=1

F = F *M

M = M +1

E rrors?

No

D oes M = N? Yes

O utput F F = 1*2*3 ... *N En d

Fig. 3.6.

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

43

3.5. DA T A FL O W DIA GRAM (DFD) DAT FLO DIAGRAM IMPORTANT NOTES

It is modeling tool that allow us to make system as a network of functional processes, connected one another by “Pipelines” & “Holding Tanks” of data. Synon ym or DFDs Synonym ymss ffor 2. Process Model 3. Bubble Diagram 4. Work Flow Diagram

Data Flow Diagram is used to check the flow of data i.e. how data is stored in database or how data is retrieved from the database or how it is updated.

5. Function Model It is one of the most commonly used system modeling tool for operational system in which the functions of the system are of permanent importance & more complex than the data that system manipulates. It is first used is software engineering.

3.5. 1 . S t eps in Dat a Flo w Analy sis 3.5.1 Data Flow Analysis n Study operations & ongoing process. n Identify how data is processed in handling transactions. n Identify the boundary of the underlying system. n Identify external entities. n Identify processes. n Identify data stores. Identify data flow among processes, data store & external entities.

3.5.2. Dat a Flo w Diagr ams Data Flow Diagrams Data flow diagrams can be used to provide a clear representation of any business function. The technique starts with an overall picture of the business and continues by analyzing each of the functional areas of interest. This analysis can be carried out to precisely the level of detail required. The technique exploits a method called top-down expansion to conduct the analysis in a targeted way. Dat a Flo w Diagr am N o t ations Diagram No Data Flow There are only five symbols that are used in the drawing of business process diagrams (data flow diagrams). These are now explained, together with the rules that apply to them.

+0)26-4 !

1. Bubble Chart

DO YOU KNO W KNOW

44

INTRODUCTION TO PROGRAMMING

2 C ustom er

C as h

A ccou nt in fo rm ation

C ounter

Enquiries Deposits and W ithdraw als

A ccou nt in fo rm ation

D2

A cc ount D etails

Fig. 3.7.

This diagram represents a banking process, which maintains customer accounts. In this example, customers can withdraw or deposit cash, request information about their account or update their account details. The five different symbols used in this example represent the full set of symbols required to draw any business process diagram. Ext er nal Entit y Exter ernal An external entity is a source or destination of a data flow which is outside the area of study. Only those entities which originate or receive data are represented on a business process diagram. The symbol used is an oval containing a meaningful and unique identifier.

C ustom er

Pr ocess Process A process shows a transformation or manipulation of data flows 2 C ounter within the system. The symbol used is a rectangular box which contains 3 descriptive elements : Enquiries Depos its and Firstly an identification number appears in the upper left hand W ithdraw als corner. This is allocated arbitrarily at the top level and serves as a unique reference. Secondly, a location appears to the right of the identifier and describes where in the system the process takes place. This may, for example, be a department or a piece of hardware. Finally, a descriptive title is placed in the centre of the box. This should be a simple imperative sentence with a specific verb, for example maintain customer records or find driver. Dat a Flo w Data Flow A data flow shows the flow of information from its source to its destination. A data flow is represented by a line, with arrowheads showing the direction of flow. Information always flows to or from a process and may be written, verbal or electronic. Each data flow may be referenced by the processes or data stores at its head and tail, or by a description of its contents.

Accou nt in fo rm ation

Dat aS e Data Stt or ore D2 A ccount D etails A data store is a holding place for information within the system: It is represented by an open ended narrow rectangle. Data stores may be long-term files such as sales ledgers, or may be short-term accumulations: for example batches of documents that are waiting to be processed. Each data store should be given a reference followed by an arbitrary number.

45

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

R esour ce Flo w esource Flow A resource flow shows the flow of any physical material from its source C as h to its destination. For this reason they are sometimes referred to as physical flows. The physical material in question should be given a meaningful name. Resource flows are usually restricted to early, high-level diagrams and are used when a description of the physical flow of materials is considered to be important to help the analysis. Dat a Flo w Diagr am–R elationship Grid Data Flow Diagram–R am–Relationship

Process

Data Store

+0)26-4 !

External Entity External Entity Process

Data Store

Fig. 3.8.

There are rules governing various aspects of the diagram components and how they can relate to one another. Dat a Flo ws Data Flow For data flows the rules are as follows : Data flows and resource flows are allowed between external entities and processes. Data flows are also allowed between different external entities. However, data flows and resource flows are not allowed between external entities and data stores. Pr ocesses Processes For processes the data flow rules are as follows: Data flows and resource flows are allowed between processes and external entities and between processes and data stores. They are also allowed between different processes. In other words processes can communicate with all other areas of the business process diagram. Dat aS es Data Stt or ores For data stores the data flow rules are as follows: Data flows and resource flows are allowed between data stores and processes. However, these flows are not allowed between data stores and external entities or between one data store and another. In practice this means that data stores cannot initiate a communication of information, they require a process to do this.

46

INTRODUCTION TO PROGRAMMING

Dat a Flo w Diagr am – Cont e xt Dia gr am Data Flow Diagram Conte Diagr gram Return Request Availability and Advice Book Details Book Supplier

Book

0

Context

Library

Book

Borrow er

O rder Reservation Enquiry Borrow er Num ber

Fig. 3.9.

The context diagram represents the entire system under investigation. This diagram should be drawn first, and used to clarify and agree the scope of the investigation. The components of a context diagram are clearly shown on this screen. The system under investigation is represented as a single process, connected to external entities by data flows and resource flows. The context diagram clearly shows the interfaces between the system under investigation and the external entities with which it communicates. Therefore, whilst it is often conceptually trivial, a context diagram serves to focus attention on the system boundary and can help in clarifying the precise scope of the analysis. The context diagram shown on this screen represents a book lending library. The library receives details of books, and orders books from one or more book suppliers. Books may be reserved and borrowed by members of the public, who are required to give a borrower number. The library will notify borrowers when a reserved book becomes available or when a borrowed book becomes overdue. In addition to supplying books, a book supplier will furnish details of specific books in response to library enquiries. Note, that communications involving external entities are only included where they involve the system process. Whilst a book supplier would communicate with various agencies, for example, publishers and other suppliers - these data flow are remote from the system process and so this is not included on the context diagram. Guidelines tto o Dr a w Cont e xt Diagr am Dra Conte Diagram Firstly, draw and name a single process box that represents the entire system. Next, identify and add the external entities that communicate directly with the process box. Do this by considering origin and destination of the resource flows and data flows. Finally, add the resource flows and data flows to the diagram.

47

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

In drawing the context diagram you should only be concerned with the most important information flows. These will be concerned with issues such as: how orders are received and checked, with providing good customer service and with the paying of invoices. Remember that no business process diagram is the definitive solution - there is no absolute right or wrong.

Le v el 1 Diagr am Lev Diagram

D ata Store

D ata Store

Process External Entity

Process D ata Store

Fig. 3.10.

The level 1 diagram shows the main functional areas of the system under investigation. As with the context diagram, any system under investigation should be represented by only one level 1 diagram. There is no formula that can be applied in deciding what is, and what is not, a level 1 process. Level 1 processes should describe only the main functional areas of the system, and you should avoid the temptation of including lower level processes on this diagram. As a general rule no business process diagram should contain more than 12 process boxes. The level 1 diagram is surrounded by the outline of a process box that represents the boundaries of the system. Because the level 1 diagram depicts the whole of the system under investigation, it can be difficult to know where to start. Dat a Flo w Diagr am—T op-Do wn Expansion Data Flow Diagram—T am—Top-Do op-Down The section explains the process of top down expansion, or leveling. Furthermore, it illustrates that whilst there can only be one context and one level 1 diagram for a given system, these normally give rise to numerous lower level diagrams. Each process within a given business process diagram may be the subject of further analysis. This involves identifying the lower level processes that together constitute the process as it was originally identified. This procedure is known as top-down expansion or leveling. As a business process diagram is decomposed, each process box becomes a boundary for the next, lower level, diagram. In order to illustrate the process of top-down expansion, consider the three processes shown within this business process diagram. No detail is shown, only the outline of the process boxes, which have been identified during the drawing of a level 1 diagram.

+0)26-4 !

Process External Entity

48

INTRODUCTION TO PROGRAMMING

Level X

Level X+1

Fig. 3.11.

Any area of a level 1 diagram is likely to require further analysis, as the level 1 diagram itself only provides a functional overview of the business system. Therefore, below the level 1 diagram there will be a series of lower level diagrams. These are referred to as level 2, level 3, etcetera. In practice, level 2 is usually sufficient and it is unusual to carry out an analysis beyond level 3. In this example the process numbered 3, at level 1, will be investigated further thereby giving rise to a level 2 diagram. In the level 2 diagram four processes of interest have been identified and the numbering of these processes must reflect the parent process. Therefore the level 2 processes are numbered 3.1, 3.2, 3.3 and 3.4 Suppose that of these four level 2 processes, one was of sufficient interest and complexity to justify further analysis. This process, lets say 3.3, could then be further analyzed resulting in a corresponding level 3 diagram. Once again the numbering of these processes must reflect the parent process. Therefore these three level 3 processes are numbered 3.3.1, 3.3.2 and 3.3.3. Dat a Flo w Diagr am—N umbering R ule Data Flow Diagram—N am—Numbering Rule The process boxes on the level 1 diagram should be numbered arbitrarily, so that no priority is implied. Even where data from one process flows directly into another process, this does not necessarily mean that the first one has to finish before the second one can begin. Therefore the processes on a level 1 diagram could be re-numbered without affecting the meaning of the diagram. This is true within any business process diagram - as these diagrams do not imply time, sequence or repetition. However, as the analysis continues beyond level 1 it is important that a strict numbering convention is followed. The processes on level 2 diagrams must indicate their parent process within the level 1 diagram. This convention should continue through level 3 diagrams, and beyond, should that level of analysis ever be required.

49

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

3 Process

3.3 Process

3.3.4

3.3.1

Process

3.1 Process

3.3.3

Process

Process

Process

3.3.2 Process

Fig. 3.12.

The diagram on this screen clearly illustrates how processes on lower level diagrams identify their ancestral path.

3.5.3. Adv ant ages of DFD Advant antages n Easily understood by users & business persons n Identify design errors early in the development n It helps analysts to understand the under lying business processors

3.5.4. De v eloping a DFD Dev Top-Do wn Appr oach op-Down Approach 1. The system designer makes a context level DFD, which shows the interaction (data flows) between the system (represented by one process) and the system environment (represented by terminators). 2. The system is decomposed in lower level DFD (Zero) into a set of processes, data stores, and the data flows between these processes and data stores. 3. Each process is then decomposed into an even lower level diagram containing its subprocesses. 4. This approach then continues on the subsequent subprocesses, until a necessary and sufficient level of detail is reached which is called the primitive process (aka chewable in one bite).

3.5.5. DFD Le v els Lev Cont e xt Le v el Conte Lev This level shows the overall context of the system and its operating environment and shows the whole system as just one process. It does not usually show data stores, unless

+0)26-4 !

3.2

50

INTRODUCTION TO PROGRAMMING

they are owned by external systems, e.g. are accessed by but not maintained by this system, however, these are often shown as external entities. Le v el 0 Lev This level shows all processes at the first level of numbering, data stores, external entities and the data flows between them. The purpose of this level is to show the major high level processes of the system and their interrelation. A process model will have one, and only one, level 0 diagram. A level 0 diagram must be balanced with its parent context level diagram, i.e. there must be the same external entities and the same data flows, these can be broken down to more detail in the level 0, e.g. the 1enquiry data flow could be spilt into enquiry request and enquiry results and still be valid.

3.5.6. Ex am ple of DFD Exam ample 1 . Aut omat ed Cour se R egis tr ation Automat omated Course Regis egistr tration

EX TERNA L E N TIT Y

A P P L IC AT IO N 1

E N Q U IR Y

CHECK COURSE AVA IL A B IL IT Y

R E P LY

CO UR SE S

A C C E P T/D E C L IN E E N R O L LM E N T A P P L IC AT IO N S

R E P LY

E N Q U IR Y 2

C H E C K A P P L IC A N T Q U A L IFIC AT IO N

Fig. 3.13.

The DFD is based on automatic course registration shown in Fig. 3.13 and it checks automatically weather the course for which applicant is applied is available, as shown above as (1), by checking the database where all the records are stored and if it is available then it again checks weather the applicant fulfill the requirement qualification, as shown above as (2), and if it fulfills then the application is accepted otherwise rejected. 2. Online Or der Sy Order Syss t em The DFD is based on online order system shown in Fig. 3.14 and it processes the customer order that he had made online, shown as (1) in the above figure. Entry is done in database D1. It also verify that the payment is approved or not by users credit card or its rejected

51

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

in (2) i.e. cyber check. If the payment is approved then it made an entry in inventory Database D2 after adding shipping charges and confirms the order & tells the customer the delivery date of the product with product type & total amount. O RDER C U S TO M E R 1

E -C O M M E R C E

C U S TO M E R A N D O R D E R IN F O R M AT IO N

PR OCE SS OR DER AC KNO W LEDG EM ENT C U S TO M E R D ATA B A S E

D1

C O N F IR M AT IO N A N D D E LIV E RY D AT E

C R E D IT C A R D N U M B E R AN D OTHE R AM OUN T

CY BER CHECK

V E R IF Y C R E D IT CARD

O R D E R IN FO R M AT IO N A P P R O VA L O R R E JE C TIO N C R E D IT C A R D C O M PA N Y

3

S H IP P IN G

S H IP O R D E R PR ODUCT TY PE AND A M O UNT

D2

IN V E N TO R Y

Fig. 3.14.

3. Ex am ple Exam ample

Stud ent Prog re ss R epo rt

A p plies to U nive rs ity

A p plica tio n

Ap prova l D en ial Letter Stud ent In form ation

Ac c eptanc e Le tter R eg is tra tio n Stud ent Info rm ation

Fig. 3.15.

Stud ent D ataba se

+0)26-4 !

2

52

INTRODUCTION TO PROGRAMMING

4. A Le v el Dat a Flo w Diagr am ffor or the Same Sy Lev Data Flow Diagram Syss t em 1 C u stom er

E n qu iry

P ro cess E n qu iry Item In fo rm a tion

D2

C us tom ers Store

D2

C u stom er D e ta ils

Item Store

Item d eta ils/ a va ilab ility Item s

2 C u stom er

O rd er

C u stom er

P ro cess E n qu iry Inv oice

O rd er D etails

D3

O rd er Store

Fig. 3.16.

3.6. TEXT EDIT OR EDITOR IMPORTANT NOTES

Text editor is a program that enables you to create and edit text files. There are many different types of editors, but they all fall into two general categories: 1 . Line Edit or Editor orss A primitive form of editor that requires you to specify a specific line of text before you can make changes to it. 2. Scr een-Orient ed Edit or Screen-Orient een-Oriented Editor orss It is also called as full-screen editors, these editors enable you to modify any text that appears on the display screen by moving the cursor to the desired location.

3.6. 1 . Types of T e xt Edit or 3.6.1 Te Editor orss (1) N o t epad++ (used only in W indo w s oper ating sy Windo indow operating syss t em) Notepad++ is the text editor which is used in many Windows Operating System and which is able to provide better features compared to Notepad. It handles most of the advanced features, like syntax highlighting, code folding, and macros. Notepad++ is completely free and open source and it is fully customizable.

53

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

+0)26-4 !

The Screen shot of Notepad++ is shown below

Fig. 3.17.

(2) Emacs (used in all platf or ms i.e. use an y oper ating platfor orms any operating sy syss t em) Emacs (Editor MACroS) is popular as it has built-in macros and powerful keyboard commands. The Emacs is virtually for every platform. The Screen shot of Emacs is shown below

Fig. 3.18.

DO YOU KNO W KNOW Platform independent means that the editor is independent on the operating system that the system uses i.e. the editor can be run either on windows or Mac OS or Unix or Linux.

54

INTRODUCTION TO PROGRAMMING

(3) Ultr aEdit (used only in W indo w s oper ating sy UltraEdit Windo indow operating syss t em) UltraEdit is a user-friendly programming text editor which have the features including, syntax highlighting, code folding, macros, and tons of similar features available. UltraEdit focuses mainly on web development, with in-build advanced features like HTML, PHP, JavaScript, and much more. The Screen shot of UltraEdit is shown below

Fig. 3.19.

(4) Te xtMat e (used only in Mac OSX oper ating sy xtMate operating syss t em) TextMate is a powerful and attractive text editor launched just a few years back and quickly gained a rapid popularity with its attractive interface, powerful macros, and downloadable. The Screen shot of TextMate is shown below :

Fig. 3.20.

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

55

(5) Vim (used in all platf or ms) platfor orms)

+0)26-4 !

Vim is very similar to Emacs, earlier version of the Vi text editor. Like Emacs, Vim is available in several forms. Apart from the original version, there are gVim or gVim Portable for Windows and MacVim for the Mac. The Screen shot of Vim is shown below

Fig. 3.21.

(6) Te xtP ad (used only in windo w s oper ating sy xtPad window operating syss t em) Like all above text editors, TextPad is also having advanced features for programmers like syntax highlighting, code blocking, and macros, along with a clip library feature. The Screen shot of TextPad is shown below

Fig. 3.22.

56

INTRODUCTION TO PROGRAMMING

3.7 OR 3.7.. VI EDIT EDITOR VI is another text editor, which is used to create & edit text files & Pronounced as Vee eye editor and which is available on all UNIX system. The VI editor has the powerful features to aid programmers.

DO YOU KNO W KNOW VIM is the earlier version of VI text editor.

3.7 e xt Edit or Oper ating Modes 3.7.. 1 . Vi T Te Editor Operating VI text editor is generally operates in either insert mode or command mode. IMPORTANT NOTES

When the editor is in insert mode then whatever typed becomes the part of the document and put these typed keystrokes into the current file. IMPORTANT NOTES

When the editor is in command mode then the keystrokes entered by keyboard are interpreted as commands that control the edit session. Typing i while in command mode switches the editor into insert mode. Typing i again at this point places an i character in the document.

3.7 .2. Ho w tto o S e xt Edit or 3.7.2. How Stt ar t the VI T Te Editor The VI editor enables a user to create new files or edit existing files. The command to start the VI editor is vi, followed by the filename. For example to edit a file called temporary, you would type vi temporary. You can start VI without a filename, but when you want to save your work, you will have to tell VI which filename to save it into later. When you start VI for the first time, you will see a screen filled with tildes (A tilde looks like this: ~) on the left side of the screen as shown below:

~ ~ ~ ~ ~ ~ ~ ~ filename N lines, M characters Any blank lines beyond the end of the file are shown this way. At the bottom of your screen, the filename should be shown, if you specified an existing file, and the size of the file will be shown as well, like this:

“filename” 21 lines, 385 characters

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

57

If the file you specified does not exist, then it will tell you that it is a new file, like this:

“newfile” [New file] If you started VI without a filename, the bottom line of the screen will just be blank.

3.7 .3. Ho w tto o Exit fr om VI T e xt Edit or 3.7.3. How from Te Editor Now that you know how to get into VI, now this session tells you how to exit from the Vi text editor. The VI editor has two modes and in order to get out of VI, you have to be in command mode. Hit the key labeled Escape or Esc to get into command mode. If you were already in the command mode when you again hit Escape key, dont worry, it might beep, but you will still be in the command mode. The VI editor has 36 buffers for storing pieces of text, out of which one buffer is a general purpose buffer. Any time a block of text is deleted from the file, it gets placed into the general purpose buffer. The block of text is also stored in another buffer other than general purpose buffer as well, if it is specified by user. The buffer is specified using the command. For example, the command: mdd uses the buffer m, and the last two characters stand for delete current line.

3.7 .5. Some Sim ple VI T e xt Edit or Commands 3.7.5. Simple Te Editor Following are some simple set of commands used in VI Text editor. Command

Description

:w filename

Writes (saves) the current document. If the optional filename is provided, the text is saved in the specified file.

:q

Quits the editor without saving the current file.

:vi filename

Loads the specified file into the editor.

:n

Loads the next file into the editor. Useful when vi was invoked from the command line with multiple file names.

:r filename

Reads (inserts) the content of the specified file into the current document.

:wq

Quits the editor and save the current file.

:a

enter insert mode, the characters typed in will be inserted after the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times.

:h

move the cursor to the left one character position.

:i

enter insert mode, the characters typed in will be inserted before the current cursor position. If you specify a count, all the text that had been inserted will be repeated that many times.

:j

move the cursor down one line.

:k

move the cursor up one line.

:l

move the cursor to the right one character position.

:r

replace one character under the cursor. Specify count to replace a number of characters

:u

undo the last change to the file. Typing u again will re-do the change.

:x

delete character under the cursor. Count specifies how many characters to delete. The characters will be deleted after the cursor.

+0)26-4 !

3.7 .4. Te xt Buf f er e xt Edit or 3.7.4. erss used in VI T Te Editor

58

INTRODUCTION TO PROGRAMMING

3.7 .6. Com pilation and R unning a Vi tte e xt edit or pr ogr am 3.7.6. Compilation Running editor progr ogram To Compile a file with filename filename.c

CC filename.c OR GCC filename.c To Run a file with filename filename.c

a.Out OR /a.out a.out or /a.out will run a file which is currently closed or saved using Vi text editor.

SUMMAR Y SUMMARY 1. Problems are obstacles or undesirable situations that prevent us from getting an objective. So there is thirst to solve the problem in order to get objective. 2. An Algorithm is the step-by-step procedure to solve a particular problem in our own Language. 3. Complexity is defined as the total space and time required to store and to execute an algorithm or problem. 4. Space complexity of an algorithm is the total space used or required to store an algorithm or program in memory. 5. Time Complexity of an algorithm is total time required to execute an algorithm. 6. This is a modeling tool to describe out algorithm pictorially or graphically, which is easy to understand 7. DFD is modeling tool that allow us to make system as a network of functional processes, connected one another by Pipelines & Holding Tanks of data. 8. Different techniques used to design an algorithms are recursion, divide & conquer, backtracking, branch & bound, iterative, Dynamic programming, greedy approach, brute force method. 9. Various symbol used in the flow chart are oval, rectangle, parallelogram, diamond box, connector, line. 10. The Process entity identifies a process taking place, it must have at least one input and output. 11. The Data Flow entity identifies the flow of data between processes, data stores & external entities. 12. The Data Store entity identifies stores of data, both manual and electronic. 13. The External Entity identifies external entities which interacts with the system, usually clients but can be within the same organization. 14. Text editor is a program that enables you to create and edit text files 15. Line editor is A primitive form of editor that requires you to specify a specific line of text before you can make changes to it. 16. Screen-oriented editors are the editors enable you to modify any text that appears on the display screen by moving the cursor to the desired location. 17. VI is another text editor, which is used to create & edit text files & Pronounced as Vee eye editor and which is available on all UNIX system.

OVERVIEW OF ALGORITHM, FLOW CHARTS AND DFD

59

18. When the editor is in insert mode then whatever typed becomes the part of the document and put these typed keystrokes into the current file. 19. When the editor is in command mode then the keystrokes entered by keyboard are interpreted as commands that control the edit session.

EXER CISES EXERCISES 1. What are the characteristics of an algorithm? 2. Write an algorithm to swap two numbers without using third variable. 3. What is the difference between a flowchart & Data flow Diagram ?

5. What is Vi editor ? 6. Write an algorithm to generate Fibonacci series and also draw the flowchart. 7. Explain in brief different modes of Vi editor and list the commands ? 8. Why does data flow diagram is required in modeling software system. Give some data flow diagram at different levels for any example software system ? 9. Draw a flowchart to find whether the given number is prime or not. 10. What do you mean by algorithm ? Give an example. 11. What is the difference between a flowchart and data flow diagram ? 12. Draw flowchart for the following : (i) to sort a list of N numbers (ii) to find the sum of digits of a number. 13. Draw flow chart for the following : (i) to find the smallest number from a list of N numbers (ii) to print the digits of a number in reverse order. 14. 15. 16. 17.

Briefly discuss the features of VI editor. Explain DFD with an example. What is the difference between Screen editor and line editor ? Three points are given (x1,y1), (x2,y2) and (x3,y3). Obtain a flowchart to check if they are collinear. 18. Write short note on editing tools ?

GGG

+0)26-4 !

4. Draw a flowchart that reads two numbers x & y and prints the bigger of them. It gives an appropriate message if both the numbers are same