An Elementary Approach to Design and Analysis of Algorithms
eBook - ePub

An Elementary Approach to Design and Analysis of Algorithms

Lekh Raj Vermani, Shalini Vermani

Share book
  1. 536 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

An Elementary Approach to Design and Analysis of Algorithms

Lekh Raj Vermani, Shalini Vermani

Book details
Book preview
Table of contents
Citations

About This Book

In computer science, an algorithm is an unambiguous specification of how to solve a class of problems. Algorithms can perform calculation, data processing and automated reasoning tasks.

As an effective method, an algorithm can be expressed within a finite amount of space and time and in a well-defined formal language for calculating a function. Starting from an initial state and initial input (perhaps empty), the instructions describe a computation that, when executed, proceeds through a finite number of well-defined successive states, eventually producing 'output' and terminating at a final ending state. The transition from one state to the next is not necessarily deterministic; some algorithms, known as randomized algorithms, incorporate random input.

This book introduces a set of concepts in solving problems computationally such as Growth of Functions; Backtracking; Divide and Conquer; Greedy Algorithms; Dynamic Programming; Elementary Graph Algorithms; Minimal Spanning Tree; Single-Source Shortest Paths; All Pairs Shortest Paths; Flow Networks; Polynomial Multiplication, to ways of solving NP-Complete Problems, supported with comprehensive, and detailed problems and solutions, making it an ideal resource to those studying computer science, computer engineering and information technology.

Contents:

  • Preface
  • About the Authors
  • Algorithms
  • Growth of Functions
  • Backtracking
  • Divide and Conquer
  • Greedy Algorithms
  • Dynamic Programming
  • Elementary Graph Algorithms
  • Minimal Spanning Tree
  • Single-Source Shortest Paths
  • All Pairs Shortest Paths
  • Flow Networks
  • Polynomial Multiplication, FFT and DFT
  • String Matching
  • Sorting Networks
  • NP-Complete Problems
  • Bibliography
  • Index


Readership: Students studying for degrees in computer science, computer engineering and information technology.Algorithms;Computer Science;Computer Engineering;Information Technology00

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is An Elementary Approach to Design and Analysis of Algorithms an online PDF/ePUB?
Yes, you can access An Elementary Approach to Design and Analysis of Algorithms by Lekh Raj Vermani, Shalini Vermani in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Algorithms. We have over one million books available in our catalogue for you to explore.

Information

Publisher
WSPC (EUROPE)
Year
2019
ISBN
9781786346773

Chapter 1

Algorithms

In the subject of computer science the word algorithm, in general, refers to a method that can be used by a computer for the solution of a problem. As such the word algorithm does not simply mean a process, technique or method. Strictly speaking, it is a finite collection of well-defined computational techniques each of which is clear and unambiguous, capable of being performed with finite effort and terminates in a finite amount of time. Before an algorithm comes to play, a problem to be solved on computer is first converted into a mathematical problem called mathematical model. An algorithm is different from a program (computer program). Although algorithm is an easily understood procedure giving a set of logical instructions for solving the problem at hand, a program is written in a computer language giving the instructions that the computer understands.

1.1.Some Sorting Algorithms

We begin our study of algorithms by considering some sorting algorithms. Here we are given a sequence of non-negative integers a1, a2, . . . , an, not necessarily all distinct, the aim is to obtain a permutation of the a’s to get the numbers in a non-decreasing (or non-increasing) order i.e., to obtain a sequence a1′, a2′, . . . , an with {a1′, a2′, . . . , an} = {a1, a2, . . . , an} and a1′a2′
image
an. We restrict ourselves to obtaining a non-decreasing sequence.

1.1.1.Bubble sort

Among the sorting algorithms, this is most perhaps the easiest. In this algorithm an is first compared with an–1 and if an < an–1, an and an–1 are interchanged. Then an is compared with an–2 and if an < an–2, an and an–2 are interchanged and the process stops when we come to an ai such that ai < an. The process is then followed with an–1, then an–2 etc.
Algorithm 1.1. Bubble Sort Algorithm
1.For i = 1 to n − 1, do
2.forj = n to i + 1
3.if aj < aj–1, then
4.interchange (swap) ajaj–1
We will better explain this algorithm through two examples: one a sequence with all terms distinct and the other when all the terms are not necessarily distinct. We may not restrict ourselves to sequences of numbers alone but may consider sequences over any ordered set.
Example 1.1. Using bubble sort, rearrange the sequence
image
in alphabetical order.
Solution. This is a sequence of six terms all distinct. So i takes the values from 1 to 5. We express the sequence as a column denoting each word by the first letter of the word. We shall fully describe the internal loops for every i (refer to Table 1.1).
Observe that in the case i = 1, there is no change for j = 5, in the case of i = 2, there is no change for j = 6, 5, 4 and for i = 3, there is no change for j = 6, 5. At this stage the sequence is already sorted and, so, for i = 4 and 5, no changes are required. Hence the final sorted sequence is A, E, K, P, S, V or
image
Example 1.2. Using bubble sort, rearrange the sequence 2, 3, 6, 1, 0, 4, 8, 0 in non-decreasing order.
Table 1.1
image
Table 1.2(a)
image
Table 1.2(b)
image
Solution. This is a sequence of eight terms. So i takes values from 1 to 7. We express the sequence as a column and fully describe the internal loops for every i (as given in Tables 1.2(a) and 1.2(b)).
Observe that the array obtained in the last column of Table 1.2(b) is already sorted and, so, no changes are needed for i = 5, 6, 7. Also on the way, no changes were needed for i =...

Table of contents