100% found this document useful (5 votes)
107 views

Data Structures - Ebook PDF All Chapters Instant Download

PDF

Uploaded by

guetdometi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
107 views

Data Structures - Ebook PDF All Chapters Instant Download

PDF

Uploaded by

guetdometi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Download the full version of the ebook now at ebooksecure.

com

Data Structures - eBook PDF

https://ebooksecure.com/download/data-structures-
ebook-pdf/

Explore and download more ebook at https://ebooksecure.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

(eBook PDF) Starting Out with Java: From Control


Structures through Data Structures 3rd Edition

https://ebooksecure.com/product/ebook-pdf-starting-out-with-java-from-
control-structures-through-data-structures-3rd-edition/

ebooksecure.com

(eBook PDF) Starting Out with Java: From Control


Structures through Data Structures 4th Edition

https://ebooksecure.com/product/ebook-pdf-starting-out-with-java-from-
control-structures-through-data-structures-4th-edition/

ebooksecure.com

(eBook PDF) Data Structures and Abstractions with Java 4th


Edition

https://ebooksecure.com/product/ebook-pdf-data-structures-and-
abstractions-with-java-4th-edition/

ebooksecure.com

(eBook PDF) Developing the Curriculum 9th Edition by


William R. Gordon II

https://ebooksecure.com/product/ebook-pdf-developing-the-
curriculum-9th-edition-by-william-r-gordon-ii/

ebooksecure.com
(eBook PDF) International Relations, Brief Edition 7th
Edition

https://ebooksecure.com/product/ebook-pdf-international-relations-
brief-edition-7th-edition/

ebooksecure.com

(eBook PDF) Introductory Statistics Exploring the World


Through Data 2nd

https://ebooksecure.com/product/ebook-pdf-introductory-statistics-
exploring-the-world-through-data-2nd/

ebooksecure.com

Affine Arithmetic-Based Methods for Uncertain Power System


Analysis 1st edition - eBook PDF

https://ebooksecure.com/download/affine-arithmetic-based-methods-for-
uncertain-power-system-analysis-ebook-pdf/

ebooksecure.com

(eBook PDF) Finance: Applications and Theory 5th Edition


by Marcia Cornett

https://ebooksecure.com/product/ebook-pdf-finance-applications-and-
theory-5th-edition-by-marcia-cornett/

ebooksecure.com

Corporate Finance, 6th Global Edition Jonathan Berk -


eBook PDF

https://ebooksecure.com/download/corporate-finance-6th-global-edition-
ebook-pdf/

ebooksecure.com
(eBook PDF) Precalculus with Limits 4th Edition

https://ebooksecure.com/product/ebook-pdf-precalculus-with-limits-4th-
edition/

ebooksecure.com
Data Structures
About the Author
E Balagurusamy, former Vice Chancellor, Anna University, Chennai and
Member, Union Public Service Commission, New Delhi, is currently the
Chairman of EBG Foundation, Coimbatore. He is a teacher, trainer, and
consultant in the fields of Information Technology and Management. He holds
an ME (Hons) in Electrical Engineering and PhD in Systems Engineering
from the Indian Institute of Technology, Roorkee. His areas of interest include
Object-Oriented Software Engineering, E-Governance, Technology Management,
Business Process Re-engineering, and Total Quality Management.
A prolific writer, Dr Balagurusamy has authored a large number of research
papers and several books.
A recipient of numerous honors and awards, Dr Balagurusamy has been listed in the Directory of
Who’s Who of Intellectuals and in the Directory of Distinguished Leaders in Education.
Data Structures

E Balagurusamy
Chairman
EBG Foundation
Coimbatore

McGraw Hill Education (India) Private Limited


CHENNAI

McGraw Hill Education Offices


