99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

代寫CS1010S: Advanced Recursion

時間:2024-02-24  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯


CS1010S: Programming Methodology

Semester II, 2023/2024

Mission 4

Advanced Recursion

Release date: 16th February 2024

Due: 22nd February 2024, 23:59

Required Files

• mission04-template.py

Background

After demonstrating your abilities to Pharaoh Tyro, you were honored with the presti-gious role of bishop within his esteemed team. The anticipation was palpable as you entered his chambers, where Tyro’s eyes sparkled with expectation. With a grand ges-ture, he handed you three scrolls (Your mission tasks), each bearing the royal seal.

"These," he declared, his voice resonating with authority, "are your inaugural assign-ments as bishop. Execute them diligently and report to me during the upcoming CS1010S class."

This mission consists of three tasks.

Task 1: Number of ways to sum to an Integer (3 marks)

A positive integer n ≥ 2 can be expressed as the sum of a number of positive integers smaller than n. For example:

2 = 1 + 1

3 = 1 + 2

   = 1 + 1 + 1

4 = 1 + 3

   = 2 + 2

   = 1 + 1 + 2

   = 1 + 1 + 1 + 1

5 = 1 + 4

   = 1 + 1 + 3

   = 2 + 3

   = 1 + 2 + 2

   = 1 + 1 + 1 + 2

   = 1 + 1 + 1 + 1 + 1

The function num_sum returns the number of ways that an integer can be expressed as the sum of a number of positive integers. From the above examples, it should be clear that:

>>> num_sum ( 2 )

1

>>> num_sum ( 3 )

2

>>> num_sum ( 4 )

4

>>> num_sum ( 5 )

6

Hint: If you grasp the essence of the count change problem, you’ll recognize that this problem is a variation of it. You may want to consider implementing a helper function that model the count change process of this problem. Solving the problem using closed-form formulas are not allowed.

Task 2: Generalized Pathfinding: Enumerate All Paths (3 marks)

In Lecture Training 5, you faced a problem where you were required to assist Jon in im-plementing a function, num_of_possible_path(board). This function determined the num-ber of possible paths to move from the starting point "S" to the ending point "E" by either walking (covering 1 step) or jumping (covering 2 steps).

Now, you encountered a similar challenge. The game no longer restricts the steps to just 1 or 2; instead, it can be any arbitrary number of steps (i.e. 1, 2, 3, ..., n). Your task is to implement an iterative recursive function, num_of_possible_path(board), which calculates the number of possible paths to move from the starting point "S" to the ending point "E" given that there are n possible ways to move at each step.

You may assume substring(string, start, end, step) function is given.

Hint: Observe that this problem resembles a count change problem. At each step, you have the choice to move 1 step forward, or 2 steps forward, or 3 steps forward, and so on, up to n steps forward.

>>> num_of_possible_path ("S##E", 1 )

1

>>> num_of_possible_path ("S##E", 2 )

3

>>> num_of_possible_path ("S##E", 3 )

4

Task 3: Check valid brackets (5 marks)

Consider a string containing only brackets "(" and ")". A string of brackets is considered valid if:

• Every opening parenthesis has a corresponding closing parenthesis.

• Opening and closing parentheses are in the correct order.

• Each closing parenthesis has a matching opening parenthesis.

Implement a function, check_valid_brackets(s), that returns True if the string s is valid brackets, and False otherwise.

Hint: If a string of brackets is valid, it can repeatedly remove the innermost non-nested "()" until it becomes an empty string.

Subtask 3a: Illustrate Your Problem-Solving Approach

In Lecture 1, you have learnt the Polya’s Problem Solving Process:

1. Understand the Problem

2. Make a Plan (Create a Flowchart, as outlined in Lecture 1 slides)

3. Do the Plan

4. Review & Generalize

Apply the Polya problem-solving methodology, and demonstrate your problem-solving process for Task 3. You are tasked to write out each step, providing insights into your approach and decision-making. This exercise aims to reinforce your understanding and application of the problem-solving methodology.

Please submit your illustration to coursemology. Note that you must include Step 1 and Step 2 in your illustration; Step 3 and Step 4 are optional. (For an example, please refer to Coursemology -> Workbin -> PolyasProblemSolvingExample.pdf)

By using the idea of divide and conquer, here are the steps to solve Task 2

1. Implement an iterative function remove_bracket_pair(s) that takes in a string of brackets. This function iterates through the string from left to right, removing the first occurrence of the brackets pair "()" within the string s, and returns the modified string. You may assume substring(string, start, end, step) function is given.

>>> remove_bracket_pair (" ()()() ")

" ()() "

>>> remove_bracket_pair (" (()()) ")

" (()) "

>>> remove_bracket_pair (" ((())) ")

" (()) "

>>> remove_bracket_pair (")()")

")"

>>> remove_bracket_pair ("()")

""

>>> remove_bracket_pair (" (())((())) ")

