D ATA S TRUCTURES AND P ROGRAM D ESIGN U SING C
LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED WARRANTY
By purchasing or using this book and disc (the Work), you agree that this license grants permission to use the contents contained herein, including the disc, but does not give you the right of ownership to any of the textual content in the book / disc or ownership to any of the information or products contained in it. This license does not permit uploading of the Work onto the Internet or on a network (of any kind) without the written consent of the Publisher. Duplication or dissemination of any text, code, simulations, images, etc. contained herein is limited to and subject to licensing terms for the respective products, and permission must be obtained from the Publisher or the owner of the content, etc., in order to reproduce or network any portion of the textual material (in any media) that is contained in the Work.
MERCURY LEARNING AND INFORMATION (MLI or the Publisher) and anyone involved in the creation, writing, or production of the companion disc, accompanying algorithms, code, or computer programs (the software), and any accompanying Web site or software of the Work, cannot and do not warrant the performance or results that might be obtained by using the contents of the Work. The author, developers, and the Publisher have used their best efforts to insure the accuracy and functionality of the textual material and/or programs contained in this package; we, however, make no warranty of any kind, express or implied, regarding the performance of these contents or programs. The Work is sold as is without warranty (except for defective materials used in manufacturing the book or due to faulty workmanship).
The author, developers, and the publisher of any accompanying content, and anyone involved in the composition, production, and manufacturing of this work will not be liable for damages of any kind arising out of the use of (or the inability to use) the algorithms, source code, computer programs, or textual material contained in this publication. This includes, but is not limited to, loss of revenue or profit, or other incidental, physical, or consequential damages arising out of the use of this Work.
The sole remedy in the event of a claim of any kind is expressly limited to replacement of the book and/or disc, and only at the discretion of the Publisher. The use of implied warranty and certain exclusions vary from state to state, and might not apply to the purchaser of this product.
D ATA S TRUCTURES AND P ROGRAM D ESIGN U SING C
A Self-Teaching Introduction
Dheeraj Malhotra
Neha Malhotra
M ERCURY L EARNING AND I NFORMATION
Dulles, Virginia
Boston, Massachusetts
New Delhi
Copyright 2019 by MERCURY LEARNING AND INFORMATION LLC.
All rights reserved.
This publication, portions of it, or any accompanying software may not be reproduced in any way, stored in a retrieval system of any type, or transmitted by any means, media, electronic display or mechanical display, including, but not limited to, photocopy, recording, Internet postings, or scanning, without prior permission in writing from the publisher.
Publisher: David Pallai
MERCURY LEARNING AND INFORMATION
22841 Quicksilver Drive
Dulles, VA 20166
www.merclearning.com
(800) 232-0223
D. Malhotra and N. Malhotra. Data Structures and Program Design Using C.
ISBN: 9781683922070
The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products. All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks, etc. is not an attempt to infringe on the property of others.
Library of Congress Control Number: 2018938986
181920321 Printed on acid-free paper in the United States of America.
Our titles are available for adoption, license, or bulk purchase by institutions, corporations, etc. For additional information, please contact the Customer Service Dept. at (800) 232-0223(toll free). Digital versions of our titles are available at: www.authorcloudware.com and other electronic vendors.
The sole obligation of MERCURY LEARNING AND INFORMATION to the purchaser is to replace the book and/or disc, based on defective materials or faulty workmanship, but not based on the operation or functionality of the product.
Dedicated to our
loving parents and beloved students.
CONTENTS
PREFACE
Data structures are the building blocks of computer science. The objective of this text is to emphasize fundamentals of data structures as an introductory subject. It is designed for beginners (students or professionals) who would like to learn the basics of data structures and their implementation using the C programming language. With this focus in mind, we present various fundamentals of the subject, well supported with real world analogies to enable a quick understanding of the technical concepts and to help in identifying appropriate data structures to solve specific, practical problems. This book will serve the purpose of a text / reference book and will be of immense help especially to undergraduate or graduate students of various courses in information technology, engineering, computer applications, and information sciences.
Key Features:
Practical Applications: Real world analogies as practical applications are given throughout the text to easily understand and connect the fundamentals of data structures with day to day, real-world scenarios. This approach, in turn, will assist the reader in developing the capability to easily identify the most appropriate and efficient data structure for solving a specific problem.
Frequently Asked Questions: Frequently asked theoretical/practical questions are integrated throughout the content of the book, within related topics to assist readers in grasping the subject.
Algorithms and Programs: To better understand the fundamentals of data structures at a generic level-followed by its specific implementation in C, syntax independent algorithms as well as implemented programs in C are discussed throughout the book. This presentation will assist the reader in getting both algorithms and their corresponding implementation within a single book.
Numerical and Conceptual Exercises: To assist the reader in developing a strong foundation of the subject, various numerical and conceptual problems are included throughout the text.
Multiple Choice Questions: To assist students for placement-oriented exams in various IT areas, several exercises are suitably chosen and are given in an MCQ format.
Dheeraj Malhotra
Neha Malhotra
May 2018
ACKNOWLEDGMENTS
It is our pleasure to take this opportunity to sincerely thank the people who have extended their kind help and support to us throughout this project.
We are indeed grateful to Dr. SC Vats, Dr. Rattan Sharma, Dr. Vinay Kumar and other staff members of Vivekananda Institute of Professional Studies (GGS IP University). They are always a source of inspiration for us, and we feel honored because of their faith in us.
We also take this opportunity to extend our gratitude to Dr. OP Rishi, Dr. Jatinder Singh, Dr. Udyan Ghose, Dr. Nitin Malik, Dr. A.D. Lamba for their motivation to execute this project.
We are profoundly thankful to Mr. Deepanshu Gupta for helping us in proofreading and compiling the codes in this manuscript.
Next page