CMSC132 Partial Solutions to Final Exam Practice Questions Problem 1 Software Engineering Object Oriented Design A Software Development and Testing a Software is difficult because programmers are slow b Software life cycle refers to how software is used c Problem specification is a component of software development d Problem specification is less important than program testing e Iterative development is a software development methodology f Black box testing is usually easier than clear box testing g Integration tests are usually more important than unit tests h Test coverage includes consideration of lines of code tested i Test drivers are only found on NASCAR training tracks T or F T or F T or F T or F T or F T or F T or F T or F T or F B Object oriented design a State behavior and identity are the main qualities of objects T or F b Object oriented design produces faster programs T or F c List two main principles of object oriented design Abstraction encapsulation d Inheritance describes a relationship between classes T or F e Inheritance discourages code reuse T or F f Extension is a form of inheritance T or F C Object oriented design II Given the following problem description produce an objectoriented solution Answer the following questions about your object oriented solution Design a simulation of a basketball conference Each conference has 10 teams Each team has 12 players Each player has a specific height speed and accuracy Players know which team they belong to Some players are scholarship players Scholarship players need to record their current grade point average Players may be transferred between teams Teams play basketball games against other teams in the conference The result of each game is determined using a function based on the height strength speed and accuracy of the players on each team a What are the objects in your object oriented solution Conference Team Player ScholarshipPlayer b What are the interactions between your objects Play Game Transfer c Which objects have other objects Also list target object Conferences have Teams Teams have Players d Which objects use other objects Also list target object None e Which objects are other objects Also list target object 1 ScholarshipPlayers are Players f Draw a UML diagram of your solution Conference myTeams 10 Team Player myPlayers 12 Player myTeam Team height speed accuracy playGame transfer 10 Team 1 12 ScholarshipPlayer GPA Problem 2 Algorithmic Complexity D Algorithmic complexity a What is algorithmic complexity Amount of resources required by algorithm with respect to problem size b List a reason benchmarking is better than analyzing complexity Measures performance for a particular hardware c What is the difference between best case worst case and average case Minimum maximum and typical number of steps required by algorithm d What does the Big O notation represent Upper bound on the number of steps required by algorithm e Why are O n2 and O n not considered equivalent The number of steps required by each algorithm grows at a different rate with respect to the problem size E Finding critical regions Calculate the asymptotic complexity of the code snippets below using big O notation with respect to the problem size n a for i 0 i n i i 2 for j 1 j n j f n O nlog n b for i 0 i n 2 i for j 0 j n j j 2 for k 1 k 5000 k k 5 f n O n2 2 for j 0 j 1000 n j j 1 for j 0 j n 5 j j 5 Problem 3 Data Structures and Recursion F Taxonomy properties a Describe the main difference between linear and hierarchical data structures Single successor vs multiple successors b What is the key property of a binary search tree Smaller values in left subtree larger values in right subtree c On average what is the complexity of doing an insertion in a binary search tree O log n d Pre order in order and post order are all depth first traversals T or F e What operation s supported by binary search trees are not supported by heaps find n f What is the difference between a set and a map Maps have keys to their elements g What happens when an open addressing hash table is close to full Operations take more steps h Describe the 2 main parts of a recursive algorithm Base case and recursive step Problem 4 Graph Algorithms G Properties a Describe the main difference between hierarchical and graph data structures Single predecessor vs multiple predecessors b Describe the difference between a directed and undirected graph Edges are one way or bi directional c Describe the difference between a path and a cycle Cycle returns to its starting node d Describe two methods of storing edges in a graph Which requires more space Edge list adjacency matrix Space usage depends on Edge Node ratio of graph H Traversals a Why is graph traversal more difficult than a tree traversal May encounter cycles b Describe the difference between a breadth first and depth first traversal of a graph 3 Breadth first visits closer neighbors first depth first finishes exploring all reachable nodes from current node first c Given the following Java class definition for a graph public class MyGraph E public class Node E E myValue boolean tag ArrayList Node myNeighbors ArrayList Node myNodes void visitNode Node n Action to be performed when traversing node void deptFirstSearch Node n Perform depth first search of graph starting at n i Write code for the method depthFirstSearch n that performs a depth first traversal starting at node n ii Write code for the method breadthFirstSearch n that performs a breadth first traversal starting at node n I Minimum spanning trees a What is a spanning tree Tree connecting all nodes in graph no cycles n 1 edges b Describe Kruskal s algorithm for finding minimum spanning trees Sort edges by weight continue adding remaining edge with lowest weight if does not create cycle until spanning tree formed c Describe Prim s algorithm for finding minimum spanning trees d Describe two methods for finding connected subgraphs Traverse graph looking for cycle or track connected subgraphs e Consider the following graph Using both Prim s and Kruskal s algorithm calculate the minimum spanning tree listing edges in the minimal spanning tree in the order they are added to the tree Kruskal E H B F E G D E D F C G S A A D 4 C 16 S 10 A 12 14 9 13 5 G E 6 7 D 8 B 15 3 F 4 H 11 J Single source shortest path a Describe Djikstra s algorithm for finding shortest paths in a graph Maintain set of nodes with known shortest path from start and their costs predecessors
View Full Document
Unlocking...