×
WISH LESS WORK MORE.
--Your friends at LectureNotes
Close

Note for Data Structure using C - DS By Amit pandey

  • Data Structure using C - DS
  • Note
  • 17 Topics
  • 315 Views
  • 3 Offline Downloads
  • Uploaded 1 year ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-2

BRIEF CONTENTS Preface iv Acknowledgements Features of the Book vii viii 1. Fundamental Concepts 1 2. Linear Data Structure Using Arrays 32 3. Stacks 94 4. Recursion 147 5. Queues 168 6. Linked Lists 195 7. Trees 280 8. Graphs 372 9. Searching and Sorting 420 10. Search Trees 479 11. Hashing 527 12. Heaps 556 13. Indexing and Multiway Trees 589 14. Files 638 15. Standard Template Library 677 16. Algorithm Analysis and Design 714 Appendix: Overview of C++ Programming Index 759 797 www.allitebooks.com

Text from page-3

DETAILED CONTENTS Preface iv Acknowledgements vii Features of the Book viii 1. Fundamental Concepts 1.1 1.2 1.3 Introduction to Programming 1 Object-oriented Programming 3 Introduction to Data Structures 3 1.3.1 Data 4 1.3.2 Data type 4 1.3.3 Data object 5 1.3.4 Data structure 5 1.3.5 Abstract data type 6 Types of Data Structures 9 1.4.1 Primitive and non-primitive data structures 9 1.4.2 Linear and non-linear data structures 9 1.4.3 Static and dynamic data structures 10 1.4.4 Persistent and ephemeral data structures 10 1.4.5 Sequential access and direct access data structures 11 Introduction to Algorithms 11 1.5.1 Characteristics of algorithms 12 1.5.2 Algorithmics 13 1.5.3 Algorithm design tools: Pseudocode and flowchart 13 Pseudocode 14 1.6.1 Pseudocode notations 14 1.6.2 Algorithm header 14 1.6.3 Purpose 15 1.6.4 Condition and return statements 15 1.6.5 Statement numbers 16 1.6.6 Variables 16 1.6.7 Statement constructs 17 1.6.8 Subalgorithms 18 Relationship among data, data structures, and algorithms 20 1.4 1.5 1.6 1.7 1 1.8 Implementation of data structures 1.9 Flowcharts 1.10 Analysis of Algorithms 1.10.1 Complexity of algorithms 1.10.2 Space complexity 1.10.3 Time complexity 1.10.4 Computing time complexity of an algorithm 1.10.5 Big-O notation 1.11 From Problem to Program 1.12 Software Engineering 1.12.1 Analysis phase 1.12.2 Design phase 1.12.3 Implementation phase 1.12.4 Testing phase 1.12.5 Verification phase 2. 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 Linear Data Structure Using Arrays Sequential Organization Linear Data Structure Using Sequential Organization: Arrays Array as an Abstract Data Type Memory Representation and Address Calculation Class Array 2.5.1 Inserting an element into an array 2.5.2 Deleting an element Arrays Using Template Multidimensional Arrays 2.7.1 Two-dimensional arrays 2.7.2 n-dimensional arrays Concept of Ordered List Single Variable Polynomial www.allitebooks.com 21 22 22 22 23 24 24 25 26 27 27 28 28 29 29 33 33 34 36 38 40 42 44 46 47 47 52 57 58

Text from page-4

