91精品国产91久久久久久_国产精品二区一区二区aⅴ污介绍_一本久久a久久精品vr综合_亚洲视频一区二区三区

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

代寫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號線
  • 短信驗證碼 目錄網 排行網

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

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

    91精品国产91久久久久久_国产精品二区一区二区aⅴ污介绍_一本久久a久久精品vr综合_亚洲视频一区二区三区
    国产三区在线成人av| 日韩一级片网址| 久久看片网站| 精品国产乱子伦一区| 最近日韩中文字幕| 九九九久久久精品| 亚洲视频高清| 一区二区三区中文字幕电影 | 国产99精品视频| 亚洲久久在线| 日韩三级视频中文字幕| 亚洲欧美色图小说| 成人蜜臀av电影| 久久国产精品一区二区三区| 精品国产成人在线影院| 免费观看在线色综合| 欧美激情91| 69堂成人精品免费视频| 亚洲一区视频在线| 午夜视频精品| 欧美一区二区视频在线观看| 亚洲制服丝袜av| 韩国久久久久| 日韩精品中文字幕一区| 蜜桃视频在线一区| 国产女优一区| 亚洲三级电影网站| 欧美欧美全黄| 欧美草草影院在线视频| 久色婷婷小香蕉久久| 国产欧美精品| 亚洲欧美日韩久久| 欧美暴力喷水在线| 欧美一区二区三区免费视频| 日韩激情视频网站| 在线午夜精品| 亚洲天堂精品视频| 欧美一区激情视频在线观看| 欧美精品1区2区| 喷水一区二区三区| 久久国产精品亚洲va麻豆| 亚洲视频在线观看三级| 成人av在线看| 欧美一级一区二区| 国产资源精品在线观看| 欧美日韩另类国产亚洲欧美一级| 午夜日韩在线观看| 久久高清国产| 亚洲国产精品久久久男人的天堂 | 日韩国产精品91| 久久国产毛片| 日韩精品一二区| 噜噜噜在线观看免费视频日韩| 亚洲另类春色国产| 亚洲精品欧美| 亚洲一区二区视频在线| 国产亚洲一区二区三区在线播放| 亚洲美女视频在线| 夜夜嗨一区二区三区| 一区二区三区四区在线播放| 亚洲三级视频| 亚洲一区二区不卡免费| 欧美疯狂做受xxxx富婆| 国产剧情一区在线| 欧美精品亚洲一区二区在线播放| 韩国精品在线观看| 26uuu亚洲综合色| 久久大香伊蕉在人线观看热2| 香蕉精品999视频一区二区 | 久久99精品久久久久久国产越南 | 欧美午夜片在线看| 伊人久久婷婷| 亚洲福利视频三区| 一本久久综合亚洲鲁鲁五月天 | 精品国免费一区二区三区| 亚洲va天堂va国产va久| 久久精品一区二区国产| 丁香五精品蜜臀久久久久99网站| 国产午夜久久久久| 欧美日韩aaaaa| 色呦呦日韩精品| 欧美色欧美亚洲另类七区| 天天综合网 天天综合色| 最近日韩中文字幕| 欧美精品一区二区三区一线天视频| 欧美人与z0zoxxxx视频| 成人精品高清在线| 国产一区 二区 三区一级| 国产精品久久二区二区| 久久高清一区| 亚洲色图清纯唯美| 在线播放/欧美激情| 亚洲精华国产欧美| 你懂的国产精品永久在线| 国产一区欧美一区| 综合久久综合久久| 在线视频你懂得一区| 91在线免费播放| 五月天国产精品| 国产精品另类一区| 欧美无砖专区一中文字| 国内精品久久国产| 国产精品亚洲视频| 亚洲码国产岛国毛片在线| 久久亚洲一级片| 欧美日韩精品欧美日韩精品一综合| 一区二区毛片| 亚洲一区二区精品在线| 午夜在线精品偷拍| 一区二区三区高清视频在线观看| 国产精品yjizz| 影音先锋中文字幕一区二区| 国产欧美在线| 欧美亚洲尤物久久| 麻豆精品网站| 国产欧美日韩在线播放| 欧美日韩mv| 男女男精品网站| 韩日欧美一区二区三区| av不卡一区二区三区| 国产精品porn| 在线免费精品视频| 亚洲欧洲av在线| 欧洲av一区二区嗯嗯嗯啊| 午夜精品999| 久久不见久久见免费视频7| 国产精品久久福利| 在线电影一区二区三区| 亚洲精品孕妇| 99久久免费视频.com| 麻豆成人免费电影| 亚洲精品国产一区二区精华液| 欧美一级一区二区| 91精彩视频在线观看| 亚洲国内精品| 色综合天天天天做夜夜夜夜做| 免费在线观看一区| 一区二区久久久久| 国产色一区二区| 日韩女优视频免费观看| 色综合激情久久| 国产欧美在线| 好吊一区二区三区| av在线免费不卡| 韩国精品在线观看| 舔着乳尖日韩一区| 夜夜嗨av一区二区三区四季av| 国产精品女人毛片| 精品国产91亚洲一区二区三区婷婷| 欧美日韩免费观看一区二区三区| 亚洲精品极品| 激情一区二区| 欧美久久在线| 99久久婷婷国产精品综合| 国产成人综合精品三级| 极品美女销魂一区二区三区| 香蕉久久一区二区不卡无毒影院| 亚洲女与黑人做爰| 亚洲男人天堂av| 亚洲欧洲性图库| 最新日韩在线视频| 亚洲欧美在线视频观看| 国产欧美日韩一区二区三区在线观看| 精品国产欧美一区二区| 日韩一区二区三区观看| 制服丝袜成人动漫| 欧美日韩国产电影| 日韩西西人体444www| 91精品国产一区二区三区蜜臀| 欧美精品精品一区| 91.xcao| 日韩一区二区三区四区| 日韩黄色免费网站| 五月激情综合网| 亚洲免费观看高清在线观看| 欧美精品久久久久久久多人混战| 91麻豆123| 亚洲国产aⅴ天堂久久| 日本精品视频一区二区| 亚洲婷婷综合色高清在线| 欧美精品一级二级三级| 一区二区在线不卡| 亚洲女同一区二区| 国产日韩在线一区二区三区| 麻豆成人av在线| 丁香一区二区三区| 麻豆成人av在线| 成人性视频免费网站| 不卡在线观看av| 亚洲视频狠狠| 米奇777在线欧美播放| 91福利小视频| 91精品视频网| 国产欧美一区二区精品性色超碰| 国产精品久久网站| 午夜久久久久久久久| 国产一区二区三区不卡在线观看 | 国产麻豆精品theporn| 97久久精品人人澡人人爽| 一区在线电影|