商业通讯
请输入关键词
  • 首页
  • 资讯
  • 科技
  • 财商
  • 汽车
  • 家电
  • 生活
首页 > 科技

CS 1501代做、代写Python/Java程序设计

发布于:2024-04-08 08:30:39 来源:互联网

CS 1501代做、代写Python/Java程序设计
Support for Assignment 4
CS 1501
Sherif KhattabGeneral Hints
• You can get the number of vertices using ag.getAirports().size(), whereby 
ag is an AirlineGraph object
• Iterate over airports using for(String airport: ag.getAirports()){ … }
• You can get a unique integer for each airport in the graph using the 
ag.getAirportNo() method
• You can retrieve the set of neighbors of an airport using 
ag.adj(airportName)
• To iterate over the set of neighbors: for(Route r: ag.adj(airportName)){ … }
• You can retrieve the name of a neighboring airport using r.destination
• You may use HashSet to instantiate Set objectsfewestStops
• Use BFS
• check the pseudo-code in lecture notes
• Shortest path Source -> transit -> destination can be found by
• shortest path source  transit
• shortest path transit  destination
• concatenate the two shortest paths
• Be careful not to add transit twice to the concatenated pathConnected Components
• Use BFS
• You can find the pseudo-code in the lecture notesallTrips
• Use backtracking and pruning
• Define a recursive helper method: solve(current decision, current solution)
• current decision  current vertex (int or String) • current solution
• Set<ArrayList<Route>> of trips found so far
• current path: ArrayList<Route>
• total price so far of current path
• number of stops so far of current path
• destination, budget and max number of stops for comparison
• Inside the recursive helper method:
• if current vertex is the destination  add current path to the solution set and return
• iterate over all possibilities (unmarked neighbors)
• check if you can add the neighbor to the current path (total price won’t exceed budget and total number of stops won’t exceed maximum stops)
• if so, mark neighbor, update current path, its price, and its number of stops. 
• make a recursive call on the neighbor
• undo changes to current path, price, and number of stops and unmark neighbor
• mark start airport before calling solve the first timeallRoundTrips
• Use backtracking and pruning
• Define a recursive helper method: solve(current decision, current solution)
• current decision  current vertex (int or String) • current solution
• Set<ArrayList<Route>> of trips found so far
• current path: ArrayList<Route>
• total price so far of current path
• number of stops so far of current path
• budget and max number of stops for comparison
• Inside the recursive helper method:
• if current vertex is the source and stops so far > 0  add current path to the solution set and return
• iterate over all possibilities (unmarked neighbors)
• check if you can add the neighbor to the current path (total price won’t exceed budget and total number of stops won’t exceed maximum stops)
• if so, mark neighbor, update current path, its price, and its number of stops. 
• make a recursive call on the neighbor
• undo changes to current path, price, and number of stops and unmark neighbor
• Don’t mark start airport before calling solve the first time

请加QQ:99515681  邮箱:99515681@qq.com   WX:codinghelp

上一篇:COMP9334代做、代写Python设计程序

下一篇:CPT408代写、代做Java,Python程序

热门文章

  • 福特电动车卖不动?只有一半汽车经纪明年想卖纯电动车

    2023-12-23
  • 春节将至,河南致信返乡人员:期盼你们返乡创业就业,在外学到的知识带回来,献计献策!

    2024-01-12
  • 新政落地后首周北京二手房日均成交量上涨11%

    2023-12-23
  • 独行侠首节44分!兰德尔:欧文定下了基调 我们的防守没存在感

    2024-01-12
  • 周口城投城市运营丨聚焦城市发展 彰显国企担当

    2023-12-23
  • 东芝退市折射日企创新困局

    2023-12-23

本站部分文字及图片均来自于网络,如有侵权请及时联系删除处理

Copyright ©2023-2024 商业通讯.Powered by © hubeizhichuang.com