@@ -234,39 +234,39 @@ const AVLTree = (function () {
234234/**
235235 * A Code for Testing the AVLTree
236236 */
237- ( function test ( ) {
238- const newAVL = new AVLTree ( )
239- const size = Math . floor ( Math . random ( ) * 1000000 )
240- let uniques = 0
241- let i , temp , j
242- const array = [ ]
243- for ( i = 0 ; i < size ; i ++ ) {
244- temp = Math . floor ( Math . random ( ) * Number . MAX_VALUE )
245- if ( newAVL . add ( temp ) ) {
246- uniques ++
247- array . push ( temp )
248- }
249- }
250- if ( newAVL . size !== uniques ) {
251- throw new Error ( 'elements not inserted properly' )
252- }
253- const findTestSize = Math . floor ( Math . random ( ) * uniques )
254- for ( i = 0 ; i < findTestSize ; i ++ ) {
255- j = Math . floor ( Math . random ( ) * uniques )
256- if ( ! newAVL . find ( array [ j ] ) ) {
257- throw new Error ( 'inserted elements not found' )
258- }
259- }
260- const deleteTestSize = Math . floor ( uniques * Math . random ( ) )
261- for ( i = 0 ; i < deleteTestSize ; i ++ ) {
262- j = Math . floor ( Math . random ( ) * uniques )
263- temp = array [ j ]
264- if ( newAVL . find ( temp ) ) {
265- if ( ! newAVL . remove ( temp ) ) {
266- throw new Error ( 'delete not working properly' )
267- }
268- }
269- }
270- } ) ( )
237+ // (function test () {
238+ // const newAVL = new AVLTree()
239+ // const size = Math.floor(Math.random() * 1000000)
240+ // let uniques = 0
241+ // let i, temp, j
242+ // const array = []
243+ // for (i = 0; i < size; i++) {
244+ // temp = Math.floor(Math.random() * Number.MAX_VALUE)
245+ // if (newAVL.add(temp)) {
246+ // uniques++
247+ // array.push(temp)
248+ // }
249+ // }
250+ // if (newAVL.size !== uniques) {
251+ // throw new Error('elements not inserted properly')
252+ // }
253+ // const findTestSize = Math.floor(Math.random() * uniques)
254+ // for (i = 0; i < findTestSize; i++) {
255+ // j = Math.floor(Math.random() * uniques)
256+ // if (!newAVL.find(array[j])) {
257+ // throw new Error('inserted elements not found')
258+ // }
259+ // }
260+ // const deleteTestSize = Math.floor(uniques * Math.random())
261+ // for (i = 0; i < deleteTestSize; i++) {
262+ // j = Math.floor(Math.random() * uniques)
263+ // temp = array[j]
264+ // if (newAVL.find(temp)) {
265+ // if (!newAVL.remove(temp)) {
266+ // throw new Error('delete not working properly')
267+ // }
268+ // }
269+ // }
270+ // })()
271271
272- module . exports = AVLTree
272+ export { AVLTree }
0 commit comments