Top-down design
Top Down Design Approach is one of several problem-solving approaches and is based on the dictum – “Divide and rule”. A small portion of problem is easier to solve at a time than the whole problem taken together. In this approach, the problem is broken down into smaller fragments and fragments, further into still smaller fragments till the fragments are small enough to be solved easily are separately.
The top-down design approach is based on the fact that large problems become more manageable if they are divided into a number of smaller and simpler tasks, which can be tackled separately.
Multiobjective optimization and Genetic algorithms in ScilabScilab
In this Scilab tutorial we discuss about the importance of multiobjective optimization and we give an overview of all possible Pareto frontiers. Moreover we show how to use the NSGA-II algorithm available in Scilab.
Multiobjective optimization and Genetic algorithms in ScilabScilab
In this Scilab tutorial we discuss about the importance of multiobjective optimization and we give an overview of all possible Pareto frontiers. Moreover we show how to use the NSGA-II algorithm available in Scilab.
LINEAR PROGRAMMING Assignment help services at Globalwebtutors are available 24/ by online LINEAR PROGRAMMING experts , LINEAR PROGRAMMING tutors are available for instant LINEAR PROGRAMMING questions help , LINEAR PROGRAMMING writers can help you with complex LINEAR PROGRAMMING dissertation requirements.
It's my take on TD learning and the first webinar I took for students, in an alumni interaction series for the students of SRM University. Prediction learning has been close to my heart and I wanted to spread what I understand of it.
All credits to the pioneers Sutton & Barto for their efforts in shaping this field to what it has become today. Major points are just there from the book.
https://youtu.be/z09m2xDPzVw
Linear Programming Problems {Operation Research}FellowBuddy.com
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
This presentation is trying to explain the Linear Programming in operations research. There is a software called "Gipels" available on the internet which easily solves the LPP Problems along with the transportation problems. This presentation is co-developed with Sankeerth P & Aakansha Bajpai.
By:-
Aniruddh Tiwari
Linkedin :- http://in.linkedin.com/in/aniruddhtiwari
Introduction
The term problem solving is used in many disciplines, sometimes with different perspectives and
often with different terminologies. The problem-solving process starts with the problem
specification and end with a correct program.
The steps to follow in the problem-solving process are:
Problem definition
Problem Analysis
Algorithm development
Coding
Testing & Debugging
Documentation & Maintenance
The stages of analysis, design, programming, implementation and maintenance form the life cycle
of the system.
LINEAR PROGRAMMING Assignment help services at Globalwebtutors are available 24/ by online LINEAR PROGRAMMING experts , LINEAR PROGRAMMING tutors are available for instant LINEAR PROGRAMMING questions help , LINEAR PROGRAMMING writers can help you with complex LINEAR PROGRAMMING dissertation requirements.
It's my take on TD learning and the first webinar I took for students, in an alumni interaction series for the students of SRM University. Prediction learning has been close to my heart and I wanted to spread what I understand of it.
All credits to the pioneers Sutton & Barto for their efforts in shaping this field to what it has become today. Major points are just there from the book.
https://youtu.be/z09m2xDPzVw
Linear Programming Problems {Operation Research}FellowBuddy.com
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
This presentation is trying to explain the Linear Programming in operations research. There is a software called "Gipels" available on the internet which easily solves the LPP Problems along with the transportation problems. This presentation is co-developed with Sankeerth P & Aakansha Bajpai.
By:-
Aniruddh Tiwari
Linkedin :- http://in.linkedin.com/in/aniruddhtiwari
Introduction
The term problem solving is used in many disciplines, sometimes with different perspectives and
often with different terminologies. The problem-solving process starts with the problem
specification and end with a correct program.
The steps to follow in the problem-solving process are:
Problem definition
Problem Analysis
Algorithm development
Coding
Testing & Debugging
Documentation & Maintenance
The stages of analysis, design, programming, implementation and maintenance form the life cycle
of the system.
As you know Sci Hub is sometimes down due to some technical issue, So you can visits the new Sci Hub New Domain with its Extension. ThesisScientist.com is New domain alternative of Sci Hub.
If Sci Hub website not working properly than you will move toward to others websites like ThesisScientist.com. It is the best website for downloading free papers and thesis and Free Journals
Computer network is a distributed system consisting of loosely coupled computers and other
devices. Any two of these devices, which we will from now on refer to as network elements or
transmitting elements, can communicate with each other through a communication medium. In
order for these connected devices to be considered a communicating network, there must be a set
of communicating rules or protocols each device in the network must follow to communicate wit
another device in the network. The resulting combination consisting of hardware and software is a computer communication network or computer network in short. Figure 1.1 shows a computer
network
Java is a general-purpose; object oriented programming language developed by Sun Microsystems of USA in 1991. This language was initially called “Oak” by James Gosling, but was renamed “Java” in 1995. Java (with a capital J) is a high-level, third generation programming language, like C, Fortran, Smalltalk, Perl, and many others.Java was initially designed to solve on a small scale could also be applied to the Internet on a large scale. This realization caused the focus of Java to switch from consumer electronic to Internet Programming.Java was designed for the development of software for consumer electronic devices like TVs, VCRs, Toasters, Microwaves ovens and such other electronics devices.Java is a first programming language that is not tied to any particular hardware or operating system. Programs developed in Java can be executed anywhere on any system.
Project Evaluation and Estimation in Software DevelopmentProf Ansari
Cost-benefit analysis
It mainly comprise two steps
Identify and estimating all of the costs and benefits of carrying out the project and operating the delivered application.
Expressing these costs and benefits in common units
We need to evaluate the net benefit, that is, the difference between the total benefit and the total benefit and the total cost of creating and operating the system.
We can categorize cost according to where they originate in the life of the project.
Stepwise Project planning in software developmentProf Ansari
The following activities are:
Identify objectives and practical measures of the effectiveness in meeting those objectives.
Establish a project authority
Stakeholder analysis – identify all stakeholders in the project and their interests
Modify objectives in the light of stakeholder’s analysis
Establish methods of communication with all parties
2.4
Entity Integrity Constraint:
It states that in a relation no attribute of a primary key (K) can have a null value. If a K consists of a single attribute, this constraint obviously applies on this attribute, so it cannot have the Null value. However, if a K consists of multiple attributes, then none of the attributes of this K can have the Null value in any of the instances.
Referential Integrity Constraint :
This constraint is applied to foreign keys. Foreign key is an attribute or attribute combination of a relation that is the primary key of another relation. This constraint states that if a foreign key exists in a relation, either the foreign key value must match the primary key value of some tuple in its home relation or the foreign key value must be completely null.
Normalisation in Database management System (DBMS)Prof Ansari
Normalization is a technique to organize the contents of the table for transactional database and data warehouse.
First Normal Form :
Seeing the data in the example in the book or assuming otherwise that all attributes contain the atomic value, we find out the table is in the 1NF.
Second Normal Form :
Seeing the FDs, we find out that the K for the table is a composite one comprising of empId, projName. We did not include the determinant of fourth FD, that is, the empDept, in the PK because empDept is dependent on empId and empID is included in our proposed PK. However, with this PK (empID, projName) we have got partial dependencies in the table through FDs 1 and 3 where we see that some attributes are being determined by subset of our K which is the violation of the requirement for the 2NF. So we split our table based on the FDs 1 and 3 as follows :
It is a semantic data model that is used for the graphical representation of the conceptual database design. The semantic data models provide more constructs that is why a database design in a semantic data model can contain/represent more details. With a semantic data model, it becomes easier to design the database, at the first place, and secondly it is easier to understand later. We also know that conceptual database is our first comprehensive design. It is independent of any particular implementation of the database, that is, the conceptual database design expressed in E-R data model can be implemented using any DBMS. For that we will have to transform the conceptual database design from E-R data model to the data model of the particular DBMS. There is no DBMS based on the E-R data model, so we have to transform the conceptual database design anyway.
The schemas as it has been defined already; is the repository used for storing definitions of the structures used in database, it can be anything from any entity to the whole organization. For this purpose the architecture defines different schemas stored at different levels for isolating the details one level from the other.
Different levels existing pat different levels of the database architecture pare expressed below with emphasis on the details of all the levels individually. Core of the database architecture is the internal level of schema which is discussed a bit before getting into the details of each level individually.
INTRODUCTION TO Database Management System (DBMS)Prof Ansari
shared collection of logically related data, designed to meet the information needs of multiple users in an organization. The term database is often erroneously referred to as a synonym for a “database management system DBMS)”. They are not equivalent and it will be explained in the next section.
Master thesis on Vehicular Ad hoc Networks (VANET)Prof Ansari
The increasing demand for wireless devices and wireless communication tends to research on self-organizing, self-healing networks without the interference of any pre-established or centralized infrastructure/authority [2]. The networks with the absence of any pre-established or centralized authority are known as Ad hoc networks [4]. Ad hoc Networks are the kind of wireless networks that uses multi-hop radio relay.There are many comparative studies and surveys that compare various ad hoc routing in VANET environment. The simulations performed in these comparative studies are very basic do not incorporate with a large number of nodes in real Vehicular Ad hoc Network environment. The main aim of our dissertation work is to firstly investigate the reactive and proactive routeing protocols than examine the performance of selected reactive routing protocols i.e. Destination Sequence Distance Vector Routing (DSDV), Ad hoc On-Demand Distance Vector (AODV), Optimized Link State Routing (OLSR) and Dynamic Source Routing (DSR)by taking three performance metrics like network load, throughput and end-to-end delay with varying number of mobile nodes or vehicle node densityOPNET: Optimized Network Engineering Tool (OPNET) is a commercial network simulator environment used for simulations of both wired and wireless networks [20]. Several different OPNET versions have been released over the last few years; the latest version of OPNET is the OPNET 16.0. At present OPNET is licensed under Riverbed technologies. It allows the user to design and study the network communication devices, protocols, individual applications and also simulate the performance of routing protocol. It supports many wireless technologies and standards such as, IEEE 802.11, IEEE 802.15.1, IEEE 802.16, IEEE 802.20 and satellite networks. OPNET IT Guru Academic Edition is available for free to the academic research and teaching community.
Master Thesis on Vehicular Ad-hoc Network (VANET)Prof Ansari
In present, many people during the public died each year in vehicle accidents, therefore in almost countries some safety data i.e. traffic lights & velocity limits are applied, simply however it is not a better solution. Also government and number of automation industries regarded that vehicular safety is real challenging task [1]. Then equally result, to enhance people traffic safety of a new progressed particular technology is formulated i.e. VANET [4]. It is progress type of MANET (Mobile Ad-hoc Network). VANET manages a network within which vehicles are act nodes and applied as mobile nodes to construct a robust infrastructure-less ad-hoc network. In Figure 1 illustrates the basic components of VANET architecture. It builds the network among Inter-Vehicle, Vehicle-to-Roadside and Inter-Roadside communicating networks [4]. Moreover, apart from accidental-safety and security types, there are also broad varieties of applications in VANET are available and potential that can extend passenger comfort like predictable mobility by GPS, web browsing and information modify and so on. Vehicular Ad-hoc Network (VANET) is a novel formulated form of Mobile Ad-hoc Network (MANET), where moving nodes are vehicles same automobiles, cars, buses etc [2].
Read/Write control logic:
The Read/Write Control logic interfaces the 8251A with CPU, determines the functions of the 8251A according to the control word written into its control register.
It monitors the data flow.
This section has three registers and they are control register, status register and data buffer.
The active low signals RD, WR, CS and C/D(Low) are used for read/write operations with these three registers.
When C/D(low) is high, the control register is selected for writing control word or reading status word.
HOST AND NETWORK SECURITY by ThesisScientist.comProf Ansari
Network management means different things to different people. In some cases, it involves a solitary network consultant monitoring network activity with an outdated protocol analyzer. In other cases, network management involves a distributed database, auto polling of network devices, and high-end workstations generating real-time graphical views of network topology changes and traffic. In general, network management is a service that employs a variety of tools, applications, and devices to assist human network managers in monitoring and maintaining networks.
SYSTEM NETWORK ADMINISTRATIONS GOALS and TIPSProf Ansari
The goal of network administration is to ensure that the users of networks receive the information and technically serves with the quality of services they expect.
Network administration means the management of network infrastructures devices (such as router and switches)
Network administration compromises of 3 majors groups:
1. Network provisioning
2. Network operations
3. Network maintenance
The VB6 IDE (Integrated Development Environment) is a very simple and fully featured IDE. If you start out programming in VB6 you may end up being too spoiled to ever appreciate a more complicated and less functional IDE like most C++ IDEs. One feature which sets VB6 apart from various IDEs is the simplicity of its approach to GUI (Graphical User Interface) design.
As a general rule: Play with it. You're very unlikely to break anything that matters, so just explore and experiment with the IDE, and you'll learn more.
ppt on blogging and In order to make money blogging you’re going to need to have a blog. While this is pretty obvious it is also a stumbling block for many PreBloggers who come to the idea of blogging with little or no technical background.blogging ppt presentation
Software Engineering is the set of processes and tools to develop software. Software Engineering is the combination of all the tools, techniques, and processes that used in software production. Therefore Software Engineering encompasses all those things that are used in software production like :
Programming Language
Programming Language Design
Software Design Techniques
Tools
Testing
Maintenance
Development etc.
These days object-oriented programming is widely being used. If programming languages will not support object-orientation then it will be very difficult to implement object-oriented design using object-oriented principles. All these efforts made the basis of software engineering.
E-Commerce is defined as the paperless exchange of business information using Electronic Data Interchange (EDI), electronic mail (e-mail), computer bulletin boards, Electronic Funds Transfer (EFT), and other, similar technologies.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Using recycled concrete aggregates (RCA) for pavements is crucial to achieving sustainability. Implementing RCA for new pavement can minimize carbon footprint, conserve natural resources, reduce harmful emissions, and lower life cycle costs. Compared to natural aggregate (NA), RCA pavement has fewer comprehensive studies and sustainability assessments.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...ssuser7dcef0
Power plants release a large amount of water vapor into the
atmosphere through the stack. The flue gas can be a potential
source for obtaining much needed cooling water for a power
plant. If a power plant could recover and reuse a portion of this
moisture, it could reduce its total cooling water intake
requirement. One of the most practical way to recover water
from flue gas is to use a condensing heat exchanger. The power
plant could also recover latent heat due to condensation as well
as sensible heat due to lowering the flue gas exit temperature.
Additionally, harmful acids released from the stack can be
reduced in a condensing heat exchanger by acid condensation. reduced in a condensing heat exchanger by acid condensation.
Condensation of vapors in flue gas is a complicated
phenomenon since heat and mass transfer of water vapor and
various acids simultaneously occur in the presence of noncondensable
gases such as nitrogen and oxygen. Design of a
condenser depends on the knowledge and understanding of the
heat and mass transfer processes. A computer program for
numerical simulations of water (H2O) and sulfuric acid (H2SO4)
condensation in a flue gas condensing heat exchanger was
developed using MATLAB. Governing equations based on
mass and energy balances for the system were derived to
predict variables such as flue gas exit temperature, cooling
water outlet temperature, mole fraction and condensation rates
of water and sulfuric acid vapors. The equations were solved
using an iterative solution technique with calculations of heat
and mass transfer coefficients and physical properties.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Introduction to Programming
1. For More Visit: Https://www.ThesisScientist.com
Unit 1
Introduction to Programming
Introduction to Problem Solving
Problem Definition
Problems are undesirable situations, that prevent one from achieving an objective in a given situation, and
therefore, must be solved in order that the objective is achieved.
They occur frequently in our day-to-day life. Some of the problems are well understood, and people have
developed generic solutions to such problems, while some may be quite unique and hence, a solution is
required to be found each time they occur.
Problem Solving
The problems are so inevitable that from time immemorial people have been continuously developing tools
and techniques for handling them. In the latest sequel, the modern computers were invented. But the tools
are tools, after all. They do not solve the problems themselves nor do they suggest any solution or method
arriving at a solution. They only help solving the problems. The method of solving a problem remains more
or less in the domain of human endeavor so far.
Some problems can be defined fairly accurately while others are open-ended and hence it may not be
possible to define them accurately. One of the important factors in solving problems is that the problem
must be defined clearly and unambiguously.
It may be noted here that problem solving is both a science and an art in respective domains. A great deal of
domain-knowledge, intuition, human reasoning and experience are required in this process of problem
solving and therefore, each individual has his/her own unique way of solving a problem.
Some methods may be more general than others but a single set of solutions cannot be applied in all the
situations nor can a single method of finding solution may be applied always. A general method of problem
solving simply does not exist despite the existence of host of sophisticated tools.
Nonetheless, the steps involved in solving any problem may be generalized to some extent, more so in the
computer-based problem solving. One such sets of generalized methodology is sketched in Fig. 1.1
2. For More Visit: Https://www.ThesisScientist.com
Become aware of the problem
Gather information to increase the
understanding of problem situation
Define the problem in terms of
objectives, variables, and their interaction
Develop evaluation criteria Develop alternative solutions
Choose the most appropriate solution
Implement solution
Monitor and control the implementation
Figure 1.1: Steps in Problem Solving
Approaches to problem solving, remain guidelines at best. A number of such approaches have been
proposed for the purpose of problem solving. With little modifications these approaches may be employed
to attempt a solution to the given problem. They are general in the sense that they may be customized in
their applicability in various situations.
Top-down design
Top Down Design Approach is one of several problem-solving approaches and is based on the dictum –
“Divide and rule”. A small portion of problem is easier to solve at a time than the whole problem taken
together. In this approach, the problem is broken down into smaller fragments and fragments, further into
still smaller fragments till the fragments are small enough to be solved easily are separately.
The top-down design approach is based on the fact that large problems become more manageable if they
are divided into a number of smaller and simpler tasks, which can be tackled separately.
Example
Problem: How to reach Kolkata from Delhi by train.
3. For More Visit: Https://www.ThesisScientist.com
Let us apply top-down design approach on this problem. Break this problem into smaller problem as
follows:
Figure 1.2: Top-down Design
The problem has been broken into smaller problems each easily manageable and solvable. If need be,
these smaller tasks may be further broken into still smaller tasks. These smaller tasks – viz. how to buy a
ticket, can be solved easily than the whole problem at a time.
The advantages of this approach are : 1. The sub-problems may be solved independent of each other and 2.
They may be tested and modified, if necessary, separately.
Bottom-up Design
The bottom-up approach is opposite to that of the top-down. Here, the problem solver has to solve the most
basic (smallest) units in the hierarchy first and then use them to build more sophisticated bigger units. The
pure bottom-up approach is generally not recommended because it is difficult to anticipate which low level
units will be needed for solution of a particular problem. It can often be a useful first step to produce a
library of basic solutions before embarking on solving the macro problem.
The bottom-up approach as applied to the Delhi to Kolkata problem:
How to reach Kolkata from Delhi by train
How to reach
Delhi Rly
station
How to
buy
ticket
How to get
to the right
platform
How to
board the
train
How to alight
from the train
How to find
the right
platform No.
How to use
escalator to go
to a platform
4. For More Visit: Https://www.ThesisScientist.com
Figure 1.3: Bottom-up approach
In the bottom-up approach it is usually assumed that the basic sub-tasks created will be general enough to
be used more than once. Use of the solutions to sub-tasks, to construct a solution to the whole problem,
saves you repeating the same instructions time and again.
The obvious advantage of this approach is that the solutions to sub-problems may be re-used as and when
required saving time and effort.
Algorithm
An algorithm is a finite list of well-defined steps for solving a particular problem. These instructions, when
executed in the specified order, solve a problem, which the algorithm intends to solve. The algorithm must
be expressed in a language that is understood by the problem solver.
Writing an algorithm (Elements of Program Style)
An algorithm has three execution-sequences:
1) Sequence Logic or Sequential Logic
2) Selection or Conditional Logic
3) Iteration or Repetitive Logic
In "Sequence Logic" execution the instructions are executed in the obvious linear sequence one by one. The
sequence may be presented explicitly, by means of numbered steps, or implicitly, by the order in which the
instructions are written.
"Selection Logic" employs a number of conditions, which lead to a selection of one out of several
alternative instructions.
"Iteration Logic" allows execution of one or more instructions repetitively, a specified number of times or
until some condition becomes true.
How to reach Kolkata from Delhi by train
How to reach
Delhi Rly
station
How to
buy ticket
How to get to
the right
platform
How to board
the train
How to alight
from the train
How to find the
right platform
No.
How to use
escalator to go to
a platform
5. For More Visit: Https://www.ThesisScientist.com
Any language may be employed to write an algorithm as long as the executor of the algorithm understands
it. We will, however, use the following convention in writing an algorithm throughout this book:
1. An algorithm begins with a START instruction.
2. It ends with a STOP instruction.
3. One instruction is written on one line.
4. Each line is numbered sequentially for identification.
5. The instructions used are well understood by the problem-solver who will use it.
6. A container of a value (known as variable) is represented by any word that does not have language
specific meaning, e.g. A, B, and C etc.
7. A ¬¬ 6 means: store 6 in the variable named A.
8. A A + 1 means: add 1 to the value contained in the variable A and store the result back into it.
Similarly, A B * C would mean multiply values in B and C and store the result into A.
9. Standard arithmetic and logical operators may be employed with their respective meanings as
follows:
Arithmetical Operator Logical Operator
Add + Equal to =
Subtract - Not equal to <>
Multiply ¬ * Less than <
Divide / Greater than >
Remainder % Less than or equal to <=
Greater than or equal to >=
10. Input-Output instructions: Simple verbs like PRINT is used to output value(s) to the user and READ
for reading input value(s) from the user.
PRINT A means: print the value stored in the variable A on the screen.
PRINT A, 3 means: print value stored in variable A and then print 3.
READ A means: take a value from the user and store this value in the variable A.
READ A, B means read two values from user, store first in variable A and second in variable B.
11. Conditional instruction: A condition is an expression that evaluates to either TRUE or FALSE. For
example, (A>5) is a condition expression. If the value stored in variable A is 3, then this condition is
FALSE (i.e. 3 > 5) and if it is 7 then the condition is TRUE (i.e. 7 > 5). An IF instruction is written as
– IF (<condition>) then <action>.
IF (A>4) THEN PRINT 5
This instruction means, if the value contained in the variable A is more than 4, then print the value of
A on the screen. If not, do nothing. There is another form of IF instruction also.
IF (A>4) THEN PRINT 5 ELSE PRINT 10
6. For More Visit: Https://www.ThesisScientist.com
The meaning of the above instruction is that if the value contained in the variable A is more than 4
then print 5 on the screen otherwise print 10.
12. Loop instruction:
A GOTO instruction takes the execution sequence control to the specified instruction No.
GOTO 200
The above instruction means that now on execute the instruction No. 200 onwards.
A DO - WHILE instruction executes a given set of instructions repeatedly as long as the given
condition is true. Execution stops when the condition becomes false.
DO (STEP 2 TO 10) WHILE (A<5)
It means, execute step 2, step 3,…..step 10. Then check the condition (A<5). If the condition is
true then again execute step 2, step 3,…..step 10. Check the condition again. Repeat this process.
Execution stops when the condition (A<5) becomes false. The instructions enclosed within the
loop are executed once, at least.
A WHILE – DO instruction executes a given set of instructions repeatedly as long as the given
condition is true. Execution stops when the condition becomes false.
WHILE (A<5) DO (STEP 2 TO 10)
It means, check the condition (A<5). If the condition is true then execute step 2, step 3,…..step
10. Again check the condition. If the condition is true then again execute step 2, step 3,…..step
10. Check the condition again. Repeat this process. Stop when the condition (A<5) becomes
false.
Loop instruction: REPEAT – UNIT instruction executes a given set of instructions repeatedly
until the given condition becomes false.
REPEAT (STEP 2 TO 10) UNTIL (A<5)
It means, execute step 2, step 3,…..step 10. Then check the condition (A<5). If the condition is
false then again execute step 2, step 3,…..step 10. Check the condition again. Repeat this process.
Execution stops when the condition (A<5) becomes true.
Example
To print all even numbers from 2 to 16 on the screen. Assume that Print instruction prints the given value
on the screen. Use sequential logic.
1. START Begin the algorithm execution
2. PRINT 2 Print value 2
3. PRINT 4 Print value 4
4. PRINT 6 Print value 6
5. PRINT 8 Print value 8
6. PRINT 10 Print value 10
7. For More Visit: Https://www.ThesisScientist.com
7. PRINT 12 Print value 12
8. PRINT 14 Print value 14
9. PRINT 16 Print value 16
10. STOP Terminate the algorithm
As, is evident, this sequential method of printing, is not very nice way of doing the job. If you have to print
values up to 200, you may have to write as many as 100 such lines. Let us see how this algorithm may be
improved using branching (If – then) and looping (go to) in the next example.
Another algorithm for the same problem using selection and iteration logic:
1. START Begin the algorithm execution
2. A 1 Store 1 in the variable 1
3. IF (A % 2 = 0) THEN
PRINT A
If (A%2 is 0 then A contains even number) is true then
print the value stored in A, otherwise move to next line
without doing anything
4. A A + 1 Add 1 to value A contains and store the result back into A
5. IF (A <= 16) THEN GOTO
3
If the value contained in A is smaller than or equal to 16
then do not go to next line, go to line number 3 instead,
otherwise move to next line. In other words, repeat steps
(3,4,5) as long as value contained in A is less than or equal
to 16
6. STOP Terminate the algorithm
Obviously, this algorithm is far better than the previous one. If you have to print the values up to 200, all
you have to do is to change the loop termination condition (A<=16) to (A<=200) instead of writing 100
lines of code.
Another algorithm for the same problem using selection and iteration logic without checking for the
condition for A being even or odd:
1. START Begin the algorithm execution
2. A 2 Store 2 in the variable A
3. PRINT A Print the value stored in A
4. A A + 2 Add 2 to value A contains and store the result back into A
5. IF (A <= 16) THEN GOTO
3
If the value contained in A is smaller than or equal to 16
then do not go to next line, go to line number 3 instead,
otherwise move to next line. In other words, repeat steps
(3,4,5) as long as value contained in A is less than or equal
to 16
6. STOP Terminate the algorithm
8. For More Visit: Https://www.ThesisScientist.com
The above algorithm may also be written using while-do looping logic as below:
1. START Begin the algorithm execution
2. A 2 Store 1 in the variable 1
3. WHILE (A <=16) DO
(STEPS 4 TO 5)
Keep on executing steps 4 and 5 as long as condition (A <=
16) is true, i.e. as long as value stored in A is less than or
equal to 16, otherwise go to step next to the one specified
in the loop condition, i.e. No. 6
4. PRINT A Print the value stored in A
5. A A + 2 Add 2 to value A contains and store the result back into A
6. STOP Terminate the algorithm
Characteristics of Algorithm
Any list of instruction does not constitute an algorithm. An algorithm must have the following
characteristics:
Input: Zero or more values externally supplied to the algorithm.
Output: Zero or more values produced by the algorithm.
Definiteness: Each instruction must be clear and unambiguous, i.e. having one and only
meaning.
Finiteness: For all cases, the algorithm must terminate after a finite number of steps.
Effectiveness: Every instruction must be sufficiently basic and also feasible as far as execution
is concerned.
Implementation of Algorithm
Starting from a problem to be solved, constructing an algorithm for the solution of the same and solving the
problem using the algorithm, is known as algorithm implementation. Algorithm implementation involves
the following different phases of activities:
Problem definition: Understanding the information given and what result is asked for.
Problem Analysis: To analyze the problem to understand and formulate a possible line of attack in
order to solve it.
Algorithm Design: Applying top-down or bottom-up approach and describing the algorithm.
9. For More Visit: Https://www.ThesisScientist.com
Algorithm analysis: To evaluate the designed algorithm and if necessary design alternative algorithm to
suit the requirements better.
Execution: Algorithms, thus developed, may be employed by a person or a machine to solve
the problem.
In order that a computer may execute the algorithm, the algorithm must be translated into a language that
computers understand. An algorithm written in a computer language is known as a program. And
using an algorithm by translating it into a suitable computer language is known as its implementation. It
involves, among others, conversion of the data variables stated in the algorithm into the language specific
data types, selecting suitable data structures etc.
An algorithm may be implemented either in the hardware or in the software. It may also be implemented as
software embedded into the hardware, when it is known as firmware to distinguish it from software.
Developing an algorithm needs no knowledge of any computer language. But its implementation requires
the knowledge of the target computer language. Computer languages have different capabilities. Each
computer language has been designed to facilitate a particular type of algorithm implementation. Hence,
COBOL is more suited for business-related algorithms while FORTRAN for engineering-related
algorithms. C is, in this regard, a general-purpose language and is suitable for all types of algorithms.
Algorithm:
1. START
2. A 1
3. DO (STEP 3 TO 5) WHILE (A < 11)
4. PRINT A
5. A A + 1
6. STOP
Implementation in C language:
#include<stdioh>
main()
{
int a;
a=1;
while(a<11)
{
printf(“%d”,a);
a++;
}
}
Note that the only language a digital computer understands is binary coded instructions. Even the above
implementation will not execute on a computer without further translation into binary (machine) code. This
translation is not done manually, however. There are programs available to do this job. These translation
programs are called compilers and interpreters.
Compilers and interpreters are programs that take a program written in a language as input and translate it
into machine language. Thus a program that translates a C program into machine code is called C compiler;
BASIC program into machine code is called a BASIC compiler and so on.
Therefore, to implement an algorithm on a computer you need to have a compiler for the language you have
chosen for writing the program for the algorithm.
Analysis and Efficiency of Algorithm
10. For More Visit: Https://www.ThesisScientist.com
The correctness of an algorithm in solving a problem is of paramount importance. An algorithm giving
incorrect solution is no better than no algorithm at all.
Besides, an algorithm may solve a problem but the method may not be cost effective. The cost that incurs in
executing an algorithm is in terms of how much space and how much time is required in its execution. Each
variable requires space and each instruction takes some time to execute.
Therefore, analysis of algorithms for their correctness and space and time requirements is a major task in
algorithm design. In order to compare correct algorithms these two bases of space and time are taken into
consideration.
To determine the execution time the following information is required:
Time taken by the executor of the algorithm to read one instruction.
Time taken to understand and interpret the instruction.
Time taken to execute the instruction
The actual time is not easy to determine because each executor of the algorithm takes its own time. The
time taken to execute an instruction also depends on instructions themselves. Some instructions take more
time to execute than others. Another approach called Frequency Count method also exists. In this method
number of operations are counted. The actual time will be proportional to this count and can be computed
by suitably multiplying by some factor. The highest order of the frequency count variable in the total time
expression is known as Order of the complexity denoted by O(). Less the order of complexity, more
efficient the algorithm is.
The space requirement can be calculated by maximum number of variables used by the algorithm in some
arbitrary space unit for the purpose of comparison.
These measurements may be different in different situations, but in case, a computer executes the
algorithm, these values may be found out more accurately.
Consider the following examples:
Example 1
Consider the algorithm to print character “A” N square times:
1. START
2. I 1
3. IF (I > N) THEN GOTO 11
4. J 1
5. IF (J > N) THEN GOTO 9
6. PRINT “A”
7. J J + 1
8. GOTO 5
9. I I + 1
10. GOTO 3
11. For More Visit: Https://www.ThesisScientist.com
11. STOP
Let us count the number of times operations are executed. Assume that START takes 1 unit of time,
assignment () takes one unit of time, comparison (>=) takes two units of time, arithmetic operation (+)
takes one unit of time, GOTO and STOP take one unit of time each. Let us compute the frequency count of
this algorithm.
1. START : 1 unit
2. I 1 : 1 unit
3. IF (I > N) THEN GOTO 11 : (2 + 1 = 3) units
4. J 1 : (1 * N) units
5. IF (J > N) THEN GOTO 9 : (2 + 1) * N units
6. X X + 1 : (N * N) * 1 units
7. J J + 1 : (N * N) * 1 units
8. GOTO 5 : (1 * N) units
9. I I + 1 : (1 * N) units
10. GOTO 3 : (1 * N) units
11. STOP : 1 units
Total units of time taken = 1+1+3+N+3*N+N*N+N*N+N+N+N+1
= 5+7*N+2*N2
The order of complexity = highest order of the frequency count variable
= 2
= O(N2
)
Fundamental Algorithms: Array Techniques
An array is a group of same type of variables, having same name. Different they are only in the way they
are referred to. By same type means the variables can store same type of data items.
There are several types of data items, different in size and value. Mainly, there are two types – Numeric (on
which arithmetic operations may be performed) and Alpha-numeric (on which arithmetic operations cannot
be performed). Thus a value 123 is a numeric value while “123” is an alpha-numeric value. Alphanumeric
values are enclosed within quotes to be distinguished from normal word. 1, 2 and 3 are three characters in
“123” and not one hundred and twenty three.
A variable can store either a numeric type data or alpha-numeric type data but not both. Size of a variable
has technical meaning in the context of computers. But as of now, we can afford to ignore it. More about
array in Chapter 13.
An array is defined in different ways in different languages. We will define it in the following way in our
present discussion:
int A[10]
12. For More Visit: Https://www.ThesisScientist.com
A[1] A[2] A[3] A[4] A[5] A[6] A[7] A[8] A[9] A[10]
This instruction creates 10 storage variables, each capable of storing an integer value and having name A.
Different variables represented by this array would be A[1], A[2], A[3]…A[10]. The value enclosed within
the [] is called index of the array.
Similarly,
char BB[50]
will create 50 storage variables, each capable of storing a character value(i.e. „a‟, „b‟,….‟z‟, „A‟, „B‟….‟Z‟,
„0‟,‟1‟,‟2‟…‟9‟, „!‟, „?‟, „/‟ etc.) and having name BB. Different variables represented by this array would
be BB[1], BB[2], BB[3]…BB[50]. The value enclosed within the [] is called index of the array. A[I] would
mean ith
A variable and BB[5], 5th
element of array BB.
Example 4
Consider the following algorithm:
1. START : Start the algorithm
2. char N[6] : Create an array(N) of 6 characters
3. N[1]‟H‟ : Store „H‟ in N[1]
4. N[2]‟e‟ : Store „e‟ in N[2]
5. N[3]‟l‟ : Store „l‟ in N[3]
6. N[4]‟l‟ : Store „l‟ in N[4]
7. N[5]‟o‟ : Store „o‟ in N[5]
8. N[6]‟!‟ : Store „!‟ in N[6]
9. I 1 : Store 1 in variable I
10. IF (I > 6) THEN GOTO 14 : Execute 11 to 13, 6 times
11. PRINT N[I] : Print N[1],N{2]….N[6]
12. I I + 1 : Increment I by 1
13. GOTO 10 : Take the execution control to 10
14. STOP : Terminate the algorithm
This algorithm prints Hello! on the screen. The column on the right is comment column, just to make the
algorithm more understandable and is not part of the algorithm.
Searching, Sorting and Merging Techniques
Some of the most fundamental algorithms applicable on arrays are described below.
Searching
13. For More Visit: Https://www.ThesisScientist.com
There are a number of occasions when searching a value in a group of variables is required. There are a
number of standard algorithms for this purpose. They are known by standard names like – Linear search,
Binary search etc. Here we will discuss these two search algorithms as applied on arrays.
Linear search
This search algorithm is the simplest and relies on comparing each value stored in the array of values, one-
by-one until either the value is found or all the elements have been searched.
1. Situation : Given an array of N number of integers.
2. Problem : To find whether an integer P exists in this array or not. If yes, where?
3. Solution : Search the array, from one element to the last, for this value P.
4. Algorithm :
1. START
2. int A[N] (loaded with values)
3. I 1
4. IF (I > N) THEN GOTO 8
5. IF (A[I] = P) THEN GOTO 8
6. I I + 1
7. GOTO 4
8. IF (I > N) THEN GOTO 11
9. PRINT “VALUE P WAS FOUND IN THE ARRAY AT”, I, “th POSITION”
10. GOTO 12
11. PRINT “VALUE P WAS NOT FOUND IN THE ARRAY”
12. STOP
Binary search
This search algorithm is applicable on the array, which are sorted either in ascending or descending order.
This algorithm is much faster than linear search.
1. Situation : Given an array of N number of integers sorted in ascending order.
2. Problem : To find whether an integer P exists in this array or not.
3. Solution : Divide the array into two halves. Take the half to which P belongs.
Continue this process until either you get the P or its absence is indicated.
4. Algorithm :
1. START
2. int A[N] (loaded with values in ascending order)
14. For More Visit: Https://www.ThesisScientist.com
3. J 1
4. K N
5. I Integral part of((K + J)/ 2)
6. IF (A[I] = P) THEN GOTO 9
7. IF (A[I] > P) THEN GOTO 11
8. IF (A[I] < P) THEN GOTO 14
9. PRINT “P WAS FOUND”
10. GOTO exit
11. IF (I <= 1) THEN GOTO 17
12. J I
13. GOTO 5
14. IF (I <= 1) THEN GOTO 17
15. K I
16. GOTO 5
17. PRINT “VALUE P WAS NOT FOUND IN THE ARRAY”
18. STOP
Sorting
Sorting refers to the operation of arranging data in some given order, such as increasing or decreasing, with
numerical data or alphabetically, with character data. There exist a number of standard algorithms for this
purpose like – Bubble sort, Quick sort, Insertion sort, Selection sort, Heap sort, Bin sort etc. Each algorithm
has its advantages and conditions for its applicability. We will discuss here sorting with an input and an
output array.
Sorting with two arrays
In this sorting algorithm, the smallest value from the array is selected and is inserted into the second array.
Then next smallest value is inserted and so on.
1. Situation : Given an array of N number of integers to be sorted in another array.
2. Problem : To sort this array into an output array. Let the given array be A[] and result array
be B[]
3. Solution : Starting from the first smallest value to the last – pick one from the given array
and insert into the result array.
4. Algorithm:
1. START
2. int A[N] (loaded with values to be sorted in ascending order)
3. int B[N] (empty result array)
15. For More Visit: Https://www.ThesisScientist.com
4. I 1
5. M A[1]
6. IF (I > N) THEN GOTO 16
7. J 1
8. IF (J > N) THEN GOTO 13
9. IF (A[J] > M) THEN GOTO 11
10. M A[J]
11. J J + 1
12. GOTO 8
13. B[I] M
14. I I + 1
15. GOTO 6
16. STOP
Merging
Merging is an operation that takes two sorted (either ascending or descending order) arrays and creates a
third array, which contains all the values from both the arrays in sorted form. The arrays A and B, both
sorted in ascending order have been merged to get array C, as shown below.
A[5] of integers
5 7 9 11 18
B[7] of integers
1 4 10 13 17 19 24
C[12] of integers
1 4 5 7 9 10 11 13 17 18 19 24
In this merging algorithm, the smaller of the values from the two input arrays A and B, is taken at a time an
inserted into the result array C.
1. Situation : Given two arrays A and B of N and M number of integers in sorted order.
2. Problem : To merge these arrays into the result array C.
3. Solution: Take the smaller value of the two arrays A and B, at a time an insert
into the result array C.
4. Algorithm:
1. START
2. int A[N] (loaded with values sorted in ascending order)
16. For More Visit: Https://www.ThesisScientist.com
3. int B[N] (loaded with values sorted in ascending order)
4. int C[N + M] (result array with sufficient number of cells)
5. I 1
6. X A[1]
7. Y B[1}
8. IF (I > N+M) THEN GOTO 24
9. J 1
10. IF (J > N) THEN GOTO 15
11. IF (A[J] > X) THEN GOTO 13
12. X A[J]
13. J J + 1
14. GOTO 10
15. P 1
16. IF (P > M) THEN GOTO 21
17. IF (B[P] > Y) THEN GOTO 19
18. Y B[P]
19. P P + 1
20. GOTO 17
21. IF (X < Y) THEN C[I] <- X ELSE C{I} <- Y
22. I I + 1
23. GOTO 8
24. IF (J >= M) THEN GOTO 34
25. C[I] J
26. J J+1
27. I I+1
28. GOTO 24
29. IF (P >= N) THEN GOTO 34
30. C[I]B[P]
31. P P+1
32. I I+1
33. GOTO 29
17. For More Visit: Https://www.ThesisScientist.com
34. STOP
Text Processing and Pattern Search
Text Processing
A text or string is an array of characters. A terminating character, usually called a NULL character,
terminates each string. A string constant is denoted by any set of characters included in double-quote
marks. Thus, “Hello World!” is a text having 12 characters.
Text processing involves accessing individual character of the text and processing it in desired way. A
number of operations are possible on text. A complete set forms a subject of its own and is dealt with in
Chapter-20. We, shall, however, consider a few basic text-processing operations and corresponding
algorithms.
Example 5
1. Situation : Given an array of 5 characters A[].
2. Problem : To print the characters in reverse order.
3. Solution : Take the last value first and print, then second last and so on.
4. Algorithm:
1. START
2. int A[5] (loaded with a word WORLD)
3. I 5
4. IF (I < 1) THEN GOTO
5. PRINT A[I]
6. I I - 1
7. GOTO 4
8. STOP
Example 6
1. Situation : A large piece of text is given in a character array A[].
2. Problem : To print the count of a word stored in array B[] occurring in A[].
3. Solution: Take one word at a time from A[], if this is also the word contained in B[]
increase the count by 1, take next and so on.
4. Algorithm:
1. START
2. C 0
3. IF (No word left in A[]) THEN GOTO
18. For More Visit: Https://www.ThesisScientist.com
4. READ a word from A[] into C[]
5. IF (C[] = B[]) THEN C C + 1
6. GOTO 3
7. PRINT “COUNT =”, C
8. STOP
Pattern Matching
A text may be contained within another text. A piece of text forms a pattern of the constituent characters.
Searching for the occurrence of a text pattern into another text is known as pattern matching (more strictly
text-pattern matching). The pattern to be searched in a given text is known as sub-string.
The pattern to be searched is:
u s
Suppose, the given text is:
T H E B U S W A S C R O W D E D
The pattern was found at position 6 in the text.
When one is searching for a sub-string within a given text, there must be some method of returning the
position of the sub-string within the string. If the sub-string is found, this position is given by an integer
value indicating the character position of the left-most character of the sub-string being sought. Pattern
matching has been dealt with in detail in chapter 20.
Dynamic Data Structure Algorithms
A variable is a data storage space that can be identified by a name.
A group of variables that can be treated as a single unit and has some pre-specified properties as well as
operations defined on it, is known as data-structure. Array is one such data structure.
A data structure, like an array, whose number of elements must be specified before it is used, is called static
data structure. Such data structures cannot accommodate more values than its specified capacity.
A dynamic data structure, on the other hand, is a data structure whose number of elements need not be
specified before it is used. It can increase and decrease to accommodate varying number of elements. More
number of data members may be added and deleted as and when required.
This dynamic nature of a data structure is achieved by the use of the concept of pointer. A pointer is a
variable that can store address of another variable. Thus, a pointer introduces the possibility of assembling a
collection for storage building blocks, called nodes, into flexible structures. By alerting the values of
pointers, nodes can be attached, detached, and reassembled in patterns that grow and shrink as execution of
algorithm progresses. A node usually has data storage and at least a pointer storage associated with it. This
pointer points to the next node of the data structure.
Integer
type
storage
Pointer
type
storage
1st
Node
Integer
type
storage
Pointer
type
storage
2nd Node
Start pointer End pointer
19. For More Visit: Https://www.ThesisScientist.com
Under the array implementation, a fix set of nodes represented by an array is established at the start of
execution. A pointer to a node is represented by the relative position of the node within the array. The
disadvantage of that approach is two fold. First, the number of nodes that are needed often cannot be
predicted when an algorithm is written. Usually, the data with which the algorithm is executed determines
the number of nodes necessary. Thus no matter how many elements the array of nodes contains, it is always
possible that the algorithm will be executed with input that requires a larger number of nodes.
The second disadvantage of the array approach is that, whatever number of nodes is declared, it must
remain allocated to the program throughout its execution. For example, if 500 nodes of a given type are
declared, the amount of storage required for those 500 nodes is reserved for that purpose. If the algorithm
actually uses only hundred or even ten nodes in its execution the additional nodes are still reserved and their
storage cannot be any other purpose.
The solution to this problem is to allow nodes that are dynamic, rather than static. That is, when a node is
needed, storage is reserved for it, and when it is no longer needed, the storage is released. Thus the storage
for nodes that are no longer in use is available for another purpose. Also, no predefined limit on the number
of nodes is established. As long as sufficient storage is available to the job as a whole, part of that storage
can be reserved for use as a node.
There are a number of fundamental algorithms to carry out standard operations on these dynamic data
structures.
Traversal algorithm:
This algorithm scans the whole of data structure, starting with the start node to the end node, visiting each
node in between.
1. START
2. P Start node of the data structure
3. IF(Next-node-pointer of P is End-pointer) THEN GOTO 6
4. P Next-node-pointer of P
5. GOTO 3
6. STOP
Searching algorithm:
The algorithm to search a value (say X) in a data structure:
1. START
2. P Start node of the data structure
3. Q 0
4. IF(Next-node-pointer of P is End-pointer) THEN GOTO 6
5. IF (The value stored at this node is equal to X THEN Q 1 AND GOTO 8
6. P Next-node-pointer of P
20. For More Visit: Https://www.ThesisScientist.com
7. GOTO 3
8. IF(Q = 0) THEN PRINT “NOT FOUND” AND GOTO 10
9. PRINT “FOUND”
10. STOP
The other dynamic data structures such as linked list, trees and graph and the related algorithms are
discussed in later chapters of data structure.
Recursive Algorithms
We have seen that an algorithm is an entity having a STARting point and a STOPping point. Between these
two limits lies its definition. Executing an algorithm may be thought of as calling the algorithm passing
values to it and receiving what it returns after execution. When an algorithm uses or calls itself within its
definition, it is known as recursive algorithm. Recursion requires comparatively more space for execution.
In each call to itself, the algorithm creates a copy of itself and the associated variables.
In order to understand recursion in an algorithm, we will use slightly modified form of an algorithm. We
will give a name to an algorithm along with the inputs required by it to carry out its task as also the output
produced. Thus, using this notation, an algorithm would look like as follows:
Algorithm: ABC (input X, output Y)
1. START
2. –
3. –
4. OUTPUT Y
5. STOP
In this notation, wherever, ABC (the name of the algorithm) is mentioned elsewhere, it is replaced by the
output value of the algorithm ABC.
Let us see, through an example, how recursion works. A detailed treatment to recursion is done in later
chapters.
Example 7
1. Problem: Compute mathematical factorial of a positive integer N. Factorial of a +ve
integer N is given by the product N*(N-1)*(N-2)…..3*2*1
2. Solution: Since N! = N*(N – 1)! , execute the algorithm recursively on (N-1) etc.
3. Algorithm:
1. Algorithm: Factorial(input N, output Y)
2. START
3. Y N
4. IF (N = 1) THEN GOTO 5
5. Y Y * Factorial(N – 1)
21. For More Visit: Https://www.ThesisScientist.com
6. OUTPUT Y
7. STOP
Note that the algorithm Factorial is using itself in its definition. The value N is passed to the algorithm, the
algorithm executes itself with input value (N-1), which executes itself again with input value (N-2) and so
on, till it reaches 1. At this point it starts giving back the calculated values. Each output value is multiplied
and the final result is the factorial required as explained below with input value 3:
Algorithm: Factorial(input 3, output Y)
1. START
2. Y 3
3. IF (N = 1) THEN GOTO 5
4. Y 3 * Factorial(3 – 1) :Factorial 2 replaced by 2*1 = 2
5. OUTPUT Y
6. STOP
Algorithm: Factorial(input 2, output Y)
1. START
2. Y 2
3. IF (N = 1) THEN GOTO 5
4. Y 2 * Factorial(2 – 1) : Factorial 1 replaced by 1
5. OUTPUT Y
6. STOP
Algorithm: Factorial(input 1, output Y)
1. START
2. Y
3. IF (N = 1) THEN GOTO 5
4. Y 1 * Factorial(1 – 1)
5. OUTPUT Y
6. STOP
One important requirement for a recursive algorithm to be correct is that it does not generate an infinite
sequence calls on itself. Clearly, any algorithm that does generate such a sequence can never terminate.
Flow Charting
In the previous section we had described algorithms to be one of the ways for expressing a solution to the
given problem. As stated earlier, an algorithm may be expressed in any language provided that the executor
of the algorithm understands the language. For this purpose a sub-set of English language was used so far.
Output 3*2*1 = 6
22. For More Visit: Https://www.ThesisScientist.com
One can appreciate that the construct of sentences differs from person to person and leaves enough scope
for misinterpretation. Towards the standardization of the representation of the solution another tool of
expression, called Flowchart is available. It is very commonly used for logic representation.
Instead of using English like sentences, a flowchart uses a set of symbols to represent
the solution. This technique of representing the solution in pictorial form is called
flowcharting.
Flowchart Symbols
Flowcharts involve the use of simple geometric symbols to represent the beginning or end of an algorithm
(oval), a process (rectangle), a decision (rhombus), or an input/output process (parallelogram) as show in
following figure.
Symbols Specification
Start of End of the Program
Computational steps
Input or Output instruction
Decision making and
branching
Connectors of two parts of
a program
Flow Lines
To sum it up,
Flowcharts are tools to express algorithms.
Being graphical in nature, they are easier to understand, at a glance, than a narrative description.
Algorithms can be reviewed and corrected easily, if found faulty.
They provide effective algorithm documentation.
With a flowchart drawn, it is easier to explain an algorithm or discuss the solution.
Every flowchart must have an oval symbol at the beginning and one at the end, representing the
start and the end of the algorithm.
The following example will help you to understand the use of the different symbols in a flowchart.
Example 9
Problem: To find the sum of two numbers.
23. For More Visit: Https://www.ThesisScientist.com
Flowchart
Branching in Flowchart
Branching is the process of choosing one of the several available paths of computations. Consider the
following example.
Book title Author Price
Learn C XXX $45
Learn Data structure YYY $12
Programming
Techniques
ZZZ $ 24
You need to understand that in branching only one path can be selected, based upon a particular condition.
In the above case, the condition is that you need to buy the cheapest book. Only one book can satisfy this
condition and that happens to be the book “Learning Data structure”.
The branching condition is specified using the rhombus symbol. The condition can evaluate to either TRUE
or FALSE. If the condition evaluates to TRUE, then one action is performed else some other action is
performed.
Consider the following example.
Example 10
Problem Check if a given number is even or odd.
Flowchart
Start
Read A,B
A A + B
Print A
Stop
24. For More Visit: Https://www.ThesisScientist.com
According to the above flowchart, the remainder of the division is checked. If the remainder is 0, then the
path labeled “Yes” is selected and the even number is displayed. Else the path labeled “No” is selected and
the odd number is displayed.
Example 11
Problem: To choose the largest of three numbers a, b, c.
Flowchart
Start
Read
A
Divide A by
2
Is
Remainder = 0
Print
“Odd”
Print
“Even”
Stop
YesNo
Start
Read
A,B,C
IS A>B
Yes No
25. For More Visit: Https://www.ThesisScientist.com
Connecters
When flowchart is very big
It may not fit in a single page.
It may be difficult to interconnect all boxes directly.
In such cases, flowcharts can be broken into parts and connectors can be used to indicate the location of the
joins. Each connector symbol has a unique number that is specified within the connector and an arrow is
drawn into it. At the point where the chart is broken, another connector with the same number and an arrow
pointing away from it is drawn at the point where the broken chart is to be joined again.
Start
Read A,B,C
IS A>B
Yes No
IS A>C IS C>B
Print A Print C Print B
Stop
Yes NoYesN
o
26. For More Visit: Https://www.ThesisScientist.com
Connectors are inserted at the point where the flowchart splits. However, the location of each join is clearly
indicated by the corresponding number.
Flow Chart Types
SEQUENCE DECISIONS (Selection)
1 2
IS A>C IS C>B
Print A Print C Print B
Stop
Yes NoYesNo
1 2
27. For More Visit: Https://www.ThesisScientist.com
OTHER DECISION STRUCTURES
28. For More Visit: Https://www.ThesisScientist.com
LOOPING STRUCTURES
Repeat Until While/ While-end
Loop Using an Automatic Counter
29. For More Visit: Https://www.ThesisScientist.com
Practice of good flow-charting
1. There should be only one start and one stop symbol in the entire flow-charting
sequence.
2. For micro level flowcharts, start and stop symbols are represented by the pre-defined process‟s
identification code and the RETURN symbol.
3. The direction of arrows should always be from top to bottom and left to right.
4. Crossing of lines should always be avoided by using the connector syntax.
5. The symbols should be drawn neatly especially the arrowheads.
Benefits of Flowcharting
1. Easy to understand
2. Conciseness
1. Guide for coding
2. A tool for documentation
CASE STRUCTURE
30. For More Visit: Https://www.ThesisScientist.com
Limitations of Flowcharting
1 Not suitable for large algorithms spanning over multiple pages
2 Since it cannot be directly converted into programs, it is not worth the effort it requires.
Decision Table
In the section of flowchart we had mentioned that the following symbol could be used to illustrate the
condition and appropriate action.
To depict the logic in this way, one has to make sure of unambiguity in conditions and corresponding
actions. Ambiguity automatically arises when conditions are complex and if not handled properly, different
persons may interpret them in different way. Such complex conditions can unambiguously be depicted with
the help of Decision Tables.
A decision table is a table of contingencies and corresponding actions to be taken. The decision table has
three parts – Condition part, Action part and Rule part(see fig below).
Rules
Condition
(IF)
A
B
Actions
(THEN)
C
D
The conditions on which the decision has to be taken are listed in the conditionpart of the table(A,B). The
actions, similarly, are listed in the actions part (C,D). Each column of this table is a decision. To understand
the concept let us consider the following example.
Example 12
A company has decided to award a sum of Rs. 3500/- to its employees who meet the following criterion of
selection. “Working in the company for more than 5 years or salary is less than
Rs. 5000 and attendance is more than 300 days in the last year”.
Now the question is that who are the employees who get the sum of Rs 3500/- as an award.
A person may interpret the rule as: (Working in the company for more than five years OR salary is less than
Rs. 5000/-) and (Attendance of last year is more than 300 days)
Condition
Yes No
31. For More Visit: Https://www.ThesisScientist.com
If the rule is interpreted in this way then a person with: (Six years experience, Salary Rs. 4000- and 200
days of attendance will not get Rs. 3500/- as award.
Another person may interpret the rule in a different way as described below.
(Working in the company for more than five years) OR (Salary less than Rs. 5000/- and attendance of last
year is more than 300 days)
According to this interpretation of the rule the same person will get the award of Rs. 3500/- and this may be
what management wanted.
Readers should note that if the rules are not defined properly action might lead to erroneous results. Now
the question is, how to convey the rules and actions properly.
For this, let us analyze the condition in the following manner.
There are three conditions
(a) Working in the company for more than 5 years
(b) Salary less than Rs. 5000/-
(c) Attendance is more than 300 days
These conditions can either be true or false. “Y” represents the true condition and “N” false. All these three
conditions combined together can form 23
= 8 combinations. These conditions and possible values can be
represented in the form of a table:
C1 Working > 5 YEARS Y Y Y N Y N N N
C2 Salary < Rs. 5000 Y Y N Y N Y N N
C3 Attendance > 300
Days
Y N Y Y N N Y N
Against all these combinations of conditions there are two actions that can be taken.
(a) A sum of Rs. 3500/- is awarded
(b) A sum of Rs. 3500/- is not awarded
If these actions are combined with above table in which X against action represents that action is taken,
then the complete table will represent the rule clearly.
C1 Working > 5 YEARS Y Y Y N Y N N N
C2 Salary > Rs. 5000 Y Y N Y N Y N N
C3 Attendance > 300
Days
Y N Y Y N N Y N
A1 Sum Awarded X X X X X
C1 Sum Not Awarded X X X
This table representing the condition action and rules of action is termed as Decision Table.
Advantage of Decision Tables
1. They ensure that the user makes a clear and complete statement of the problem.
2. They provide an efficient means of communication between the user and the algorithm developer.
32. For More Visit: Https://www.ThesisScientist.com
3. They ensure that algorithm descriptions are structured in modules for ease.
4. Alterations and additions can easily be made (and, incidentally, the redrawing of flowcharts is
unnecessary since typists can make fair copies.
5. Decision tables provide a standard format, and deviations from the standard are immediately
apparent.
6. Algorithm can be automatically created from tables.
Pseudo-code
As stated earlier, an executor can execute an algorithm if he/she understands the language of the algorithm.
In case it is desired to execute the algorithm by computer, the algorithm must be translated into a computer
language. An algorithm written in computer language is known as a computer program. There exist a
number of programming languages, each with their own advantages and limitations.
However, since it is not known, a-priori, which programming language will be used for coding the
algorithm into a program, an intermediate language, which is somewhat between English and a true
programming language, is used. This language is called Pseudo-code.
Pseudo-code defines the logic to be used in the program, and is referred to as being "neat notes to yourself".
As notes the pseudo-code you write for a program is not the detail code for the program - if it were then it
would not be notes! Therefore, when you are creating the pseudo-code, you are providing enough
information to "jog your memory" as to what is needed, and work through the logic flow of the program.
Keep in mind also that someone else could, in theory, use the pseudo-code you create for writing the
program in FORTRAN, C++, Visual Basic, etc. Because of this reason, you don't want to use too many
"language specific" references, but rather use "generic" programming constructs.