Chennai New York St Louis San Francisco Auckland Bogotá Caracas
Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal
San Juan Santiago Singapore Sydney Tokyo Toronto
McGraw Hill Education (India) Private Limited
Published by McGraw Hill Education (India) Private Limited
444/1, Sri Ekambara Naicker Industrial Estate, Alapakkam, Porur, Chennai 600 116
Data Structures

Copyright © 2019 by McGraw Hill Education (India) Private Limited.


No part of this publication may be reproduced or distributed in any form or by any means, electronic, mechanical, photocopying,
recording, or otherwise or stored in a database or retrieval system without the prior written permission of the publishers. The pro-
gram listings (if any) may be entered, stored and executed in a computer system, but they may not be reproduced for publication.
This edition can be exported from India only by the publishers,
McGraw Hill Education (India) Private Limited.
1 2 3 4 5 6 7 8 9 D103074 22 21 20 19 18
Printed and bound in India.

Print-Book Edition
ISBN (13): 978-93-5316-182-8
ISBN (10): 93-5316-182-7

E-Book Edition
ISBN (13): 978-93-5316-183-5
ISBN (10): 93-5316-183-5

Director—Science & Engineering Portfolio: Vibha Mahajan


Senior Portfolio Manager—Science & Engineering: Hemant K Jha
Associate Portfolio Manager—Science & Engineering: Tushar Mishra
Production Head: Satinder S Baveja
Copy Editor: Taranpreet Kaur
General Manager—Production: Rajender P Ghansela
Manager—Production: Reji Kumar

Information contained in this work has been obtained by McGraw Hill Education (India), from sources believed to be reliable.
However, neither McGraw Hill Education (India) nor its authors guarantee the accuracy or completeness of any information published
herein, and neither McGraw Hill Education (India) nor its authors shall be responsible for any errors, omissions, or damages arising
out of use of this information. This work is published with the understanding that McGraw Hill Education (India) and its authors are
supplying information but are not attempting to render engineering or other professional services. If such services are required, the
assistance of an appropriate professional should be sought.

Typeset at APS Compugraphics, 4G, PKT 2, Mayur Vihar Phase-III, Delhi 96, and printed at

Cover Designer: APS Compugraphics


Cover Image Source: Shutterstock
Cover Printer:

Visit us at: www.mheducation.co.in


Write to us at: info.india@mheducation.com
CIN: U22200TN1970PTC111531
Toll Free Number: 1800 103 5875
Preface
About the Book
Data Structure is the way of storing data in a computer system. It allows an application to fetch and store
data in the computer’s memory in an efficient manner. It is very important to choose the correct type
of data structure while developing a software application. C is one of the first programming languages
that students of computer science get familiar with. It is also the language of choice while facilitating
the learning of programming concepts such as data structures.
The strength of Data Structures lies in its simple and lucid presentation of the subject which will help
beginners in better understanding of the concepts. It adopts a student-friendly approach to the subject
matter with many solved and unsolved examples, illustrations and well-structured C programs.
This book will prove to be a stepping stone in understanding the data structure concepts in an efficient
and organized manner, and also for revisiting the fundamentals of data structure.

Salient Features of the Book


 In-depth coverage of all important topics like Arrays, Linked lists, Stacks, Queues, Trees, Graphs,
Sorting, and Searching
 Dedicated chapter on Real Life Applications of Data Structures
 Explains run-time complexity of all algorithms
 Multiple-Choice Questions for university exams and interviews
 Innovative chapter features includes pedagogical aids like illustrations, programs, important commands
in programs, output and program analysis, note, checkpoint, key terms, solved problems, and review
questions.

What Sets This Book Apart