xii  Detailed Contents 2.9.1  Representation using arrays 2.9.2 Polynomial as array of structure 2.9.3  Polynomial evaluation 2.9.4  Polynomial addition 2.9.5  Polynomial multiplication 2.10 Array for Frequency Count 2.11 Sparse Matrix 2.11.1  Sparse matrix representation 2.11.2  Sparse matrix addition 2.11.3  Transpose of sparse matrix 2.12 String Manipulation Using Array 2.13 Pros and Cons of Arrays 2.13.1  Characteristics 2.13.2  Advantages 2.13.3  Disadvantages 2.13.4  Applications of arrays 58 60 61 62 66 69 70 72 73 77 84 89 89 89 90 90 3. Stacks 94 4.6 3.1 Concept of Stacks and Queues 3.2 Stacks 3.2.1  Primitive operations 3.3 Stack Abstract Data Type 3.4 Representation of Stacks Using Sequential Organization (Arrays) 3.4.1  Create 3.4.2  Empty 3.4.3  GetTop 3.4.4  Push 3.4.5  Pop 3.5 Stacks Using Template 3.6 Multiple Stacks 3.7 Applications of Stack 3.8 Expression Evaluation and Conversion 3.8.1 Polish notation and expression conversion 3.8.2 Need for prefix and postfix expressions 3.8.3  Postfix expression evaluation 3.9 Processing of Function Calls 3.10 Reversing a String with a Stack 3.11 Checking Correctness of Well-formed Parentheses 94 95 96 99 100 102 102 102 103 103 105 107 110 110 112 113 113 137 138 140 3.12 Recursion 3.13 Parsing Computer Programs 3.14 Backtracking Algorithms 3.15 Converting Decimal Numbers to Binary 140 142 142 4. Recursion 147 4.1 4.2 4.3 4.4 147 150 151 152 153 153 154 155 155 156 157 159 4.5 4.7 4.8 4.9 Introduction Recurrence Use of Stack in Recursion Variants of Recursion 4.4.1  Direct recursion 4.4.2  Indirect recursion 4.4.3  Tail recursion 4.4.4  Linear recursion 4.4.5  Tree recursion Execution of Recursive Calls Recursive Functions 4.6.1  Writing recursive code 4.6.2 Tower of Hanoi: An example of recursion 4.6.3  Checking for correctness 4.6.4  Things to remember Iteration Versus Recursion 4.7.1 Demerits of recursive algorithms 4.7.2  Demerits of iterative methods Simulating Recursion Using Stack (Eliminating Recursion) Applications of Recursion 142 159 161 162 162 162 163 163 164 5. Queues 168 5.1 5.2 5.3 5.4 168 169 170 176 Concept of Queues Queue as Abstract Data Type Realization of Queues Using Arrays Circular Queue 5.4.1 Advantages of using circular queues 5.5 Multi-queues 5.6 Deque 5.7 Priority Queue 5.7.1 Array implementation of priority queue www.allitebooks.com 180 180 181 182 185

Text from page-5

Detailed Contents  5.8 Applications of Queues 5.8.1  Josephus problem 5.8.2  Job scheduling 5.8.3  Simulation 5.9 Queues Using Template 185 186 187 188 189 6. Linked Lists 195 6.1 Introduction 6.2 Linked List 6.2.1 Comparison of sequential and linked organizations 6.2.2  Linked list terminology 6.2.3  Primitive operations 6.3 Realization of Linked Lists 6.3.1 Realization of linked list using arrays 6.3.2 Linked list using dynamic memory management 6.4 Dynamic Memory Management 6.4.1 Dynamic memory management in C++ with new and delete operators 6.5 Linked List Abstract Data Type 6.5.1  Data structure of node 6.5.2  Insertion of a node 6.5.3  Linked list traversal 6.5.4  Deletion of a node 6.6 Linked List Variants 6.6.1  Head pointer and header node 6.6.2  Types of linked list 6.6.3 Linear and circular linked lists 6.7 Doubly Linked List 6.7.1  Creation of doubly linked list 6.7.2 Deletion of a node from a doubly linked list  6.7.3 Insertion of a node in a doubly linked list  6.7.4  Traversal of DLL 6.8 Circular Linked List 6.8.1  Singly circular linked list  6.8.2 Circular linked list with header node 195 196 199 200 201 201 202 203 204 205 207 209 212 218 221 224 224 225 226 227 228 231 234 236 237 238 239 xiii 6.8.3  Doubly circular linked list 6.9 Polynomial Manipulations 6.9.1  Polynomial evaluation 6.9.2  Polynomial addition 6.9.3 Polynomial multiplication 6.10 Representation of Sparse Matrix Using Linked List 6.11 Linked Stack 6.11.1  Class for linked stack 6.11.2  Operations on linked stack 6.12 Linked Queue 6.12.1  Erasing a linked queue 6.13 Generalized Linked List 6.13.1  Definition 6.13.2  Applications 6.13.3 Representation of polynomials using generalized linked list  6.13.4 Representation of sets using generalized linked list  6.14 More on Linked Lists 6.14.1  Copying a linked list 16.4.2 Computing the length of a linked list 6.14.3 Reversing singly linked list without temporary storage 6.14.4  Concatenating two linked lists 6.14.5 Erasing the linked list 6.15 Application of Linked List—Garbage Collection  240 241 243 244 247 7. Trees 280 7.1 Introduction 7.1.1  Basic terminology 7.1.2  General tree 7.1.3  Representation of a general tree 7.2 Types of Trees 7.3 Binary Tree 7.3.1  Properties of a binary tree 7.4 Binary Tree Abstract Data Type 7.5 Realization of a Binary Tree 7.5.1 Array implementation of binary trees 280 281 285 289 290 292 293 296 298 www.allitebooks.com 250 251 252 253 256 259 260 260 262 265 269 272 272 272 273 274 274 275 298

Lecture Notes