100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary programming $6.39   Add to cart

Summary

Summary programming

 1 view  0 purchase
  • Course
  • Institution

A note on the field of programming, how to learn programming and training courses for programming, learning programming from scratch to professionalism, learning programming for beginners to professionalism, programming languages

Preview 4 out of 205  pages

  • July 19, 2023
  • 205
  • 2022/2023
  • Summary
  • Secondary school
  • 1
avatar-seller
INTRODUCTION TO C++ UNIT 1



1
Algorithms, Flowcharts & Program
Design

Unit Structure:
1.1 Objectives
1.2 Introduction
1.3 Algorithms
1.3.1 Expressing Algorithms
1.3.2 Benefits of Using Algorithms
1.3.3 General Approaches in Algorithm Design
1.3.4 Analysis of Algorithms
1.4 Flowcharts
1.4.1 Advantages of Using Flowcharts
1.4.2 Limitations of Using Flowcharts
1.4.3 When to Use Flowcharts
1.4.4 Flowchart Symbols & Guidelines
1.4.5 Types of Flowcharts
1.5 Program Design
1.5.1 Activities involved in Program Design
1.5.2 Object-Oriented Formulations
1.6 Summary
1.7 Unit End Exercises
1.7.1 Questions
1.7.2 Programming Projects
1.8 Further Reading

1.1 OBJECTIVES

After completing this chapter, you will be able to:
 Understand the basics and usefulness of an algorithm,
 Analyse various algorithms,
 Understand a flowchart and its advantages and limitations,
 Steps involved in designing a program.

1.2 INTRODUCTION

A computer is a useful tool for solving a great variety of
problems. To make a computer do anything (i.e. solve a problem), you
have to write a computer program. In a computer program you tell a
computer, step by step, exactly what you want it to do. The computer
then executes the program, following each step mechanically, to
accomplish the end goal.
INSTITUTE OF DISTANCE & OPEN LEARNING 1

,INTRODUCTION TO C++ UNIT 1

The sequence of steps to be performed in order to solve a
problem by the computer is known as an algorithm.

Flowchart is a graphical or symbolic representation of an
algorithm. It is the diagrammatic representation of the step-by-step
solution to a given problem.

Program Design consists of the steps a programmer should do
before they start coding the program in a specific language. Proper
program design helps other programmers to maintain the program in
the future.

1.3 ALGORITHMS

Look around you. Computers and networks are everywhere,
enabling an intricate web of complex human activities: education,
commerce, entertainment, research, manufacturing, health
management, communication, even war. Of the two main
technological underpinnings of this amazing proliferation, one is the
breathtaking pace with which advances in microelectronics and chip
design have been bringing us faster and faster hardware. The other is
efficient algorithms that are fuelling the computer revolution.

In mathematics, computer science, and related subjects, an
algorithm is a finite sequence of steps expressed for solving a problem.
An algorithm can be defined as “a process that performs some
sequence of operations in order to solve a given problem”. Algorithms
are used for calculation, data processing, and many other fields.

In computing, algorithms are essential because they serve as the
systematic procedures that computers require. A good algorithm is like
using the right tool in the workshop. It does the job with the right
amount of effort. Using the wrong algorithm or one that is not clearly
defined is like trying to cut a piece of plywood with a pair of scissors:
although the job may get done, you have to wonder how effective you
were in completing it.

Let us follow an example to help us understand the concept of
algorithm in a better way. Let’s say that you have a friend arriving at
the railway station, and your friend needs to get from the railway
station to your house. Here are three different ways (algorithms) that
you might give your friend for getting to your home.


 The taxi/auto-rickshaw algorithm:
 Go to the taxi/auto-rickshaw stand.
 Get in a taxi/auto-rickshaw.
 Give the driver my address.
 The call-me algorithm:
 When your train arrives, call my mobile phone.
INSTITUTE OF DISTANCE & OPEN LEARNING 2

