首页 \ 问答 \ O(mn)和O(mnlgn)(O(mn) and O(mnlgn))

O(mn)和O(mnlgn)(O(mn) and O(mnlgn))

对于上面的两个大O,如果n >> m会发生什么。 大O如何改变? 它在第一种情况下变成了O(n)吗? 如果是,为什么?


for the above 2 big O's, what happens if n>>m . How does the big O change? Does it become O(n) in the first case. If yes ,why?


原文:https://stackoverflow.com/questions/5290598
更新时间:2023-05-21 10:05

最满意答案

罗杰

这是一个有效的,经过测试的用例语法。 我尝试使用你所拥有的但它失败并且看起来不完整。 以下是两个示例,用于演示条件存在时的可选外观:

S = A <space> B [<space> optC]

A = "a"

B = "b"

C = "c"

optC = C

space = #' '

以下是两个输出:

;input 1 = "a b"
;produces

=> [:S [:A "a"] [:B "b"]]

input 2 = "a b c"
;produces

=> [:S [:A "a"] [:B "b"] [:optC [:C "c"]]]

用你的语法。 正如我所说,我遇到了麻烦,因为它似乎没有完全定义,但一般来说:

(* If you change this *)

interface = <interface_dec> uses

(* to this, you should get similar results *)

interface = <interface_dec> [uses] 

如果这不起作用,那么您需要提供一个语法,该语法与提供的输入样本一起使用,因为它们似乎不同步。


Roger

Here is a valid, tested use case grammar. I tried using what you have but it is failing and doesn't appear complete. Following this are two examples to demonstrate optional appearance if condition exists:

S = A <space> B [<space> optC]

A = "a"

B = "b"

C = "c"

optC = C

space = #' '

Here are the two outputs:

;input 1 = "a b"
;produces

=> [:S [:A "a"] [:B "b"]]

input 2 = "a b c"
;produces

=> [:S [:A "a"] [:B "b"] [:optC [:C "c"]]]

With your grammar. As I said, I was having trouble as it does not appear fully defined but generally speaking:

(* If you change this *)

interface = <interface_dec> uses

(* to this, you should get similar results *)

interface = <interface_dec> [uses] 

If that doesn't work then you would need to provide a grammar that works with the input sample provided as they seem out of synch.

相关问答

更多
  • 我会创建两个SimpleDateFormat,一个带有时区,另一个没有。 您可以查看字符串的长度以确定要使用哪一个。 听起来你需要一个DateFormat,它代表两个不同的SDF。 DateFormat df = new DateFormat() { static final String FORMAT1 = "yyyyMMddHHmmss"; static final String FORMAT2 = "yyyyMMddHHmmssz"; final SimpleDateForma ...
  • 您可以为查询语言编写一个小编译器,使用instaparse生成一个解析树,使用常规Clojure函数将其转换为Clojure代码,最后生成一个Clojure函数,然后将其应用于您的记录。 对eval的初始调用会有些昂贵,但结果函数将等同于在源文件中手动编写的函数,并且不会带来性能损失。 实际上,这是eval一个罕见的有效用例 - 生成一个函数,其代码以真正动态的方式构造,然后将被调用很多次。 显然,当遵循这种方法时,您需要确保您不会无意中允许不受信任的源执行任意代码。 为了演示,这里是一个基于非常简单的语法 ...
  • 罗杰 这是一个有效的,经过测试的用例语法。 我尝试使用你所拥有的但它失败并且看起来不完整。 以下是两个示例,用于演示条件存在时的可选外观: S = A B [ optC] A = "a" B = "b" C = "c" optC = C space = #' ' 以下是两个输出: ;input 1 = "a b" ;produces => [:S [:A "a"] [:B "b"]] input 2 = "a b c" ;produces => [:S [:A ...
  • React路由器使用path-to-regexp - https://github.com/pillarjs/path-to-regexp 您可以将可选的非参数与这样的路径匹配: const path = "/to/page/:pathParam1?/(otherParam)?/:pathParam2?" 并测试它: const re = pathToRegexp(path) console.log(re.exec("/to/page/1")) // ["/to/page/1", "1", undefi ...
  • 这是一个工作示例项目: project.clj: (defproject parse "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies ...
  • 当您在输入上使用parser本身而不是通过insta/parses ,它会在REPL处输出错误的错误消息。 一个例子: (def ebnf "expr = A DOT A = 'A' DOT = '.'") user> ((insta/parser ebnf) "A.") [:expr [:A "A"] [:DOT "."]] user> ((insta/parser ebnf) "B.") Parse error at line 1, column 1: B. ^ Expecte ...
  • 您可以传递可选参数以启用自动空白: (doc insta/parser) ------------------------- instaparse.core/parser ([grammar-specification & {:as options}]) :auto-whitespace (:standard or :comma) or :auto-whitespace custom-whitespace-parser You can pass an optional parameter ...
  • 你只要把它们当作字符串来处理。 例如: ((insta/parser "S = '<' tag '>' tag = #'\\w+' ") "") ; [:S "<" [:tag "html"] ">"] 在instaparse中,您可以使用尖括号<>隐藏已解析的元素,从树输出中抑制它们。 ((insta/parser "S = <'<'> tag <'>'> tag = #'\\w+' ") "") ; [:S [:tag "html"]] ...
  • 你只需要添加? 两个非捕获组的(零或一个匹配)量词。 -[A-Z1-9]{2,8}(?: \(Alarm .*?\))?(?: \(Box .*\))? (.*?)\. \( 现在它应该工作,无论是否存在Alarm Type和Box 。 DEMO You just need to add ? (zero or one match) quantifiers to both non-capturing groups. -[A-Z1-9]{2,8}(?: \(Alarm .*?\))?(?: \(Box .*\ ...
  • 我真的不知道instaparser,所以我只是阅读了足够的文档来给我一种虚假的安全感。 我也没有测试,我真的不知道你的要求是什么。 特别是,我不知道: 1)$()是否可以嵌套(我认为你的语法不可能,但我觉得这很奇怪) 2)是否()可以包含空格而不被解析为多个单词 3)是否()可以包含$() 你需要清楚这样的事情才能写出语法(或者,当它发生时,要求建议)。 更新 : 根据评论修改语法。 我删除了$ (和)因为它们似乎没必要,这样角括号感觉更容易处理。 以下是基于回答上述问题“是,否,是”以及关于正则表达式格式 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)