Figure-Chapter 2-Analysis of exercises in data structure question set-yan Weimin Wu Weimin edition and Yan Weimin Wu Weimin

Source: Internet
Author: User
Tags comparison table


Figure-Chapter 2-Analysis of exercises in data structure question set-yan Weimin Wu Weimin edition and Yan Weimin Wu Weimin


Question set Parsing


Chapter 4 Diagram


-- Data Structure question set-yan Weimin. Wu Weimin


Source code instructions☛☛☛Data Structure-C language version (Yan Weimin, Wu Weimin version) Textbook source code + EXERCISE set parsing instructions


Textbook source code compilation Link☛☛☛Data Structure textbook source code compilation


Question set full resolution Link☛☛☛Analysis and compilation of data structure question set




Test data download link☛Data Packets




Directory where this exercise document is stored: Data Structure \ ▼ \ ▼ 07


Source code storage directory in this document: Data Structure \ FAQs supporting exercises \ picture 07 \ FAQs test documentation-07


Source code test Data storage directory: Data Structure \ FAQs supporting exercises \ picture 07 \ FAQs test documentation-07 \ Data




I. Basic knowledge questions

7.1 notice: The directed graph shown in the figure is known.


(1) The inbound/outbound degrees of each vertex;


(2) adjacent matrix;


(3) adjacent table;


(4) Inverse adjacent table;


(5) strongly connected components.


7.2 ❷ the adjacent matrix of the known directed graph is An X n. For example, A (k) n x n (k = ,..., N) What are their actual meanings?


7.3 draw an undirected graph of multiple adjacent tables, so that the first vertex number in each undirected edge node is smaller than the second vertex number, and the link sequence of each adjacent edge of each vertex is shown, the sequence number of the vertex adjacent to it is in the ascending order. Lists the sequence of vertices and edges obtained from traversing the graph by depth-first and breadth-first searches.


7.4 explain the undirected graph shown below, and draw the breadth of the graph to generate a forest first.


7.5 Notice shows the adjacent matrix of a graph that is known as a two-dimensional array. Draw the depth-first spanning tree and breadth-first spanning tree derived from vertex 1.


7.6 The internal test proves the correctness of the algorithm (deep Priority Search) for strongly connected components in section 7.4.2 of the textbook.


7.7 configure the undirected weighted graph,


(1) Write out its adjacent matrix and calculate its Minimum Spanning Tree Based on the prim algorithm;


(2) Write out its neighbor list and use the kacar algorithm to find its Minimum Spanning Tree.


7.8 skip the following example: Execute the algorithm to calculate the nodes of the undirected graph, and obtain the visited [I] and low [I] values of each vertex, I = ,..., Vexnum.


7.9 explain the test to list all possible Topological sequence sequences and point out which sequence is obtained by applying the Topological Sort Algorithm in section 7.5.1 (Note: Determine the storage structure first ).


7.10 explain for the AOE network shown in, calculate the e (ai) and l (aj) function values of each active arc, ve (vi) and vl (vj) of each event (vertex) function value. It lists all key paths.


7.11 Finally, the Dijkstra algorithm is used to find the shortest path from vertex a to other vertices and write the state of each step during Algorithm Execution.


7.12 verify that the Dijkstra Algorithm for Finding the shortest path is correct.


7.13 middleware uses the Floyd algorithm to find the shortest path between each pair of vertices in the directed graph.


Reprinted with the source: original article link




Ii. Algorithm Design Questions Adjacent table

7.14 compile an algorithm, and establish a directed graph's adjacent table based on the number of vertex input, the number of arcs, the information of each vertex, and the information of each arc.


Adjacent matrix


7.15 perform basic graph operations on the storage structure of the adjacent matrix: InsertVex (G, v), InsertArc (G, v, w), DeleteVex (G, v) and DeleteArc (G, v, w ).


Adjacent table


7.16 redo the 7.15 questions on the storage structure of the adjacent table.


Cross Linked List


7.17 redo the 7.15 questions on the storage structure of the cross linked list.


Joining multiple tables


7.18 million questions about the storage structure of multiple adjacent tables.


7.19 compile an algorithm to create an undirected graph of multiple adjacent tables based on the number of vertices, number of edges, information of each vertex, and information of each edge.


Adjacent matrix


