写作data留学生编程、 辅导Python,Java编程

” 写作data留学生编程、 辅导Python,Java编程August, 2020 FinalQuestion 1. [20 marks]Implement the function int findHeightTree(PositionEntryV,K root); that computes the heightof a binary tree. The following functions are available for your use: PositionEntryV,K left(PositionEntryV,K root); This function Returns the reference to the left child of the input argument root. This value willbe NULL if root is a leaf node. PositionEntryV,K right(PositionEntryV,K root); This function returns the reference to the right child of the input argument root. This valuewill be NULL if root is a leaf node.The function findHeightTree takes in one argument (PositionEntryV,K root) which is the root ofthe tree. This function returns an integer indicating the height of the tree. You may not create any helperfunctions. You can only use recursion. If you are not sure about the definition of the height of a tree,write your assumption and carry on with the question.Page 2 of 12 contd. . .Examination EECS 2011public int FfindHeightTree(PositionEntryV,K root){}Page 3 of 12 over. . .August, 2020 FinalQuestion 2. [20 marks]Implement the function int maxVerticesTraversal() that computes the maximum vertices that can betraversed in a connected directed Graph. Consider the following diagram:For instance, starting from vertex 0, the total number of vertices that can be traversed is 6 (i.e. vertices0, 1, 2, 4, 3, 2, 5) whereas starting from vertex 3, you can traverse two vertices (i.e. 3 and 5). Hence,for this Graph the function should return the value 6. You may assume that the following definitions anddeclarations are provided to you: Queue ADT: LinkedListQueueVertexV LinkedListQueue(); Constructor of the queue void enqueue(VertexV u); Inserts into a queue VertexV dequeue(); Removes from the queue boolean isEmpty(); Checks if the queue is empty Graph ADT: IterableEdgeE outgoingEdges(VertexV u); Returns An iterable list of outgoing edges that are incident to u IterableVertexV vertices(); Returns an iterable list of vertices in the Graph int numVertices(); Returns the total number of vertices in the Graph VertexV opposite(VertexV v, EdgeE e); Returns the vertex that forms the edge e with vertex v Vertex Class: int getLabel(VertexV u); Returns the integer label associated with the vertex uHint: You may use breadth-first traversal from each vertex in the graph to compute the total number ofvertices traversed. You may not define additional helper functions.Page 4 of 12 contd. . .Examination EECS 2011public int maxVerticesTraversal(){}Page 5 of 12 over. . .August, 2020 Final.Page 6 of 12 contd. . .Examination EECS 2011Question 3. [20 marks]Implement a function boolean isCycle() that detects whether a cycle exists in a directed Graph. Thisfunction Will return true if there exists a cycle in the graph and false otherwise. You may assume thatthe following classes and functions are available to you: Stack ADT: LinkedListStackVertexV LinkedListStack(); Constructor of the stack void push(VertexV u); Inserts into a stack VertexV pop(); Removes from the stack boolean isEmpty(); Checks if the stack is empty Graph ADT: IterableEdgeE outgoingEdges(VertexV u); Returns an iterable list of outgoing edges that are incident to u IterableVertexV vertices(); Returns an iterable list of vertices in the Graph int numVertices(); Returns the total number of vertices in the Graph VertexV opposite(VertexV v, EdgeE e); Returns the vertex that forms the edge e with vertex v Vertex Class: int getLabel(VertexV u); Returns the integer label associated with the vertex uHint: You may Use depth-first search to identify cycles from each node in the Graph. You may not definehelper functions.Page 7 of 12 over. . .August, 2020 Finalpublic boolean isCycle(){}Page 8 of 12 contd. . .Examination EECS 2011.Page 9 of 12 over. . .August, 2020 Final[Use the space on this page for rough work. Indicate clearly any work you want us to mark.]Page 10 of 12 contd. . .Examination EECS 2011[Use the space on this Page for rough work. Indicate clearly any work you want us to mark.]Page 11 of 12 over. . .[Use the space on this page for rough work. Indicate clearly any work you want us to mark.]Page 12 of 12 Total Marks = 60 End of Final Examination如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导