" ()((())) "

2. Using the above iterative remove_bracket_pair(s) function, implement a recursive check_valid_brackets(s) that takes in a string of brackets and returns True if the string s is valid brackets, and False otherwise.

>>> check_valid_brackets ("()")

True

>>> check_valid_brackets (" (()) ")

True

>>> check_valid_brackets (" ()() ")

True

>>> check_valid_brackets (" (()")

False

>>> check_valid_brackets (" ())")

False

>>> check_valid_brackets (" ())( ")

False

Subtask 3b: Execute Your Plan

1. Implement the iterative function remove_bracket_pair(s).

2. Implement the recursive function check_valid_brackets(s).

You may assume substring(string, start, end, step) function is given.

You are highly encouraged to test your functions with additional test cases.

Optional: Spiral Maze Iterative Recursively

Write an iterative recursive function num_of_steps that takes in 4 arguments, the x and y coordinates of ending point, x and y, width of the maze, W and height of the maze, H. The function returns the number of steps to navigate from the bottom-left corner (origin) of the maze to the specified ending point. Please follow the question requirements any closed form formula or pure iterative solution will not be accepted.

Hint: You will need to iterate until the boundary, then recursively call the function with the new boundary and updated x & y.



Figure 1: A spiral maze with height 3 and width 3. The number of steps from the origin to the ending point (1, 1) is 8.

num_of_steps (1 , 1 , 3 , 3 )

>>> 8

num_of_steps (0 , 0 , 3 , 3 )

>>> 0

num_of_steps (1 , 1 , 3 , 2 )

>>> 4

num_of_steps (1 , 3 , 5 , 7 )

>>>

Optional: Alternative approach of Task 2

There are many ways to solve the problem in Task 2. You are encouraged to explore alternative approaches to solve the problem.

You may assume substring(string, start, end, step) function is given in this task.

Implement a function, check_valid_brackets_alt(s), that returns True if the string s is valid brackets, and False otherwise.

Completely Iterative Approach (Easy)

You can implement the function purely iterative. Please confine your implementation to what you’ve learned from CS1010S thus far.

Completely Recursive Approach (Challenging)

You may also implement the function purely recursively.

Warning: This is a challenging task.

請加QQ:99515681  郵箱:99515681@qq.com   WX:codehelp 