,INTRODUCTION TO C++ UNIT 1
 Meet me outside the railway station.
 The bus algorithm:
 Outside the railway station, catch bus number 321.
 Transfer to bus 308 near Kurla station.
 Get off near Kalina University.
 Walk two blocks west to my house.

All these three algorithms accomplish the same goal, but each
algorithm does it in a different way. Each algorithm also has a different
cost and a different travel time. Taking a taxi/auto-rickshaw, for
example, is the fastest way, but also the most expensive. Taking the
bus is definitely less expensive, but a whole lot slower. You choose the
algorithm based on the circumstances.

In computer programming, there are often many different
algorithms to accomplish any given task. Each algorithm has
advantages and disadvantages in different situations. Sorting is one
place where a lot of research has been done, because computers spend
a lot of time sorting lists.

Three reasons for using algorithms are efficiency, abstraction and
reusability.
 Efficiency: Certain types of problems, like sorting, occur often
in computing. Efficient algorithms must be used to solve such
problems considering the time and cost factor involved in each
algorithm.

 Abstraction: Algorithms provide a level of abstraction in
solving problems because many seemingly complicated
problems can be distilled into simpler ones for which well-
known algorithms exist. Once we see a more complicated
problem in a simpler light, we can think of the simpler problem
as just an abstraction of the more complicated one. For
example, imagine trying to find the shortest way to route a
packet between two gateways in an internet. Once we realize
that this problem is just a variation of the more general shortest
path problem, we can solve it using the generalised approach.

 Reusability: Algorithms are often reusable in many different
situations. Since many well-known algorithms are the
generalizations of more complicated ones, and since many
complicated problems can be distilled into simpler ones, an
efficient means of solving certain simpler problems potentially
lets us solve many complicated problems.

1.3.1 Expressing Algorithms:

Algorithms can be expressed in many different notations,
including natural languages, pseudocode, flowcharts and
programming languages. Natural language expressions of algorithms
tend to be verbose and ambiguous, and are rarely used for complex or
INSTITUTE OF DISTANCE & OPEN LEARNING 3

, INTRODUCTION TO C++ UNIT 1
technical algorithms. Pseudocode and flowcharts are structured ways
to express algorithms that avoid many ambiguities common in natural
language statements, while remaining independent of a particular
implementation language. Programming languages are primarily
intended for expressing algorithms in a form that can be executed by a
computer, but are often used to define or document algorithms.

Sometimes it is helpful in the description of an algorithm to
supplement small flowcharts with natural language and/or arithmetic
expressions written inside block diagrams to summarize what the
flowcharts are accomplishing.

Consider an example for finding the largest number in an
unsorted list of numbers.

The solution for this problem requires looking at every number in the
list, but only once at each.
1) Algorithm using natural language statements:
a) Assume the first item is largest.
b) Look at each of the remaining items in the list and if it is larger
than the largest item so far, make a note of it.
c) The last noted item is the largest item in the list when the
process is complete.

2) Algorithm using pseudocode:
largest = L0
for each item in the list (Length(L) ≥ 1), do
if the item ≥ largest, then
largest = the item
return largest


1.3.2 Benefits of using Algorithms:

The use of algorithms provides a number of benefits. One of
these benefits is in the development of the procedure itself, which
involves identification of the processes, major decision points, and
variables necessary to solve the problem. Developing an algorithm
allows and even forces examination of the solution process in a
rational manner. Identification of the processes and decision points
reduces the task into a series of smaller steps of more manageable size.
Problems that would be difficult or impossible to solve in entirety can
be approached as a series of small, solvable sub-problems.

By using an algorithm, decision making becomes a more
rational process. In addition to making the process more rational, use
of algorithm will make the process more efficient and more consistent.
Efficiency is an inherent result of the analysis and specification
process. Consistency comes from both the use of the same specified
process and increased skill in applying the process. An algorithm
serves as a mnemonic device and helps ensure that variables or parts of
INSTITUTE OF DISTANCE & OPEN LEARNING 4

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller mebrahim_fahmy. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $6.39. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

76800 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$6.39
  • (0)
  Add to cart