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爱在线视频这里只有精品_窝窝午夜看片成人精品_日韩精品久久久毛片一区二区_亚洲一区二区久久

          9000px;">

                亚洲精品中文字幕乱码三区| 国产免费观看久久| 国产欧美一区二区三区在线看蜜臀| 日韩精品1区2区3区| 日韩精品一区二区三区三区免费| 视频在线观看国产精品| 精品国产一区二区三区av性色| 国产美女精品在线| 国产精品国产自产拍高清av王其| 在线亚洲欧美专区二区| 麻豆一区二区99久久久久| 久久久亚洲高清| 91麻豆.com| 久久精品国产99国产精品| 中文字幕乱码久久午夜不卡| 在线观看精品一区| 国产一区二区导航在线播放| 中文字幕国产一区二区| 91丨porny丨最新| 日韩精品电影一区亚洲| 中文字幕一区二区三区色视频| 欧美视频在线一区| 成人永久免费视频| 六月丁香婷婷久久| 亚洲一区在线观看视频| 久久久久9999亚洲精品| 欧美日韩在线播放三区四区| 成人午夜免费电影| 精品一区二区综合| 亚洲一区二区欧美| 国产精品久久免费看| 欧美成人午夜电影| 欧美视频中文一区二区三区在线观看| 激情久久五月天| 一区二区高清视频在线观看| 国产女同性恋一区二区| 精品国产99国产精品| 3atv在线一区二区三区| 色综合一个色综合| 91亚洲精品乱码久久久久久蜜桃| 国产精品一二三四五| 免费av网站大全久久| 亚洲chinese男男1069| 亚洲一线二线三线久久久| 国产精品麻豆一区二区 | 99久久亚洲一区二区三区青草| 另类中文字幕网| 偷拍一区二区三区四区| 玉足女爽爽91| 亚洲主播在线观看| 亚洲二区视频在线| 亚洲国产cao| 亚洲大片一区二区三区| 亚洲成a人在线观看| 一区二区久久久久久| 一区二区三区色| 亚洲国产精品久久不卡毛片| 伊人一区二区三区| 亚洲一区二区精品视频| 亚洲网友自拍偷拍| 日韩—二三区免费观看av| 蜜臀av一级做a爰片久久| 久久99热这里只有精品| 国产一区二区电影| www.日韩av| 在线看一区二区| 91精品在线一区二区| 日韩欧美一级二级三级久久久| 欧美xxxx在线观看| 国产精品色在线| 亚洲一区二区三区在线看| 亚洲图片欧美一区| 韩国av一区二区| 99视频精品在线| 欧美日韩精品欧美日韩精品一| 日韩一级高清毛片| 国产精品视频看| 亚洲成在线观看| 国产一区三区三区| 色综合久久久久综合体桃花网| 欧美日韩在线不卡| 国产精品免费视频网站| 午夜欧美2019年伦理| 国产黄色成人av| 欧美日韩成人一区| 精品电影一区二区三区| 亚洲欧美日本韩国| 久久99久久精品| 91亚洲国产成人精品一区二区三| 欧美电影一区二区三区| 国产精品天美传媒| 美女视频黄久久| 色婷婷综合激情| 日韩精品一区二区三区在线播放 | 激情偷乱视频一区二区三区| 久久狠狠亚洲综合| 91天堂素人约啪| 日韩美女主播在线视频一区二区三区| 国产欧美一区二区精品性| 亚洲成av人片一区二区梦乃| 国产一区二区三区久久悠悠色av| 色欧美片视频在线观看| 国产三级一区二区| 美女一区二区久久| 欧美在线观看视频一区二区三区 | 在线成人高清不卡| 中文字幕一区二区视频| 强制捆绑调教一区二区| 91美女蜜桃在线| 国产三级精品三级| 久久精品国产秦先生| 欧美另类变人与禽xxxxx| 亚洲欧美国产三级| 国产精品一区专区| 日韩免费电影网站| 日本午夜一本久久久综合| 91日韩精品一区| 国产精品免费aⅴ片在线观看| 黄页视频在线91| 日韩精品一区在线| 久久66热偷产精品| 日韩精品一区二| 免费看黄色91| 91精品国产欧美日韩| 五月激情六月综合| 欧美亚洲国产怡红院影院| 中文字幕一区av| 91免费视频网| 亚洲综合久久久| 欧美日韩一本到| 日本中文一区二区三区| 5858s免费视频成人| 天天亚洲美女在线视频| 欧美日本在线播放| 日韩av一区二区在线影视| 777xxx欧美| 美国十次综合导航| 精品国产一区二区国模嫣然| 极品少妇一区二区三区精品视频| 精品久久久久一区| 成人av第一页| 亚洲福利国产精品| 日韩精品一区二区三区四区| 国产一区视频在线看| 中文字幕免费一区| 欧美天堂一区二区三区| 蜜桃视频第一区免费观看| 国产午夜亚洲精品午夜鲁丝片| av一区二区不卡| 亚洲一区二区中文在线| 91精品国模一区二区三区| 国产一区二区不卡| 亚洲欧美一区二区三区国产精品| 欧美午夜精品久久久久久超碰| 日韩精品免费视频人成| 久久精品一区二区| 欧美亚洲精品一区| 国产超碰在线一区| 丝袜美腿亚洲色图| 久久精品日韩一区二区三区| 91香蕉视频mp4| 美女www一区二区| 亚洲天堂2014| 日韩免费看的电影| 在线欧美小视频| 高清国产午夜精品久久久久久| 亚洲综合视频在线观看| 国产亚洲综合av| 欧美午夜电影网| 国产不卡在线一区| 看电视剧不卡顿的网站| 夜夜精品视频一区二区| 欧美激情综合五月色丁香小说| 欧美理论在线播放| 色狠狠一区二区三区香蕉| 国产一区二区三区久久悠悠色av| 亚洲国产另类精品专区| 国产精品女同一区二区三区| 欧美一区二区三区色| 在线观看一区二区视频| 成人免费福利片| 国产麻豆一精品一av一免费| 五月天精品一区二区三区| 亚洲综合色噜噜狠狠| 亚洲人成网站色在线观看| 国产精品无人区| 久久综合久久综合九色| 欧美一区二区在线免费播放| 在线观看日产精品| 色综合天天视频在线观看| caoporn国产精品| 成人黄色网址在线观看| 国产成人精品影院| 国产一区不卡在线| 极品少妇一区二区| 久久国产精品区| 国产一区999| 国产电影一区二区三区| 国产美女在线精品| 国产福利精品一区二区|