Chapter 12 introduces graphs and discusses graph algorithms such as shortest path, minimum spanning tree, topological sorting, and how to find Euler circuits in a graph. Chapter 13 continues with the discussion of STL started in Chapter 4. In particular, it introduces the STL associative containers and algorithms. Appendix E discusses some of the most widely used library routines. Appendix F contains the detailed analysis of the insertion sort and quicksort algorithms.
Appendix G has two objectives. Appendix I gives the answers to odd-numbered exercises in the text. To do so, the book discusses data structures such as linked lists, stacks, queues, and binary trees. However, our emphasis is to teach you how to develop your own code. At the same time, we also want you to learn how to use professionally written code.
Chapter 4 of this book introduces STL. In the subsequent chapters, after explaining how to develop your own code, we also illustrate how to use the existing STL code. The book can, therefore, be used in various ways. If you are not interested in STL, say in the first reading, then you can skip Chapter 4 and in the subsequent chapters, whenever we discuss a particular STL component, you can skip that section. Chapter 6 discusses recursion. However, Chapter 6 is not a prerequisite for Chapters 7 and 8.
Even though Chapter 6 is not required to study Chapter 9, ideally, Chapters 9 and 10 should be studied in sequence. Therefore, we recommend that you should study Chapter 6 before Chapter 9. The following diagram illustrates the dependency of chapters.
From beginning to end, the concepts are introduced at an appropriate pace. The presentation enables students to learn the material in comfort and with confidence. The writing style of this book is simple and straightforward. It parallels the teaching style of a classroom. Visual diagrams, both extensive and exhaustive, illustrate difficult concepts.
The book contains over figures. Programming Examples are programs featured at the end of each chapter. Moreover, the problems in these programming examples are solved and programmed using OOD. Exercises further reinforce learning and ensure that students have, in fact, learned the material. Before introducing a key concept, we explain why certain elements are necessary.
The concepts introduced are then explained using examples and small programs. Each chapter contains two types of programs. First, small programs called out as numbered Examples are used to explain key concepts. Each line of the programming code in these examples is numbered. The program, illustrated through a sample run, is then explained lineby-line. The rationale behind each line is discussed in detail. As mentioned above, the book also features numerous case studies called Programming Examples.
These Programming Examples form the backbone of the book. Quick Review sections at the end of each chapter reinforce learning. After reading the chapter, readers can quickly walk through the highlights of the chapter and then test themselves using the ensuing Exercises. Many readers refer to the Quick Review as a way to quickly review the chapter before an exam. All source code and solutions have been written, compiled, and quality assurance tested.
All of the teaching tools available with this book are provided to the instructor on a single CD-ROM. ExamView includes hundreds of questions that correspond to the topics covered in this text, enabling students to generate detailed study guides that include page references for further review.
These computer-based and Internet testing components allow students to take exams at their computers, and save the instructor time because each exam is graded automatically.
These are included as a teaching aid either to make available to students on the network for chapter review, or to be used during classroom presentations.
Instructors can modify slides or add their own slides to tailor their presentations. For more information on how to bring distance learning to your course, contact your local Cengage Learning sales representative.
If an input file is needed to run a program, it is included with the source code. Solution Files The solution files for all programming exercises are available at www. If an input file is needed to run a programming exercise, it is included with the solution file. The reviewers will recognize that their criticisms have not been overlooked, adding meaningfully to the quality of the finished book.
Next, I express thanks to Amy Jollymore, Acquisitions Editor, for recognizing the importance and uniqueness of this project. All this would not have been possible without the careful planning of Product Manager Alyssa Pratt. I also thank Tintu Thomas of Integra Software Services for assisting us in keeping the project on schedule.
I would like to thank Chris Scriver and Serge Palladino of QA department of Cengage Learning for patiently and carefully proofreading the text, testing the code, and discovering typos and errors. I am thankful to my parents, to whom this book is dedicated, for their blessings. Finally, I would like to thank my wife Sadhana and my daughter Shelly. They cheered me up whenever I was overwhelmed during the writing of this book.
I welcome any comments concerning the text. Comments may be forwarded to the following e-mail address: [email protected] D. Learn about software engineering principles. Discover what an algorithm is and explore problem-solving techniques. Become aware of structured design and object-oriented design programming methodologies. Learn about classes.
Become aware of private, protected, and public members of a class. Explore how classes are implemented. Examine constructors and destructors. Become aware of abstract data type ADT. Software are computer programs designed to accomplish a specific task. This book, for example, was created with the help of a word processor. Students no longer type their papers on typewriters or write them by hand.
Instead, they use word processing software to complete their term papers. Many people maintain and balance their checkbooks on computers. Powerful, yet easy-to-use software has drastically changed the way we live and communicate.
Terms such as the Internet, which was unfamiliar just a decade ago, are very common today. With the help of computers and the software running on them, you can send letters to, and receive letters from, loved ones within seconds. You can watch how stocks perform in real time, and instantly buy and sell them.
Without software a computer is of no use. It is the software that enables you to do things that were, perhaps, fiction a few years ago. However, software is not created overnight. From the time a software program is conceived until it is delivered, it goes through several phases. There is a branch of computer science, called software engineering, which specializes in this area. Most colleges and universities offer a course in software engineering.
This book is not concerned with the teaching of software engineering principles. However, this chapter briefly describes some of the basic software engineering principles that can simplify program design. Software Life Cycle A program goes through many phases from the time it is first conceived until the time it is retired, called the life cycle of the program.
The three fundamental stages through which a program goes are development, use, and maintenance. Usually a program is initially conceived by a software developer because a customer has some problem that needs to be solved and the customer is willing to pay money to have it solved.
The new program is created in the software development stage. The next section describes this stage in some detail. Once the program is considered complete, it is released for the user to use.
Once users start using the program, they most certainly discover problems or have suggestions to improve it. When a program is considered too expensive to maintain, the developer might decide to retire the program and no new version of the program will be released. Software Development Phase 3 The software development phase is the first and perhaps most important phase of the software life cycle.
A program that is well developed will be easy and less expensive to maintain. The next section describes this phase. Analysis Analyzing the problem is the first and most important step. Understand the problem requirements. Requirements can include whether the program requires interaction with the user, whether it manipulates data, whether it produces output, and what the output looks like. Suppose that you need to develop a program to make an automated teller machine ATM operational.
In the analysis phase, you determine the functionality of the machine. Here, you determine the necessary operations performed by the machine, such as withdraw money, deposit money, transfer money, check account balance, and so on. During this phase, you also talk to potential customers who would use the machine.
To make it user-friendly, you must understand their requirements and add any necessary operations. If the program manipulates data, the programmer must know what the data is and how it is represented. That is, you need to look at sample data.
If the program produces output, you should know how the results should be generated and formatted. Design After you carefully analyze the problem, the next step is to design an algorithm to solve the problem.
If you broke the problem into subproblems, you need to design an algorithm for each subproblem. The structured design approach is also known as top-down design, stepwise refinement, and modular programming.
In structured design, the problem is divided into smaller problems. Each subproblem is then analyzed, and a solution is obtained to solve the subproblem. The solutions of all the subproblems are then combined to solve the overall problem.
This process of implementing a structured design is called structured programming. For example, suppose you want to write a program that automates the video rental process for a local video store. The two main objects in this problem are the video and the customer. After identifying the objects, the next step is to specify for each object the relevant data and possible operations to be performed on that data.
For example, for a video object, the data might include the movie name, starring actors, producer, production company, number of copies in stock, and so on.
Some of the operations on a video object might include checking the name of the movie, reducing the number of copies in stock by one after a copy is rented, and incrementing the number of copies in stock by one after a customer returns a particular video. This illustrates that each object consists of data and operations on that data.
An object combines data and operations on the data into a single unit. In OOD, the final program is a collection of interacting objects. You will learn about the many advantages of OOD in later chapters. Chapter 2 discusses inheritance and polymorphism. In object-oriented design, you decide what classes you need and their relevant data members and member functions. You then describe how classes interact with each other. Software Development Phase 5 Implementation In the implementation phase, you write and compile programming code to implement the classes and functions that were discovered in the design phase.
This book uses the OOD technique in conjunction with structured programming to solve a particular problem. It contains many case studies—called Programming Examples—to solve real-world problems. The final program consists of several functions, each accomplishing a specific goal. Some functions are part of the main program; others are used to implement various operations on objects. To use a function, the user needs to know only how to use the function and what the function does. The user should not be concerned with the details of the function, that is, how the function is written.
Let us illustrate this with the help of the following example. Suppose that you want to write a function that converts a measurement given in inches into equivalent centimeters. We traverse the list in reverse order starting from the last node. If the list is empty, both functions terminate the program.
As before, we find the place where the new item is supposed to be inserted, create the node, store the new item, and adjust the link fields of the new node and other particular nodes in the list. There are four cases: Case 1: Insertion in an empty list Case 2: Insertion at the beginning of a nonempty list Case 3: Insertion at the end of a nonempty list Case 4: Insertion somewhere in a nonempty list Both cases 1 and 2 require us to change the value of the pointer first.
Cases 3 and 4 are similar. After inserting an item, count is incremented by 1. Next, we show case 4. Consider the doubly linked list shown in Figure After inserting 20, the resulting list is as shown in Figure As before, we first search the list to see whether the item to be deleted is in the list. The search algorithm is the same as before.
Similar to the insert operation, this operation if the item to be deleted is in the list requires the adjustment of two pointers in certain nodes. The delete operation has several cases: Case 1: The list is empty. Case 2: The item to be deleted is in the first node of the list, which would require us to change the value of the pointer first.
Case 3: The item to be deleted is somewhere in the list. Case 4: The item to be deleted is not in the list. Doubly Linked Lists After deleting a node, count is decremented by 1. Let us demonstrate case 3. Consider the list shown in Figure First, we search the list with two pointers and find the node with info 17, and then adjust the link field of the affected nodes.
See Figure The reference of the first node of the list to be sorted is passed as a parameter to the function recMergeSort. Note that the functions divideList, merge, and recMergeSort can be included as private members of the class unorderedLinkedList because these functions are used only to implement the function mergeSort. The function mergeSort calls the function recMergeSort and passes first to this function. It also sets last to point to the last node of the list.
See Programming Exercise 10 at the end of this chapter. Moreover, each sublist can also be divided into two sublists of the same size. Each call to the function recMergeSort makes two recursive calls to the function recMergeSort and each call divides the sublist into two sublists of the same size. So the length of the original list is 8.
The first call to the function recMergeSort divides the original list into two sublists, each of size 4. The first call then makes two recursive calls to the function recMergeSort. Each of these recursive calls divides each sublist, of size 4, into two sublists, each of size 2.
We now have 4 sublists, each of size 2. The next set of recursive calls divides each sublist, of size 2, into sublists of size 1. So we now have 8 sublists, each of size 1. It follows that the exponent 3 in 23 indicates the level of the recursion, as shown in Figure Note that the number of recursion levels is m. Consider the function mergeList, which merges two sorted lists into a sorted list.
Note that this is where the actual work, comparisons and assignments, is done. In general, at level k of the recursion, there are a total of 2k calls Heapsort: Array-Based Lists to the function mergeList. It now follows that the maximum number of comparisons at each level of the recursion is O n.
Because the number of levels of the recursion is m, the maximum number of comparisons made by mergesort is O nm. Hence, the maximum number of comparisons made by mergesort is O n log2n. Let A n denote the number of key comparisons in the average case. In the average case, during the merge process one of the sublists will exhaust before the other list. This is also a good approximation when n is not a power of 2. We can also obtain an analysis of mergesort by constructing and solving certain equations as follows.
As noted before, in mergesort, all the comparisons are made in the method mergeList, which merges two sorted sublists. We remarked that, on average, quicksort is of the order O nlog2n. However, in the worst case, quicksort is of the order O n2. This section describes another algorithm, the heapsort, for array-based lists. This algorithm is of order O n log2n even in the worst case, therefore overcoming the worst case of the quicksort. Consider the list in Figure For example, consider list[3], which is The elements at position list[7] and list[8] are 20 and 10, respectively.
Clearly, list[3] is larger than list[7] and list[8]. Therefore, to facilitate the discussion of heapsort, we typically view data in the form of a complete binary tree as described next.
For example, the data given in Figure can be viewed in a complete binary tree, as shown in Figure The second element of the list, which is 70, is the left child of the root node; the third element of the list, which is 80, is the right child of the root node. Note that Figure clearly shows that the list in Figure is in a heap.
Also note that in Figure , the elements 20, 10, 35, 15, 62, 58, and 30 are called leaves as they have no children. As remarked earlier, to demonstrate the heapsort algorithm, we will draw the complete binary tree corresponding to a list.
Note that even though we will draw a complete binary Heapsort: Array-Based Lists tree to illustrate heapsort, the data gets manipulated in an array. We now describe heapsort. The first step in heapsort is to convert the list into a heap, called buildHeap.
Mohammed Al-Saleh. Deitel advanced data structures course. About This Product. Clearly written with the student in mind, this text fo. Fundamentals Of Data. Malik 2nd Ed Solution manual. Malik brings his proven C Programming 5th Edition.
Malik 5th ed ISBN. Ford William R. Ace your classes with our powerful online study tools. CS Data Structures and Algorithms. Mullins Answers to Review Questions.
S Malik Free Download. Skip to content. Knight, Scott Nutter, Larry K. Comments are closed. My primary goal is to motivate and excite all introductory programming students, regardless of their level.
Motivation breeds excitement for learning. Motivation and excitement are critical factors that lead to the success of the programming student. This text is a culmination and development of my classroom notes throughout more than fifty semesters of teaching successful programming to Computer Science students.
Warning: This text can be expected to create a serious reduction in the demand for programming help during your office hours. The term data structure is used to describe the way data is stored, and the term algorithm is used to describe the way data is processed. Data structures and algorithms are interrelated. Choosing a data structure affects the kind of algorithm you might use, and choosing an algorithm affects the data structures we use.
A data structure is a particular way of organizing data in a computer so that it can be used effectively. For example, we can store a list of items having the same data-type using the array data structure.
We have ratings, but no written reviews for this, yet. Be the first to write a review. Skip to main content. Email to friends Share on Facebook - opens in a new window or tab Share on Twitter - opens in a new window or tab Share on Pinterest - opens in a new window or tab.
Add to Watchlist. Goodreads helps you keep track of books you want to read. Want to Read saving…. Want to Read Currently Reading Read. Other editions. Malik self. Here is a links to 4,5,6,7 edition It looks like 8 isn't available anywhere which is interesting considering it's a purchasable Ebook.
There is a preview available on google books located here. If anyone finds it lmk! If you have already previewed the 8th edition, how does it compare to the 7th edition?
0コメント