Chapter Opening Features
At the opening of each chapter, the outline lists the major headings, followed by an introduction to the
chapter. This will help students organize their study priorities.
In-chapter Features
Features like algorithms, pseudocodes, flowcharts and programs emphasize on a point or help teach a
concept. Commands in bold draw students’ attention to a particular section in the program.
Other Significant Features
Notes, Tips and Checkpoints are designed to provide extra information or alternative views or results
or interesting snippets of information related to the content of the chapter.
Chapter-end Features
Summary reviews the concepts while a list of key terms helps identify the vocabulary students need to
understand the concepts presented in the chapter. Students can assess their knowledge by answering the
basic review questions, programming exercises and multiple-choice questions.
Chapter Organization
This book is organized into 8 chapters, which explain concepts like Arrays, Stacks, Queues, Linked
Lists, Trees and Graphs.
Chapter 1 introduces algorithm and its related concepts. It also provides a brief introduction to
the different types of data structures. Chapter 2 discusses one of the commonly used derived data
types, i.e., array and explains how it is used as a data structure in different programming situations.
Chapter 3 explains the concept of linked list along with its different variants. Chapters 4 and 5
elucidates the restricted data structures, stacks and queues. These data structures are of great importance
in programming situations because of the specific restrictions that they apply on insertion and deletion
of data elements. Chapters 6 and 7 explain the non-linear data structures trees and graphs and their
related operations. These chapters also explain the various algorithms that are used to traverse these
data structures. Chapter 8 introduces two of the most common computing operations, i.e., searching
and sorting. It explains various searching and sorting techniques along with their related advantages
and disadvantages.

Acknowledgements
I would like to thank the following reviewers for their suggestions in improving the script:
Dr. K. Sasi Kala Rani Hindusthan Institute of Technology, Coimbatore
Shashank Dwivedi UCER, Allahabad, Uttar Pradesh
Rajiv Pandey Amity University Lucknow Campus, Lucknow, Uttar Pradesh
Mahua Banerjee Xavier Institute of Social Service, Ranchi, Jharkhand
Sameer Bhave Indore Professional Studies Academy, Indore, Madhya Pradesh
D Lakshmi, Adithya Institute of Technology, Coimbatore, Tamil Nadu
A Sharada G Narayanamma Institute of Technology and Science, Hyderabad,
Andhra Pradesh
Sincere thanks to the editorial team of McGraw Hill Education (India) for their support and cooperation.

Publisher’s Note
Remember to write to us. We look forward to receiving your feedback, comments, and ideas to enhance
the quality of this book. You can reach us at info.india@mheducation.com. Please mention the title and
authors’ name as the subject. In case you spot piracy of this book, please do let us know.

vi Preface
Contents
Preface v
Roadmap to the Syllabus xiii

UNIT-I LINEAR DATA STRUCTURES – LIST

1. Introduction to Algorithm and Data Structures 1.1


1.1 Introduction 1.2
1.2 Algorithms 1.2
1.2.1 Characteristics of an Algorithm 1.3
1.2.2 Representation of an Algorithm 1.3
1.2.3 Efficiency of an Algorithm 1.5
1.3 Asymptotic Notation 1.6
1.3.1 Big-Oh Notation 1.6
1.3.2 Omega Notation 1.7
1.3.3 Theta Notation 1.9
1.4 Introduction to Data Structures 1.10
1.4.1 Characteristics of Data Structure 1.11
1.5 Types of Data Structures 1.11
1.5.1 Arrays 1.12
1.5.2 Linked Lists 1.12
1.5.3 Stacks 1.13
1.5.4 Queues 1.13
1.5.5 Trees 1.14
1.5.6 Graphs 1.14
1.6 Data Structure Operations 1.15
1.6.1 Data Structure Efficiency 1.15
Summary 1.15
Key Terms 1.16
Multiple-Choice Questions 1.16
Review Questions 1.17

