Algorithms - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Algorithms

Posts: 5Member
Suppose you are given a set P of integers and another integer x. We wish to use a T(nlgn) algorithm to decide whether there are 2 integers in P and the product (multiplication) of these two integers equals to x. Show your algorithm. (You can use pseudo code or by illustration only)

This is what I have:
Var x;
Function equate( list m)
// if list size is 0 empty or 1 print computation can not be done
If(length m >=1)
Divide the lists into two parts
Var list left ,right ;
Var int middle = length (m) /2;
For each x in before middle
Add x to the left // left is an array
Loop : For (int i=0;i< middle;i++ )
For (int j= 1;j<middle;j++)
multiply left (i)xleft(j)
if (left (i)xleft(j) =x )
print left (i) , left(j)
For each x in after middle before length(m) // right is an array
Loop : For (int i=middle ; i< m ;i++ )
For (int j= middle ;j<m ;j++)
multiply right (i)x right (j)
if (right (i)xright (j) =x )
print right (i), right j

Is this correct. Please, do not make it complicated. I want to keep it simple. If it is correct or I have to change something please tell me the line, and what it should look like, write the line out! Thank you!