Hello..

I'm doing a project that involves searching/matching 2 matrix's. The basic idea:

Matrix 1:

0 1 0 1 0
1 0 1 0 1
1 1 1 0 1

Which will then be interpreted in memory as:

0 1 0 1 0 1 0 1 0 1 1 1 1 0 1

Matrix 2:

0 1 0 1 0
1 0 1 0 1

Which will then be interpreted in memory as:

0 1 0 1 0 1 0 1 0 1

Would a binary tree (search) be most efficient? I've come up with the idea of starting at the midpoint and in the array(matrix 2) and checking to see if it matches with the other array (matrix2) and if it does, go left until it returns false, and then go right to check if there's a match.

Any ideas? :)

Recommended Answers

All 3 Replies

Matrix 1:

0 1 0 1 0
1 0 1 0 1
1 1 1 0 1

What's the data type of Matrix?

What's the data type of Matrix?

Thanks for your reply :)

The matrix is a double.

If its just 1's and 0's you might as well use std::bitset

std::bitset<15> mat1(std::string("010101010111101"));
cout << mat1.to_ulong() << endl;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.