The following function accepts an array as input parameter and returns true if the array is empty or false otherwise. Function IsArrayEmpty(ByVal arr) If Len(Join(arr,"")) = 0 Then IsArrayEmpty = True Else IsArrayEmpty = False End If End Function

# Tag Archive: array

Jun 19 2008

## Handling Java Arrays

Tsachi Nimni was kind enough to publish what I think is an undocumented killer feature in QTP’s Java-Addin – an inherent capability to use Java arrays. When working with Java object properties, you’re bound to come across a property which stores its data in an array. Unlike .Net or VB arrays, Java arrays are completely …

May 01 2008

## Read Excel Range into an Array

Usually, we only want to read some data from an Excel worksheet, and we’ll be more than happy to get that data in a simple 2-dimensional array. Later we can loop through the array, and access the data in a quick and easy fashion. Here’s a function which receives an Excel file, the workbook name …

Apr 02 2008

## Sorting Array – Bubble Sort

Bubble sort is a simple sorting algorithm. It works by repeatedly stepping through the list to be sorted, comparing two items at a time and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which means the list is sorted. The algorithm gets …

Apr 02 2008

## Sort Arrays – Merge Sort

In computer science, merge sort or mergesort is an O(n log n) comparison-based sorting algorithm. It is stable, meaning that it preserves the input order of equal elements in the sorted output. It is an example of the divide and conquer algorithmic paradigm. It was invented by John von Neumann in 1945. Fig 1: Merge …

Apr 02 2008

## Sorting Arrays – Quick Sort

Quicksort in action on a list of random numbers. The horizontal lines are pivot values.Quicksort is a well-known sorting algorithm developed by C. A. R. Hoare that, on average, makes (big O notation) comparisons to sort n items. However, in the worst case, it makes L(n2) comparisons. Typically, quicksort is significantly faster in practice than …

Apr 02 2008

## Worst Case Array Statistics

Worst case means that the array is already sorted in reverse order from the required. Worst Case Function just loop from max to min to create a sorted array in descending order Worst Case Function Public Sub WorstCase( ByRef arr(), Byval nSize ) Dim i, nCount Redim arr( nSize – 1 ) nCount = 0 …

Apr 02 2008

## Sorting Arrays – Heap Sort

Heapsort is a comparison-based sorting algorithm, and is part of the selection sort family. Although somewhat slower in practice on most machines than a good implementation of quicksort, it has the advantage of a worst-case O(n log n) runtime. Heapsort is an in-place algorithm, but is not a stable sort. Fig. 1: Heap Sort Animation …

Apr 02 2008

## Sorting a String Array

Sorting arrays in VBScript has never been easy; that’s because VBScript doesn’t have a sort command of any kind. In turn, that always meant that VBScript were forced to write their own sort routines, be that a bubble sort, a heap sort, a quicksort, or some other type of sorting algorithm. But that was before …