2. Arrays 2.1
2.1 Introduction 2.2
2.2 Types of Arrays 2.2
2.3 Representation of One-Dimensional Array in Memory 2.3
2.4 Array Traversal 2.3
2.5 Insertion and Deletion 2.5
2.5.1 Insertion 2.5
2.5.2 Deletion 2.8
2.6 Sorting and Searching 2.10
2.6.1 Sorting 2.10
2.6.2 Searching 2.13
2.8 Realizing Matrices using Two-Dimensional Arrays 2.16
2.9 Matrix Operations 2.18
2.9.1 Addition 2.18
2.9.2 Subtraction 2.21
2.9.3 Multiplication 2.21
2.9.4 Transpose 2.24
Solved Problems 2.26
Summary 2.27
Key Terms 2.27
Multiple-Choice Questions 2.28
Review Questions 2.29
Programming Exercises 2.29

3. Linked Lists 3.1


3.1 Introduction 3.2
3.2 Linked Lists—Basic Concept 3.2
3.2.1 Representation of Linked Lists 3.2
3.2.2 Advantages of Linked Lists 3.3
3.2.3 Disadvantages of Linked Lists 3.3
3.3 Linked List Implementation 3.3
3.3.1 Linked List Node Declaration 3.3
3.3.2 Linked List Operations 3.4
3.3.3 Linked List Implementation 3.7
3.4 Types of Linked Lists 3.15
3.5 Circular Linked List 3.15
3.5.1 Circular Linked List Operations 3.16
3.5.2 Circular Linked List Implementation 3.17
3.6 Doubly Linked List 3.24
3.6.1 Doubly Linked List Node Declaration 3.25
3.6.2 Doubly Linked List Operations 3.25
3.6.3 Doubly Linked List Implementation 3.27
Solved Problems 3.32
Summary 3.33
Key Terms 3.33

viii Contents
Multiple-Choice Questions 3.34
Review Questions 3.35
Programming Exercises 3.35

UNIT-II LINEAR DATA STRUCTURES – STACKS, QUEUES

4. Stacks 4.1
4.1 Introduction 4.2
4.2 Stacks 4.2
4.2.1 Stack Representation in Memory 4.2
4.2.2 Arrays vs. Stacks 4.3
4.3 Stack Operations 4.3
4.3.1 Push 4.4
4.3.2 Pop 4.4
4.3.3 An Example of Stack Operations 4.5
4.4 Stack Implementation 4.5
4.4.1 Array Implementation of Stacks 4.5
4.4.2 Linked Implementation of Stacks 4.11
Solved Problems 4.16
Summary 4.19
Key Terms 4.19
Multiple-Choice Questions 4.20
Review Questions 4.21
Programming Exercises 4.22

5. Queues 5.1
5.1 Introduction 5.2
5.2 Queues—Basic Concept 5.2
5.2.1 Logical Representation of Queues 5.3
5.3 Queue Operations 5.4
5.4 Queue Implementation 5.6
5.4.1 Array Implementation of Queues 5.6
5.4.2 Linked Implementation of Queues 5.12
5.5 Circular Queues 5.17
5.6 Priority Queues 5.25
5.7 Double-Ended Queues 5.31
Solved Problems 5.34
Summary 5.37
Key Terms 5.37

Contents ix
Multiple-Choice Questions 5.38
Review Questions 5.39
Programming Exercises 5.39

UNIT-III NON LINEAR DATA STRUCTURES – TREES

6. Trees 6.1
6.1 Introduction 6.2
6.2 Basic Concept 6.2
6.2.1 Tree Terminology 6.2
6.3 Binary Tree 6.3
6.3.1 Binary Tree Concepts 6.4
6.4 Binary Tree Representation 6.5
6.4.1 Array Representation 6.5
6.4.2 Linked Representation 6.6
6.5 Binary Tree traversal 6.10
6.6 Binary Search Tree 6.17
6.7 Tree Variants 6.24
6.7.1 Expression Trees 6.25
6.7.2 Threaded Binary Trees 6.26
6.7.3 Balanced Trees 6.27
6.7.4 Splay Trees 6.30
6.7.5 m-way Trees 6.31
Summary 6.33
Multiple-Choice Questions 6.34
Key Terms 6.34
Review Questions 6.35
Programming Exercises 6.35

