You are on page 1of 397
DATA STRUCTURES mE) ALGORITHMS ns Peete and Mien Lot ae saa a eae IN| Tata McGraw-Hill Published by the Tata McGraw-Hill Publishing Company Limited, 7 West Patel Nagar, New Delhi 110 008. Copyright © 2008, by Tata McGraw-Hill Publishing Company 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 program 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, Tata McGraw-Hill Publishing Company Limited Second reprint 2008 RCLCRDRXRCBLX ISBN (13): 978-0-07-066726-6 ISBN (10): 0-07-066726-8 Managing Director: Ajay Shukla General Manager: Publishing—SEM & Tech Ed: Vibha Mahajan Asst. Sponsoring Editor: Shalini Jha Editorial Executive: Nilanjan Chakravarty Executive—Editorial Services: Sohini Mukherjee Senior Proof Reader: Suneeia $ Bohra General Manager: Marketing—Higher Education & School: Michael J Cruz Product Manager: SEM & Tech Ed: Bijw Ganesan Controller—Production: Rajender P Ghansela Asst. General Manager—Production: B L Dogra Information contained in this work has been obtained by Tata McGraw-Hill, from sources believed to be reliable, However, neither Tata McGraw-Hill nor its authors guarantee the accuracy or completeness of any information published herein, and neither Tata McGraw-Hill 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 Tata McGraw-Hill and its authors are supplying information but are not attempting to render engineering or other professional services. Ifsuch services are required, the assistance of an appropriate professional should be sought. ‘Typeset at The Composers, 260, C.A. Apt., Paschim Vihar, New Delhi 110 053 and printed at Pashupati Printers, 429/16, Gali No. 1, Friends Colony, Industrial Area, GT Road, Shahdara, Delhi 110 095 Cover Printer: Rashtriya Printers Beers Ons CONTENTS More the Reviewers Preface 1L_Introduction 1.1 History of Algorithms 2 1.2 Definition, Structure and Properties of Algorithms _3 1.3 Development of an Algorithm 4 14 Data Structures and Algorithms 4 Summary 7 2._ Analysis of Algorithms 21 Efficiency of Algorithms 8 2.2 Apriori Analysis 9 2.3 Asymptotic Notations 11 24 Time Complexity of an Algorithm Using O Notation 12 25 Polynomial Vs Exponential Algorithms 12 2.6 Average, Best and Worst Case Complexities_13 2.7 Analyzing Recursive Programs 15 Summary 19 Review Questions 25 3._Arrays 3.1__Introduction 26 3.2__Array Operations 27 3.3 Number of Elements in an Array 27 3.4__Representation of Arrays in Memory 28 3.5__ Applications 32 Summary 34 Ilustrative Problems 35 Review Questions 37 Programming Assignments 37 a RR 26

You might also like