JAVA graph data structure ghostwriting, graph program traversal algorithm ghostwriting

JAVA graph data structure ghostwriting, graph program traversal algorithm ghostwriting
problem 1
Suppose we have a large computer network all over the country, which can be connected by network fiber links. Some of these links are already built. Every potential new link has a cost associated with building it. We want to know the cheapest way to connect all computers to a single network. i.e.
V is a set of n vertices (servers)
E is a set of m undirected edges between vertices in V
A ? E is a subset of edges already constructed The
cost c for each remaining edge ∈ V \ A ( e) > 0
problem: choose a minimal weight subset X ∪ A such that the graph (V, X ∪ A) is connected


Figure: Solid lines represent existing fiber optic links, while dashed lines represent potential links that may be constructed.

Your task is to design an efficient algorithm to solve this problem. Suppose the graph is stored as an adjacency matrix.
Your solution must include

(i) An efficient algorithm for the optimal solution of the above graph
(ii) Briefly explain how your algorithm works and why your algorithm is correct (10 points)
(iii) Analyze the upper bound on the time complexity of the algorithm (10 points)


Question 2 (40 points)

An alphabet is a finite set of symbols, and a letter (an alphabet) is a finite sequence of symbols in that alphabet. For example, 1100 is a word on the letters {0,1} and abba is a word on the letters {a,b,c}. If w is a word, we denote the total number of symbols in w by |w|, so |abba|=4.
A code is a mapping from characters in the source alphabet to characters in the target alphabet. For example
C = {a → 0, b → 10, c → 110}

is a code with source alphabet {a,b,c} and destination alphabet {0,1}. Another example is Morse code, with English letters (and numbers) as the source alphabet and {?, -} as the destination alphabet.
A code naturally defines a mapping from words on the source alphabet to words on the target alphabet, by replacing each symbol in the source word with its corresponding codeword. We call it encoding. For example, the code C above encodes the word abba as 010100. For simplicity, we write it as C(abba) = 0101000. Decoding is the inverse of encoding

- That is, given a word w about the target alphabet, find a word u in the source alphabet such that C(u) = w. Note that depending on the code, there may be multiple valid decodings, or even none.

(a) Using the code C above, find words on {0,1} that have no valid decoding,

Lossless codes are codes where each word on the target alphabet is decoded at most once. For example, Morse code is not lossless because the same word can be decoded as A or ET. A natural way to generate lossless code is to map each source symbol to some fixed-length word. For example, ASCII codes map commonly used alphanumeric symbols to 7-bit words (i.e. words on {0,1} of length exactly 7).

(b) Suppose C is a (lossless) fixed-length code that can be used to map letters of symbol size 27 (i.e. 26 letters of the English alphabet together with spaces) to words {0,1} on the target alphabet. The encoded word has a certain length k. What is the minimum fixed length k? In other words, what is the minimum number of digits required to encode each of the 26 letters of the English alphabet with spaces. (5 points)

(c) Suppose C is a (lossless) fixed-length code that maps symbols in A to words of fixed length k in B. Find the lower bound of k in terms of |A| and |B|. (5 points)

The rationale behind data compression is to view data as a word (e.g. a piece of text is a [very long] alphanumeric string) and design a lossless encoding C such that for a typical data word w we have |C(w )|<|w|. The key word here is typical - it's not possible to compress every word of data, so in order to achieve compression we need to do some additional analysis. A typical approach is frequency analysis: by using fewer target symbols to encode more frequently occurring source symbols, you will end up using fewer symbols on average.

A greedy method for designing lossless data compression codes (from English alphabet to binary) is as follows:

1. Map the most frequent symbol (i.e. 'space') to the shortest binary word (i.e. '0')

2. Map the second most frequent symbol (ie 'E') to the second shortest binary word (ie '1')
3. Map the third most frequent symbol (ie 'T') to the third shortest binary word (ie '00')
4. Wait...

(d) Does this greedy algorithm work? Explain why it is/is not suitable for solving data compression problems. (10 points)
To overcome the difficulties highlighted in the previous question, a common approach is to use prefix codes: no target code word in a code is a prefix of another code. For example, the code used at the beginning,
C = {a → 0, b → 10, c → 110},
is the prefix code; while the code

C'= {a→0,b→10,c→101}

No, because 10 is a prefix of 101.
(e) Given a source alphabet A = {a, b, c, d, e} and a target alphabet B = {0, 1}, design an algorithm to find prefix codes C that map A to words on B . Answers must include the following:

(i) Briefly describe the algorithm and explain why it works (10 points)

(ii) Use the designed algorithm to give a prefix code C that maps A to a word (5 tokens) on B
(using a binary tree data structure!!!!)
Problem 3 (30 points):
Let A be a Array of n numbers (positive and negative). Develop a divide-and-conquer algorithm that finds two indices 1≤i≤j≤n such that Σ (the sum of elements from i to j) is maximized. For example, in matrix A=[10,-1,2,5,7,-2,4,-11], subarray A[3:6] has sum 5+7-2+4=14 and nothing else The subarray contains elements whose sum is a value greater than 14, so for this input the algorithm should output (3,6). Design an algorithm to solve this problem
(i) Write down the pseudocode of the algorithm (20 points).

(ii) Briefly describe the running time of the algorithm (10 points).
http://www.6daixie.com/contents/9/1365.html

The core members of the team mainly include Silicon Valley engineers, BAT front-line engineers, top 5 master and doctoral students in China, and are proficient in German and English! Our main business scope is to do programming assignments, course design and so on.

 

Our field of direction: window programming, numerical algorithm, AI, artificial intelligence, financial statistics, econometric analysis, big data, network programming, WEB programming, communication programming, game programming, multimedia linux, plug-in programming program, API, image processing, embedded/MCU database programming, console process and thread, network security, assembly language hardware Programming software design engineering standards and regulations. The ghostwriting and ghostwriting programming languages ​​or tools include but are not limited to the following:

C/C++/C# ghostwriting

Java ghostwriting

IT ghostwriting

Python ghostwriting

Tutored programming assignments

Matlab ghostwriting

Haskell ghostwriting

Processing ghostwriting

Building a Linux environment

Rust ghostwriting

Data Structure Assginment

MIPS ghostwriting

Machine Learning homework ghostwriting

Oracle/SQL/PostgreSQL/Pig database ghostwriting/doing/coaching

web development, website development, website work

ASP.NET website development

Finance Insurance Statistics Statistics, Regression, Iteration

Prolog ghostwriting

Computer Computational method

 

Because professional, so trustworthy. If necessary, please add QQ: 99515681 or email: [email protected]

WeChat: codinghelp

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325357548&siteId=291194637