UNIT-IV NON LINEAR DATA STRUCTURES – GRAPHS

7. Graphs 7.1
7.1 Introduction 7.2
7.2 Basic Concept 7.2
7.3 Graph Terminology 7.3
7.4 Graph Implementation 7.4
7.4.1 Implementing Graphs using Adjacency Matrix 7.4
7.4.2 Implementing Graphs using Path Matrix 7.6
7.4.3 Implementing Graphs using Adjacency List 7.8

x Contents
Visit https://testbankfan.com
now to explore a rich
collection of testbank or
solution manual and enjoy
exciting offers!
7.5 Shortest Path Algorithm 7.11
7.6 Graph Traversal 7.15
7.6.1 Breadth First Search 7.15
7.6.2 Depth First Search 7.16
Summary 7.17
Key Terms 7.17
Multiple-Choice Questions 7.17
Review Questions 7.18
Programming Exercises 7.18

UNIT-V SEARCHING, SORTING AND HASHING TECHNIQUES

8. Sorting and Searching 8.1


8.1 Introduction 8.2
8.2 Sorting Techniques 8.2
8.2.1 Selection Sort 8.3
8.2.2 Insertion Sort 8.7
8.2.3 Bubble Sort 8.10
8.2.4 Quick Sort 8.14
8.2.5 Merge Sort 8.19
8.2.6 Bucket Sort 8.23
8.3 Searching Techniques 8.28
8.3.1 Linear Search 8.28
8.3.2 Binary Search 8.31
8.3.3 Hashing 8.34
Solved Problems 8.37
Summary 8.38
Key Terms 8.39
Multiple-Choice Questions 8.39
Review Questions 8.40
Programming Exercises 8.40

Contents xi
Roadmap to the Syllabus
Data Structures
Semester III

Unit-I: LINEAR DATA STRUCTURES – LIST


Abstract Data Types (ADTs) – List ADT – array-based implementation – linked list implementation
––singly linked lists- circularly linked lists- doubly-linked lists – applications of lists –Polynomial
Manipulation – All operations (Insertion, Deletion, Merge, Traversal)

Chapter 1: Introduction to Algorithm and Data Structures


GO TO Chapter 2: Arrays
Chapter 3: Linked Lists

Unit-II: LINEAR DATA STRUCTURES – STACKS, QUEUES


Stack ADT – Operations - Applications - Evaluating arithmetic expressions- Conversion of Infix to
postfix expression - Queue ADT – Operations - Circular Queue – Priority Queue - deQueue – appli-
cations of queues

Chapter 4: Stacks
GO TO
Chapter 5: Queues

Unit-III: NON LINEAR DATA STRUCTURES – TREES


Tree ADT – tree traversals - Binary Tree ADT – expression trees – applications of trees – binary
search tree ADT –Threaded Binary Trees- AVL Trees – B-Tree - B+ Tree - Heap – Applications of
heap.

GO TO Chapter 6: Trees
Unit-IV: NON LINEAR DATA STRUCTURES – GRAPHS
Definition – Representation of Graph – Types of graph – Breadth-first traversal – Depth-first
traversal – Topological Sort – Bi-connectivity – Cut vertex – Euler circuits – Applications of graphs.

GO TO Chapter 7: Graphs

Unit-V: SEARCHING, SORTING AND HASHING TECHNIQUES


Searching- Linear Search – Binary Search. Sorting – Bubble sort – Selection sort – Insertion sort
– Shell sort – Radix sort. Hashing – Hash Functions – Separate Chaining – Open Addressing –
Rehashing – Extendible Hashing

GO TO Chapter 8: Sorting and Searching

xiv Roadmap to the Syllabus


UNIT-I
Linear Data Structures – List

CHAPTERS

Chapter 1: Introduction to Algorithm and Data Structures


Chapter 2: Arrays
Chapter 3: Linked Lists
Exploring the Variety of Random
Documents with Different Content
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like