Java Reference
In-Depth Information
147 private static int getRightChildIndex( int
index)
148 {
149 return 2 * index + 1 ;
150 }
151
152 /**
153 Returns the index of the parent.
154 @param index the index of a node in this heap
155 @return the index of the parent of the given node
156 */
157 private static int getParentIndex( int
index)
158 {
159 return index / 2 ;
160 }
161
162 /**
163 Returns the value of the left child.
164 @param index the index of a node in this heap
165 @return the value of the left child of the given node
166 */
167 private Comparable getLeftChild( int index)
168 {
169 return elements.get( 2 * index);
170 }
171
172 /**
173 Returns the value of the right child.
174 @param index the index of a node in this heap
175 @return the value of the right child of the given node
176 */
177 private Comparable getRightChild( int index)
178 {
179 return elements.get( 2 * index + 1 );
180 }
181
182 /**
183 Returns the value of the parent.
184 @param index the index of a node in this heap
185 @return the value of the parent of the given node
749
Search WWH ::




Custom Search