Data Structures: A Pseudocode Approach with C Data Structures: A Pseudocode Approach with C

Richard F. Gilberg, Behrouz A. Forouzan

Language: English

Pages: 736

ISBN: 0534390803

Format: PDF / Kindle (mobi) / ePub

This second edition expands upon the solid, practical foundation established in the first edition of the text. A new four-part organizational structure increases the flexibility of the text, and all material is presented in a straightforward manner accompanied by an array of examples and visual diagrams. Machine Musicianship

Computer Science Illuminated

Production Volume Rendering: Design and Implementation

Automata and Computability (Undergraduate Texts in Computer Science)

ALGORITHM 1-4 Multiply Two Matrices Algorithm multiMatrix (matrix1, matrix2, size, matrix3) Multiply matrix1 by matrix2 and place product in matrix3 Pre matrix1 and matrix2 have data size is number of columns and rows in matrix Post matrices multiplied--result in matrix3 1 loop (not end of row) 1 loop (not end of column) 1 loop (size of row times) 1 calculate sum of ƒƒƒƒƒƒƒƒƒƒƒƒƒƒ(all row cells) * (all column cells) 2 store sum in matrix3 continued Chapter 1 Basic Concepts ALGORITHM 1-4

len2 = ... return ... return len1 + len2 + 1; FIGURE 2-10 Recursive Call for Find Expression Length Because the first character is an operator (+), we call recursively after stripping off the plus operator, leaving *ABC/EF. Once again the first character is an operator (*), so we call recursively again, this time with ABC/EF. Because the first character is now an operand (A), we exit the function, returning 1. We are now at the second recursive call (statement 95). We again call recursively,

deleted, the stack must be set to its empty state. If pop is called when the stack is empty, it is in an underflow state. The pop stack operation is shown in Figure 3-3. Chapter 3 Stacks 81 Data Top Pop Top Operation Stack Stack FIGURE 3-3 Pop Stack Operation Stack Top The third stack operation is stack top. Stack top copies the item at the top of the stack; that is, it returns the data in the top element to the user but does not delete it. You might think of this operation as reading

Backtracking Example We start at node 1 and move right until we hit a branching node, 3. At this point we take the upper path. We continue until we get to node 5, at which time we again take the upper path. When we arrive at node 7, we can go no further. However, we have not yet reached our goal. We must therefore backtrack to node 5 and take the next path. At node 8 we again backtrack to node 5 and take the third path. Once again, at node 11, we must backtrack, this time way back to node 3. As

queue->front; queue->front = queue->front->next; free (deletePtr); } // while free (queue); } // if return NULL; } // destroyQueue Program 4-10 Analysis In the normal course of events, the queue being destroyed is empty. If it is, the queue front is null and all we need to do is free the queue header and return. If there are data in the queue, however, we first free the data space using the data pointer stored in the queue node, then we delete the queue node itself. Eventually, we get to the end