日韩精品一区二区三区高清_久久国产热这里只有精品8_天天做爽夜夜做爽_一本岛在免费一二三区

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

代寫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
  • 無相關信息
    合肥生活資訊

    合肥圖文信息
    2025年10月份更新拼多多改銷助手小象助手多多出評軟件
    2025年10月份更新拼多多改銷助手小象助手多
    有限元分析 CAE仿真分析服務-企業/產品研發/客戶要求/設計優化
    有限元分析 CAE仿真分析服務-企業/產品研發
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    急尋熱仿真分析?代做熱仿真服務+熱設計優化
    出評 開團工具
    出評 開團工具
    挖掘機濾芯提升發動機性能
    挖掘機濾芯提升發動機性能
    海信羅馬假日洗衣機亮相AWE  復古美學與現代科技完美結合
    海信羅馬假日洗衣機亮相AWE 復古美學與現代
    合肥機場巴士4號線
    合肥機場巴士4號線
    合肥機場巴士3號線
    合肥機場巴士3號線
  • 短信驗證碼 trae 豆包網頁版入口 目錄網 排行網

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

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

    日韩精品一区二区三区高清_久久国产热这里只有精品8_天天做爽夜夜做爽_一本岛在免费一二三区

      <em id="rw4ev"></em>

        <tr id="rw4ev"></tr>

        <nav id="rw4ev"></nav>
        <strike id="rw4ev"><pre id="rw4ev"></pre></strike>
        亚洲乱码国产乱码精品精可以看| 国产亚洲欧美色| 亚洲主播在线| 亚洲精品在线看| 亚洲影视在线播放| 亚洲一区日韩在线| 欧美视频官网| 亚洲在线电影| 一区二区三区在线高清| 国产欧美日本| 伊人狠狠色j香婷婷综合| 国产精品久久久久久久久免费| 欧美色另类天堂2015| 99国产精品国产精品久久| 亚洲区在线播放| 久久精品91久久久久久再现| 亚洲精品影院在线观看| 欧美精品97| 亚洲精品久久久久久久久| 亚洲电影第1页| 韩日精品视频一区| 午夜宅男欧美| 久久精品国产清自在天天线| 美女黄毛**国产精品啪啪| 欧美日韩国产在线| 久热精品视频在线观看| 亚洲午夜一二三区视频| 国产精品扒开腿做爽爽爽软件| 国产精品美女诱惑| 麻豆乱码国产一区二区三区| 国产一区高清视频| 亚洲美女色禁图| 在线日韩欧美视频| 先锋影音国产精品| 久久久久久69| 亚洲乱码日产精品bd| 日韩视频在线观看| 欧美性大战久久久久久久蜜臀| 日韩一级大片| 日韩视频久久| 欧美日本免费一区二区三区| 亚洲成人在线视频网站| 久久久久久久久蜜桃| 亚洲一区二区不卡免费| 亚洲在线免费观看| 伊人久久亚洲影院| 欧美国产精品人人做人人爱| 久久精品欧美日韩| 久久在线播放| 狠狠88综合久久久久综合网| 欧美一区二区播放| 国产亚洲欧美另类中文| 欧美日韩一区二区三区在线观看免| 欧美日韩一区免费| 国产精品欧美激情| 久久国产直播| 欧美一区二区视频在线观看| 亚洲视频自拍偷拍| 亚洲人被黑人高潮完整版| 欧美无乱码久久久免费午夜一区| 亚洲精品久久7777| 久久成人av少妇免费| 欧美紧缚bdsm在线视频| 亚洲国产精品电影在线观看| 亚洲一区二区三区久久| 欧美激情一区二区三区在线| 午夜视频一区| 亚洲一级在线| 国产一区二区三区在线观看精品| 亚洲国产精品一区二区尤物区| 国产一区二区三区无遮挡| 久久大香伊蕉在人线观看热2| 国产精品乱码一区二区三区| 亚欧成人在线| 国产精品久久久久国产a级| 美腿丝袜亚洲色图| 欧美美女日韩| 国产乱码精品| 欧美日韩国产精品| 国产精品久久久久久久久搜平片| 国产精品福利片| 中国女人久久久| 国产精品视频xxxx| 一区二区欧美日韩| 亚洲精品麻豆| 亚洲精品国偷自产在线99热| 欧美+日本+国产+在线a∨观看| 亚洲欧美一区二区精品久久久| 红桃视频成人| 蜜桃伊人久久| 在线观看日产精品| 欧美人与禽猛交乱配| 久久国产精品亚洲77777| 一区二区三区国产在线观看| 国产精品国产三级国产专区53| 久久aⅴ乱码一区二区三区| 午夜精品偷拍| 亚洲久久在线| 欧美一级片久久久久久久| 男人插女人欧美| 亚洲在线第一页| 国模精品一区二区三区色天香| 一区二区在线不卡| 亚洲激情av在线| 乱人伦精品视频在线观看| 午夜精品久久久久99热蜜桃导演| 欧美大香线蕉线伊人久久国产精品| 久久综合九色综合欧美狠狠| 国产精品一区一区三区| 国产精品久久久久影院色老大| 樱桃视频在线观看一区| 欧美www视频| 国产一区二区三区免费在线观看| 国产精品青草久久| 亚洲一级特黄| 在线视频精品一| 1024日韩| 亚洲另类视频| 欧美+亚洲+精品+三区| 国产精品久久久999| 亚洲在线免费观看| 国产午夜精品麻豆| 欧美日韩国产bt| 免费日韩精品中文字幕视频在线| 久久成人18免费网站| 国产精品一区2区| 黄色亚洲大片免费在线观看| 欧美大尺度在线观看| 欧美一区二区三区视频在线观看| 亚洲免费av电影| 欧美高清一区二区| 国产一区日韩一区| 国产精品成人一区| 国产精品av久久久久久麻豆网| 亚洲精品日韩在线观看| 免费看精品久久片| 亚洲精品在线观| 国产精品国产三级国产普通话99| av成人黄色| 欧美成人精品不卡视频在线观看| 亚洲精品国产精品乱码不99按摩| 在线看片欧美| 欧美视频日韩视频| 国产亚洲午夜| 亚洲男人的天堂在线| 一级成人国产| 国产精品美女一区二区在线观看| 久久蜜臀精品av| 亚洲欧美日韩在线| 国产精品福利在线观看网址| 国产日韩精品在线| 中国av一区| 欧美性大战久久久久久久| 亚洲国产精品一区二区尤物区| 每日更新成人在线视频| 在线精品视频一区二区三四| 欧美日韩中文| 免费成人在线视频网站| 欧美日韩精品免费观看视频| 国产精品视频成人| 国产一区二区精品在线观看| 黄网站免费久久| 国产精品久久久久久久久久久久久| 亚洲欧美激情视频|