/* *************************************************************************
 * Que 5. Given two arrays A and B each with n elements. 
 * Give an algorithm for finding largest n pairs (A[i],B[j])
 * 
 * Comments - 	1) Heapify A and B - O(2*n) = O(N)
 * 		2) Keep on deleting the element from both the heaps (2log(n))
 * 
 * Time Complexity : O(nlog(N))
 * Space Complexity: O(N)
 * 
 * *************************************************************************/
void FindLargestPairs(int A[], int B[], int n)
{
   PriorityQueue queueA(n,MAX_HEAP),queueB(n,MAX_HEAP);
   queueA.Heapify(A,n);
   queueB.Heapify(B,n);
   for(int i=0;i<n;i++)
     printf("(%d,%d)\n",queueA.DeleteTop(),queueB.DeleteTop());
}
Пример #2
0
int FormFunc::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0:
            infoLUpdated((*reinterpret_cast< QString(*)>(_a[1])));
            break;
        case 1:
            searchB();
            break;
        case 2:
            nextB();
            break;
        case 3:
            prevB();
            break;
        case 4:
            clrB();
            break;
        case 5:
            playB();
            break;
        case 6:
            downloadB();
            break;
        case 7:
            setPage();
            break;
        case 8:
            abortB();
            break;
        case 9:
            timeOut();
            break;
        case 10:
            mnuTPopup();
            break;
        case 11:
            mnuQPopup();
            break;
        case 12:
            copyAddr();
            break;
        case 13:
            delQueueEntry();
            break;
        case 14:
            dwnPB();
            break;
        case 15:
            copyAddr2();
            break;
        case 16:
            chPage((*reinterpret_cast< bool(*)>(_a[1])));
            break;
        case 17:
            queueB();
            break;
        case 18:
            searchAddressAfterThr();
            break;
        case 19:
            openInBrowser();
            break;
        case 20:
            updateInfoL((*reinterpret_cast< QString(*)>(_a[1])));
            break;
        case 21:
            infoL((*reinterpret_cast< QString(*)>(_a[1])));
            break;
        default:
            ;
        }
        _id -= 22;
    }
    return _id;
}