dynamic-programming:动态编程练习

时间:2021-03-09 03:29:18
【文件属性】:
文件名称:dynamic-programming:动态编程练习
文件大小:23KB
文件格式:ZIP
更新时间:2021-03-09 03:29:18
Ruby 动态编程 动态编程是一种开发算法的策略,其中解决了每个子问题,并记录了结果以用于解决更大的问题。 在本练习中,您将编写一对动态编程方法。 第一波纽曼康威序列 [Newman-Conway序列]是生成以下整数序列的序列。 1 1 2 2 3 4 4 4 5 6 7 7…..并遵循以下递归公式。 P(1) = 1 P(2) = 1 for all n > 2 P(n) = P(P(n - 1)) + P(n - P(n - 1)) 给定数字n然后打印n项纽曼康韦序列 例子: Input : 13 Output : 1 1 2 2 3 4 4 4 5 6 7 7 8 Input : 20 Output : 1 1 2 2 3 4 4 4 5 6 7 7 8 8 8 8 9 10 11 12 您应该能够以O(n)的时间复杂度执行此操作。 Wave 2最大总和连续子数组 编写一种方法,以在总和最
【文件预览】:
dynamic-programming-master
----.gitignore(1KB)
----Dockerfile(503B)
----images()
--------kadane-Algorithm.png(18KB)
----test.sh(18B)
----LICENSE(1KB)
----README.md(2KB)
----lib()
--------max_subarray.rb(166B)
--------newman_conway.rb(134B)
----Gemfile(163B)
----Rakefile(158B)
----test()
--------newman_conway_test.rb(935B)
--------max_sub_array_test.rb(1KB)
--------test_helper.rb(249B)
----Gemfile.lock(605B)

网友评论