DATA STRUCTURES
AND
PROGRAM DESIGN
USING PYTHONLICENSE, 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. DATA STRUCTURES
AND
PROGRAM DESIGN
USING PYTHONA Self-Teaching IntroductionDheeraj Malhotra, PhD
Neha Malhotra, PhDMERCURY LEARNING AND INFORMATION
Dulles, Virginia
Boston, Massachusetts
New Delhi Copyright 2021 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 Python.
ISBN: 978-1-68392-639-9 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: 2020946121 202122321Printed 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.academiccourseware.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 studentsCONTENTSPREFACEData structures are the building blocks of computer science. The objective of this text is to emphasize the fundamentals of data structures as an introductory subject. It is designed for beginners who would like to learn the basics of data structures and their implementation using the Python 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 the reader in quickly identifying appropriate data structures to solve specific, practical problems.
This book will serve the purpose of a text or 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 quickly 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 identify the most appropriate and efficient data structure for solving a specific, real-world problem.Frequently Asked Questions: Frequently asked theoretical or 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 their implementation in Python, syntax independent algorithms, as well as implemented programs in Python, 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 fields, several exercises are suitably chosen and are given in an MCQ format.Dr. Dheeraj Malhotra
Dr. Neha Malhotra
September 2020ACKNOWLEDGMENTSWe are indeed grateful to Chairman - Dr. S.C.
Vats, Vice Chairman - Mr. Suneet Vats, Chairperson VSIT - Prof. Sidharth Mishra, and Dean VSIT- Prof. Supriya Madan of our employer institute - 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 our mentors Prof. O.P.
Rishi (University of Kota), Dr. Sushil Chandra (DRDO, GOI), Prof. Udyan Ghose (GGS IP University), and Prof. M.N. Hoda (BVICAM) for their motivation to execute this project.
Next page