Algorithm 算法作业



You are given n strings s1, s2, · · · , sn and q queries. In i th query, you are given a string ti , please find

out how many strings in s1, s2, · · · , sn begins with ti .

Football Match

While the FIFA World Cup is being held in Qatar, BLGG is organizing a football tournament in LGU,


There are n teams in this tournament, numbered from 1 to n. Each team has its popularity, and the

popularity of team i is ai . A match between i and j will gain ai × aj MOD M attractions.

When a football team loses a match, it will be eliminated from the tournament. At the end, the team

left standing will be the champion of this tournament.

BLGG is wondering that what the maximum sum of the attractions of the (n 1) matches.

Median Search Tree

If the sorted array of all the values in the set is {ai} n

i=1, let t = n/2, then the median 2k values are

{atk+1, · · · , at+k}.

Barbara has got a set of values with size of 2k initially. Barbara wants to do m operations on it. Each

operation belongs to the following 3 types:

  • 1 w: insert a value w.
  • 2: output all the median 2k values, i.e. atk+p, 1 p 2k.
  • 3 p: delete the p-th value among median 2k values, i.e. atk+p.

We guarantee that all the values will be distinct and the size of the set is always at least 2k.

Special Shortest Path

City C consists of n nodes, representing different places. There are m edges between these nodes. For

the edge ei = (ui , vi , wi), there is a bidirectional(undirected) trail connecting ui and vi with length of

wi .

For a path P = {pi}, consisting of edges p1, p2, p3, · · · , pk, the length of each edge is li = wpi . Normally,

passing the edge pi with length li will cost li units of energy. Specially, if li = K · li1, then passing

this edge will only cost (K 1) · li1 units of energy.

Alice is starting from the node 1. Alice wants to know how many units of energy it will take at least

to visit the node x, for any x. If x is unreachable from the start point(node 1), you should output 1

as the result.

Chess Game

The program should respect the rules of chess, for example,

  • the movement of pieces (including castling and en-passant),
  • piece promotion, check
  • checkmate
  • stalemate

Please review the rules of chess to verify your understanding of the game!

  • You can implement your system on any platform and language you want as long as

it is available in our labs (can be run in our labs). You may have to show me/TA

how it works in some cases.

  • The program must use a game tree search scheme with alpha-beta pruning.

Furthermore, the program should permit user-supplied control parameters, for

example, the depth of search.

  • Put effort towards designing an effective board evaluation function. You should

research the literature on computer chess to find strategies used by other systems.

You can borrow ideas from the literature (properly acknowledged in your report).

I also encourage you to try your own ideas!

  • The program should interact with a human player. Both human vs human and

human vs ai options should be available. Moves should be given via board

coordinates. At the minimum, the program should dump out the current board as an

ASCII table (e.g., upper case = black, lower case = white, space = “-“,). Although

a graphical user interface is not required, an effective GUI will be positively

considered during evaluation.

  • Your program should permit any board setup to be used initially (This is good for

testing purposes).

  • An option is that your program should dump out the game in terms of a standard

chess output text file.

java maze solver

Due Date

Monday, April 20th, at 5:30pm

Important: This is an individual assignment. Please do not collaborate.

No late assignment will be accepted.

Make sure that you write every line of your code. Using code written by someone else will be considered a violation of the academic integrity and will result in a report to the Dean’s office.

Minimal Submitted Files

You are required, but not limited, to turn in the following source files: (You do not need to modify this file.) — complete this file. (You do not need to modify this

unmanned lawn mowers c程序代写

代写c程序 二维数组 指针 内存申请与释放

dfs recrusive 遍历所有路径

// ~ Overview ~ //

This exercise will familiarize you with 2-dimensional arrays and
some more file operations.

// ~ Learning Goals ~ //

(1) To learn to perform file operations
(2) To learn to create and manipulate 2-dimensional arrays using
malloc and free function.
(3) To apply recursion to solve a maze traversal problem
// ~ Submitting Your Assignment ~ //

You must submit one zip file to blackboard. This zip file must

(1) pa_answer02.c
(2) pa02.c

You create the zip file using the following command.

> zip pa_answer02.c pa02.c

// ~ Overview ~ //

This exercise will give you more practice with file operations,
memory allocation, and recursion.

You own a business that performs mowing using unmanned lawn mowers
(ULM). Suppose you have just agreed to a contract to provide mowing
service to a corn maze operator. Based on a pre-processed satellite
images of corn maze, where the walls of the corn maze are stored as ‘X’ and
the paths are store

c语言扫雷游戏 minesweeper实现

minesweeper C 程序代写

1. (Time: 2 – 3 hours) For your final project you will be implementing the computer

game minesweeper. The game of minesweeper works as follows:

1. There is a rectangular grid of tiles

2. Hidden under some of the tiles are mines

3. Your goal is to mark all the tiles that contain mines and uncover all the tiles

4. If you uncover a tile that contains a mine you lose the game

5. If you uncover a tile that doesn’t contain a mine, it tells you how many mines

that don’t contain mines

are hidden in the eight surrounding squares

Here are some example boards with all of their contents revealed so that you can get an

idea as to what they look like.

Example 1:

2 * * 2 0

1 5 * 3 0

0 * * 2 0

0 1 2 3

Example 2:

9 0 0 0 0 0 1 1 1 0 0

8 0 0 0 0 0 1 * 1 0 0

7 0 1 1 1 0 1 1 2 1 1

6 0 1 * 1 1 1 1 1 * 1

5 0 1 1 1 1 * 1 1 1 1

4 1 1 1 0 1 1 1 0 0 0

3 1 * 1 0 0 0 0 0 0 0

2 1 1 1 0 0 0 0 0 0 0

1 1 2 1 1 0 1 1 2 2 2

0 * 2 * 1 0 1 * 2 * *

0 1 2 3 4 5 6 7 8 9


1. Name your exe