7.20 The algorithm segment below explain can determine whether the graph G = (V, E) is passed: trans = TRUE; for (each x in V) for (N (x) in each y) for (N (y) is not equal to each z of x) if (z is not in N (x) trans = FALSE; where N (x) indicates the set of all vertices connected to x. We try to use the storage structure of the adjacent matrix to determine the passing ability of a graph and use the mean values of n = | V |, m = | E | and d = node degrees, estimated execution time.





Adjacent table

7.21 redo the 7.20 questions on the storage structure of the adjacent table.


7.22 first, we will try to write an algorithm based on the graph-based deep priority search policy to determine whether the directed graph stored in the form of an adjacent table has a path from vertex vi to vertex vj (I = j ). Note: basic operations on graphs involved in algorithms must be implemented in this storage structure.


7.23. Write an algorithm based on the graph-based breadth-first search policy.


Adjacent matrix


7.24 compile a trial using the basic operations of the stack to traverse a non-recursive algorithm of a strongly connected graph based on the deep-first search policy. The algorithm does not specify a specific storage structure, but regards Graph as an abstract data type.





Similar to an adjacent table

7.25 then assume that n vertices in the directed graph are naturally numbered, and the three arrays s [1... Max], fst [1... N] and lst [1... N. The array s stores the information of the successor vertex of each vertex, the successor vertex of vertex I is stored in the subscripts of vertex s from fst [I] to the component of lst [I] (I = 1, 2 ,..., N ). If fst [I]> lst [I], the I vertex has no successor vertex. Write an algorithm to determine whether a loop exists in the directed graph.


Adjacent matrix


7.26 if the vertex in the directed graph is numbered appropriately, the adjacent matrix of the vertex can be set to the bottom triangle and the main diagonal is completely zero. The necessary condition is that the directed graph does not contain loops. Then, write an algorithm to rename the vertex of the directed graph without loops, change its adjacent matrix to the bottom triangle, and output the comparison table of the old and new numbers.


Adjacent table


7.27 using the storage structure of the adjacent table, compile an algorithm for determining whether a simple path with k length exists between any given two vertices in an undirected graph (a simple path refers to a vertex without any reproduction in its vertex sequence. ).


7.28 explain know the directed graph and the two vertices u and v in the graph. Write an algorithm to find all simple paths from u to v in the directed graph, and manually execute your algorithm as an example, draw a search process diagram.


Adjacent matrix


7.29 then try to write an algorithm to calculate the number of non-loop paths from vertex I to vertex j in directed graph G stored in the form of an adjacent matrix with a length of k.


7.30 then try to write an algorithm for finding all simple circuits in directed graph G.


Cross Linked List


7.31 The middleware completes the algorithm for finding the strongly connected component of the directed graph and analyzes the time complexity of the algorithm.





Adjacent table

7.32 modify the prim algorithm to minimize the time complexity of generating a forest in the storage structure of the adjacent table (the storage structure of the forest is the Child-brother linked list ).


7.33 The edge set of the known undirected graph is stored in an EdgeSet data structure of the EdgeSetType type (without the ring edge with the fixed endpoint). Two basic operations have been defined in this structure:


(1) function GetMinEdge (EdgeSet, u, v): If EdgeSet is not empty, the smallest edge is required. The variable parameters u and v contain two vertices on the smallest edge, and true is returned; otherwise, false is returned;


(2) process DelMinEdge (EdgeSet, u, v): remove the smallest edge attached to vertex u and v from EdgeSet. In the above structure, we try to implement the cruise Karl Algorithm for Finding the smallest spanning tree (represented by the Child-brother linked list.


7.34 compile an algorithm to assign an integer serial number to each vertex in directed acyclic graph G. If an arc exists between vertex I and vertex j, the I <j.


7.35 if a vertex r exists in a directed acyclic graph (DAG), a directed path starting from r exists between all vertices in the r and graph, the DAG has a root. Write the algorithm for finding the root of the DAG graph.





7.36 increment adds an MPL field for each vertex in the graph's adjacent table storage structure. Write an algorithm to obtain the length of the longest path starting from each vertex of the acyclic graph G and store it in its MPL domain. Provide the time complexity of the algorithm.


7.37 design an algorithm for finding the longest path in a directed acyclic graph and estimate its time complexity.


7.38 explain a four arithmetic expressions are stored in an undirected graph adjacent table. each operand atom is represented by a single letter. Write an algorithm to output its inverse polish expression.


Binary linked list


7.39 rewrite the storage structure to a binary linked list and redo the 7.38 questions.


Adjacent table


7.40. If the operator and operand atom of question 7.38 are represented by characters and integers respectively, design the node type of the adjacent table and write an algorithm to evaluate the expression.


7.41 compile an algorithm to calculate the Key Path (CPM) using the depth-first traversal directed graph.


7.42 using the adjacent table as the storage structure, the Dijkstra algorithm is used to find the shortest path from the source point to the other vertices.







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.