简体   繁体   English

矩形矩阵复杂度

[英]rectangular matrix complexity

I have to compute complexity of algorithm which searches an element in a rectangular matrix. 我必须计算在矩形矩阵中搜索元素的算法的复杂性。 It uses divide and conquer. 它使用分而治之。 For square matrix my time functions becomes a*T(n/b)+O(n^2). 对于方矩阵,我的时间函数变为a * T(n / b)+ O(n ^ 2)。 But for rectangular matrix I don't know how to denote the division if it has to be divided into 4 sub matrices. 但是对于矩形矩阵,如果必须将其划分为4个子矩阵,我不知道如何表示该划分。 Will it be a*T(m*n/4) + O(n)? 是a * T(m * n / 4)+ O(n)吗?

You didn't describe you algorithm so it's not possible to answer the question precisely. 您没有描述算法,因此无法精确回答问题。 But I'll try assuming the algorithm is like: 但我会尝试假设算法如下:

  1. If m = 1 or n = 1 then process matrix in O(m * n) time. 如果m = 1n = 1则在O(m * n)时间内处理矩阵。
  2. Else ( m > 1 and n > 1 ) divide matrix into four matricies of size not more then [m / 2]x[n / 2] , where [y] is a minimal integer not less then y . 否则( m > 1n > 1 )将矩阵分为四个不n > 1 [m / 2]x[n / 2]矩阵,其中[y]是不小于y的最小整数。
  3. Call the algorithm with each of these matricies. 使用这些矩阵中的每一个调用算法。 Then "merge" results in O(m * n) time. 然后“合并”将导致O(m * n)时间。

In this case recurrent equation for time complexity will be 在这种情况下,时间复杂度的递归方程将是

  1. T(1, n) = O(n) T(1,n)= O(n)
  2. T(m, 1) = O(m) T(m,1)= O(米)
  3. T(m, n) = 4 * T([m / 2], [n / 2]) + O(m * n) T(m,n)= 4 * T([m / 2],[n / 2])+ O(m * n)

Lets solve it 让我们解决它

T(m, n) = O(m * n) +
          4 * O([m / 2] * [n / 2]) +
          4 ^ 2 * O([m / 4] * [n / 4]) +
          ... +
          4 ^ L * O([m / 2 ^ L] * [n / 2 ^ L]),  where L = [log(min(m, n))]
T(m, n) = O(m * n + ... + 4 ^ L * [m / 2 ^ L] * [n / 2 ^ L]) =
        = O(m * n + ... + 2 ^ L * [m / 2 ^ L] * 2 ^ L * [n / 2 ^ L] =
        = O(m * n + ... + m * n  (L times)) =
        = O(L * m * n) = O(m * n * [log(min(m, n))])

So the answer to your question is 因此,您的问题的答案是

T(m, n) = O(m * n * [log(min(m, n))]), where log stands for a binary logarithm and [y] stands for ceil function. T(m,n)= O(m * n * [log(min(m,n))])),其中log代表二进制对数, [y]代表ceil函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何访问矩形矩阵中的每一行和每一列 - How to get access to each row and column in rectangular matrix 任意大小的矩形矩阵的运行时有效换位 - Run-time efficient transposition of a rectangular matrix of arbitrary size MKL矩形矩阵就地转置:不使用多核? - MKL Rectangular Matrix inplace transpose: not using multiple cores? 判断一个矩形矩阵是否有两行正元素 - Determine if a rectangular matrix has two rows of positive elements 如何计算非正方形(矩形)矩阵的正交基础 - How to compute the orthonormal basis of a non square (rectangular) matrix 向右开始在正方形或矩形矩阵上添加对角线的算法 - algorithm for adding the diagonals on a square or rectangular matrix, starting rightwise 如何使用GSL在C中找到矩形矩阵的逆矩阵 - How to find the inverse of a Rectangular Matrix in C using GSL 如何通过用户给出的输入将二维矩阵的元素打印为矩形 - How to print the elements of 2D matrix as rectangular shape by the input given by user 给定已充电的整数矩形MATRIX(MxN),请计算相对于垂直轴有多少个对称元素 - Given a rectangular MATRIX(MxN) of integers, already charged, calculate how many are symmetric elements with respect to the vertical axis 最优矩阵搜索(2D)问题的时间复杂度分析 - Time complexity analysis on Optimal Matrix Search(2D) problem
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM