## Data Structures and Other Objects Using JavaThis text uses a five-step method for working with data types, to ensure students have a thorough knowledge of the subject and understand the data type abstractly. It also aims to teach students how to use the data type, design and implement it, and analyze the implementation. |

### From inside the book

Results 1-3 of 67

Page 27

We then execute the body of the

searching for does not occur, we will execute this body n times. How many

operations occur during each execution of the

number, but let's just say that each execution of the

operations, where k is some number around 3 or 4 (including the work at the end

of the

necessary, we'll figure out k ...

We then execute the body of the

**loop**, and because the number that we aresearching for does not occur, we will execute this body n times. How many

operations occur during each execution of the

**loop**body? We could count thisnumber, but let's just say that each execution of the

**loop**body requires koperations, where k is some number around 3 or 4 (including the work at the end

of the

**loop**where i is incremented and the termination test is executed). Ifnecessary, we'll figure out k ...

Page 140

Except for two declarations and two statements, all of the work in

countOccurrences happens in this

++) if (target == data [index]) answer++; We can see that the body of the

be executed exactly n times — once for each element in the bag. The body of the

calls to methods that contain

number of statements ...

Except for two declarations and two statements, all of the work in

countOccurrences happens in this

**loop**: for (index = 0; index < manyItems; index++) if (target == data [index]) answer++; We can see that the body of the

**loop**willbe executed exactly n times — once for each element in the bag. The body of the

**loop**also has another important property: The body contains no other**loops**orcalls to methods that contain

**loops**. This is enough to conclude that the totalnumber of statements ...

Page 595

(The

executes.) Selectionsort — Analysis We want to analyze the worst-case running

time for the selectionsort algorithm that we implemented as the method

selectionsort shown in Figure 12.1. Let's use n for the number of elements to be

sorted. In outline form, the major work of the selectionsort algorithm is given here:

for (i = n-1; i > 0; i--) swap (data [fi rst+i] , data [suitable index]) ; When i is equal to

n-1, then data ...

(The

**loop**begins with i set to -1, and therefore the body of the**loop**neverexecutes.) Selectionsort — Analysis We want to analyze the worst-case running

time for the selectionsort algorithm that we implemented as the method

selectionsort shown in Figure 12.1. Let's use n for the number of elements to be

sorted. In outline form, the major work of the selectionsort algorithm is given here:

for (i = n-1; i > 0; i--) swap (data [fi rst+i] , data [suitable index]) ; When i is equal to

n-1, then data ...

### What people are saying - Write a review

User Review - Flag as inappropriate

trtgfhh

### Contents

Chapter | 2 |

LEARNING OBJECTIVES | 14 |

Chapter Summary and Solutions | 38 |

Copyright | |

25 other sections not shown

### Other editions - View all

### Common terms and phrases

Accessor method activated addAll algorithm applet arithmetic overflow array B-tree binary search tree binary tree BTNode Celsius clone method collection class computation constructor contains copy create current element cursor data type digits double numbers empty example expression extended class Figure graph hash table head reference heap heapsort Indicates insufficient memory information hiding initial capacity input IntArrayBag integer IntNode iterator Java Javadoc linked list Location loop manyItems mergesort method returns node null reference number of elements number of operations package parameter position Postcondition pre-order traversal Precondition priority queue private instance variables pseudocode public boolean public class public int public Object public static void public void quicksort recursive call reference variable remove return value returns true root Self-Test Exercises sequence shown simulation specified stack statement step stored string subtree Suppose target Throttle Throws TreeMap vertex vertices write zero