掃一掃在手機打開當前頁
  • 上一篇:代寫ELEC-4840 編程
  • 下一篇:代寫 Financial Derivatives and Financial
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    出評 開團工具
    出評 開團工具
    挖掘機濾芯提升發動機性能
    挖掘機濾芯提升發動機性能
    海信羅馬假日洗衣機亮相AWE  復古美學與現代科技完美結合
    海信羅馬假日洗衣機亮相AWE 復古美學與現代
    合肥機場巴士4號線
    合肥機場巴士4號線
    合肥機場巴士3號線
    合肥機場巴士3號線
    合肥機場巴士2號線
    合肥機場巴士2號線
    合肥機場巴士1號線
    合肥機場巴士1號線
  • 短信驗證碼 豆包 幣安下載 AI生圖 目錄網

    關于我們 | 打賞支持 | 廣告服務 | 聯系我們 | 網站地圖 | 免責聲明 | 幫助中心 | 友情鏈接 |

    Copyright © 2025 hfw.cc Inc. All Rights Reserved. 合肥網 版權所有
    ICP備06013414號-3 公安備 42010502001045

    99爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

          欧美午夜在线观看| 国产精品一二三四| 狠狠网亚洲精品| 一区二区三区视频在线| 久久香蕉国产线看观看av| 国产精品一区二区久久精品| 亚洲在线免费| 国产一区美女| 国产精品热久久久久夜色精品三区| 欧美在线视频免费观看| 亚洲尤物在线| 在线一区视频| 亚洲精品国产精品乱码不99| 1024欧美极品| 国产在线成人| 国产欧美精品日韩精品| 欧美午夜欧美| 欧美日韩日本视频| 欧美精品一线| 欧美国产一区二区在线观看| 久久琪琪电影院| 久久久.com| 久久国产视频网| 午夜欧美不卡精品aaaaa| 一区二区三区产品免费精品久久75| 一区视频在线播放| …久久精品99久久香蕉国产| 国内精品久久久久久影视8| 国产亚洲欧美一区二区| 国产一区二区在线观看免费播放| 国产精品嫩草久久久久| 国产欧美日韩综合| 国产一区二区日韩精品| 国产亚洲精品bv在线观看| 国产午夜精品理论片a级探花| 国产欧美日韩视频| 国产原创一区二区| 在线观看的日韩av| 亚洲三级免费| 亚洲一级在线观看| 欧美一区影院| 欧美高清视频免费观看| 国产精品第十页| 国产欧美综合在线| 国外精品视频| 日韩一级视频免费观看在线| 亚洲桃花岛网站| 欧美伊人久久| 欧美电影免费观看大全| 欧美日韩亚洲综合一区| 国产亚洲精品美女| 亚洲精品国产品国语在线app| 一区二区三区视频在线| 欧美中文字幕在线| 欧美国产高清| 国产日韩精品视频一区| 亚洲国产欧美一区| 欧美一二三区精品| 免费在线观看日韩欧美| 国产精品视频yy9099| 亚洲高清在线播放| 亚洲综合999| 欧美不卡在线视频| 国产啪精品视频| 一本大道久久a久久综合婷婷| 欧美在线视频一区| 亚洲视频观看| 国产欧美一区二区白浆黑人| 欧美激情一区二区三区全黄 | 欧美日韩一区二区在线| 久久影院午夜片一区| 亚洲宅男天堂在线观看无病毒| 在线免费观看视频一区| 国产伦精品一区二区三区四区免费 | 午夜久久资源| 一本久久精品一区二区| 亚洲国产日韩欧美综合久久| 国产一二三精品| 久久精品30| 亚洲专区在线视频| 欧美日精品一区视频| 亚洲品质自拍| 欧美激情区在线播放| 在线看片日韩| 久久午夜电影网| 狠狠噜噜久久| 久久精品国产一区二区三区免费看| 欧美视频导航| 亚洲免费观看高清完整版在线观看熊 | 久久夜色精品国产亚洲aⅴ| 国产农村妇女精品| 亚洲欧美福利一区二区| 国产精品呻吟| 欧美在线不卡| 韩国在线一区| 鲁大师影院一区二区三区| 国内精品久久久久久| 久久久久久免费| 精久久久久久| 久久综合一区| 亚洲精选中文字幕| 欧美日韩一级片在线观看| 亚洲最快最全在线视频| 国产精品爱啪在线线免费观看| 一本不卡影院| 国产日本亚洲高清| 老鸭窝毛片一区二区三区| 亚洲欧洲一区二区天堂久久| 欧美黄色aaaa| 亚洲自拍电影| 国内精品国产成人| 蜜臀av一级做a爰片久久| 亚洲毛片在线观看| 国产毛片一区| 牛牛国产精品| 亚洲香蕉成视频在线观看| 国产农村妇女精品| 老色鬼久久亚洲一区二区| 亚洲免费观看高清完整版在线观看熊 | 久久精品国产亚洲aⅴ| 亚洲高清一区二| 欧美日韩国产在线看| 亚洲欧美在线一区二区| 国产曰批免费观看久久久| 欧美精品国产精品| 亚洲免费在线| 91久久精品日日躁夜夜躁欧美 | 国产精品成av人在线视午夜片| 午夜久久电影网| 日韩一区二区免费看| 国产日产亚洲精品| 欧美日韩亚洲91| 老司机成人在线视频| 亚洲一区二区三区视频播放| 国产综合第一页| 亚洲欧美成人一区二区三区| 亚洲线精品一区二区三区八戒| 久久久久久91香蕉国产| 欧美日韩一区二区三区四区五区| 国产在线拍偷自揄拍精品| 国产一区二区三区久久精品| 欧美午夜国产| 欧美福利小视频| 久久一区二区三区四区五区| 亚洲专区一区| 亚洲天堂av高清| 夜夜嗨网站十八久久| 亚洲第一区色| 激情综合网激情| 国产一区二区三区黄视频| 国产精品久久久久毛片大屁完整版| 狼人社综合社区| 久久久国产一区二区三区| 亚洲综合另类| 亚洲欧美久久| 亚洲综合色婷婷| 亚洲欧美日韩综合一区| 亚洲一区二区精品在线| 日韩一区二区福利| 亚洲精品久久久蜜桃| 亚洲高清激情| 亚洲国产精品专区久久| 亚洲国产婷婷| 亚洲国产日韩综合一区| 亚洲激情第一页| 亚洲人成在线观看一区二区| 亚洲高清在线| 99精品视频免费观看| 亚洲午夜免费视频| 亚洲性色视频| 欧美中日韩免费视频| 久久成人免费视频| 久久婷婷丁香| 久久综合亚洲社区| 欧美a级片一区| 欧美日韩国产美| 国产精品久久久久国产a级| 国产精品欧美激情| 国产亚洲一本大道中文在线| 精品成人乱色一区二区| 亚洲国产成人av好男人在线观看| 亚洲欧洲在线一区| 亚洲制服丝袜在线| 久久久777| 欧美另类videos死尸| 国产精品久久久久久久7电影| 国产精品视频午夜| 精品成人免费| 亚洲网站在线| 久久久91精品国产一区二区三区| 久久免费黄色| 欧美午夜在线| 黄色成人在线| 国产精品99久久久久久久女警| 午夜精品久久久久久久| 久久三级视频| 欧美日韩在线免费观看| 国内精品久久久久影院 日本资源| 91久久中文| 久久精彩视频|