Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CMSC 132 Final Exam Review With 100% Correct And Verified Answers, Exams of Advanced Education

A comprehensive review of the cmsc 132 final exam, covering a wide range of topics related to computer science and software engineering. It includes detailed explanations and correct answers to various questions, addressing concepts such as software project failure, program life-cycle, program verification, binary search trees, heaps, algorithmic complexity, graph traversal, inner classes, exceptions, and sorting algorithms. The document aims to help students prepare for the cmsc 132 final exam by providing a thorough understanding of the key topics and their applications.

Typology: Exams

2023/2024

Available from 08/27/2024

Qualityexam
Qualityexam 🇰🇪

2.5

(4)

2.7K documents

1 / 5

Toggle sidebar

Related documents


Partial preview of the text

Download CMSC 132 Final Exam Review With 100% Correct And Verified Answers and more Exams Advanced Education in PDF only on Docsity!

CMSC 132 Final Exam Review With 100%

Correct And Verified Answers

What is the main reason software projects fail? - Correct Answer-Complexity of projects What is the program life-cycle? - Correct Answer-Problem Specification, Program Design, Algorithms and Data Structures, Coding and Debugging, Testing and Verification, Deployment, Documentation and Support, Maintenance and Upgrades True/False: Compared to program verification, empirical testing... - Correct Answer-a) Handles larger programs (True) b) Always catches more errors (False) c) Ensures code is correct (False) d) Can be applied without examining code (False, but maybe True?) True/False: According to the unified model... - Correct Answer-a) Design all algorithms before coding (False) b) Write test cases before coding (False) c) Use a prototype implementation to refine design (True) True/False: According to the Waterfall model... - Correct Answer-a) Design all algorithms before coding (True) b) Write test cases before coding (False) c) Use prototype implementation to refine design (False) What is the key property of a binary search tree? - Correct Answer-Has 0-2 children per node On average, what is the (algorithmic) complexity of doing an insertion in a binary tree? - Correct Answer-O(log(n)) On average, what is the (algorithmic) complexity of doing a find in a binary tree? - Correct Answer-O(log(n)) What is the worst case complexity of doing a find in a Binary Search Tree? - Correct Answer-O(h), where h is the height of the tree What can cause worst-case behavior in a binary tree? - Correct Answer-Degenerative trees. Meaning that, the data being entered into the tree is already in order, leading to a sorted Linked List. Inserting 10,20,30,40,50,... will lead to a single "column"? tree that leads to a very large tree height

What is a tree traversal - Correct Answer-The process of finding all the nodes in a Tree, and determining ther relationship What is the difference between a depth-first and breadth-first traversal? - Correct Answer-Breadth-first visit closer nodes first. Depth-first has three modes: Preorder - parent > left child > right child Inorder - left child > parent > right child Postorder - left child > right child > parent Pre-order traversals are faster than post-order traversals, T or F - Correct Answer-F Preorder, Inorder and Postorder are all O(n) What are the two key properties of a heap? - Correct Answer-Complete (Balanced) Binary Tree, Value at Node What operation(s) supported by binary search trees are not supported by heaps? - Correct Answer-Find any value. For BSTs it's either O(log(n)) for balanced trees or O(n) for degenerate trees. Heaps can only readily provide Min or Max values On average, what is the complexity of doing an insertion in a heap? - Correct Answer- O(log(n)) On average, what is the complexity of doing a find in a heap? - Correct Answer- O(log(n)) What is algorithmic complexity? - Correct Answer-Amount of resources required by algorithm with respect to problem size List a reason benchmarking is better that analyzing complexity - Correct Answer- Precise information for given configuration Implementation, hardware, inputs details What is the difference between best case, worst case, and average case? - Correct Answer-Best case: Smallest number of steps required Worst case: Largest number of steps required Average case: typical number of steps required What does big O notation represent? - Correct Answer-Big O notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity.

Describe the difference between a directed and undirected graph - Correct Answer-An Undirected graph is a graph in which the veritcies are connected bidirectionally. A Directed graph is a graph in which the vertices are connected unidirectionally Describe the difference between a path and a cycle - Correct Answer-A cycle is a closed path, starts and ends at the same vertex. A path starts and ends at different vertices Describe two methods of storing edges in a graph - Correct Answer-Adjacency Matrix (2D array) and Adjacency List/Set/Map Why is graph traversal more difficult than tree traversal? - Correct Answer-Many-to- many relationship between elements Multiple predecessors, multiple successors Describe the difference between a breadth-first and depth-first traversal of a graph - Correct Answer-Bread-First (BFS) will visit all adjacent neighbor nodes before proceeding further through the graph Depth-First (DFS) will visit all nodes with a path until the current path ends, and then back tracks to traverse other paths What are inner classes? - Correct Answer-Classes defined in scope of another class, should not have any static members. Outer and Inner classes can directly access each other's fields and methods What are nested classes? - Correct Answer-Inner classes, Local Classes, Anonymous Classes, Static Classes When should inner classes be used? - Correct Answer-When a provate helper class is needed, when there exists a need to hide data while also being able to access said data within a class When should anonymous classes be used? - Correct Answer-When you only need to create a single instance of a class for use. What relationship exists between lambda expressions and anonymous inner classes? - Correct Answer-In some cases Lambda expressions can be used instead of an anonymous class. Instead of declaring an anonymous class with an accompanying method, a lambda expression can skip straight to the return statement of whatever method would have been defined with an anonymous class. True or False: All non-static initialization blocks are executed when objects are created.

  • Correct Answer-True

True or False: If no visibility modifier is specified, methods are private by default - Correct Answer-False, (Package-Private) True or False: Protected access is less visible than package access - Correct Answer- False What are the advantages of using Generics? - Correct Answer-Allows the user to use the same code for different data types What is a Lambda expression? - Correct Answer-A concise approach to define an anonymous class instance. Compiler treats a lambda expression as an object created from an anonymous class. What property must an interface have in order to be used with a Lambda expression? - Correct Answer-Must be a functional interface (only 1 method) What are exceptions - Correct Answer-Rare event outside normal behavior of code. Usually a run-time error How are exceptions used in Java? - Correct Answer-Exceptions are represented as an Object derived from the class Throwable. Instructions for handling exceptions can be specified in a try-catch block What are some differences between Checked and Unchecked Exceptions? - Correct Answer-Unchecked: Serious errors not handled by typical problem. Errors are your fault. Most likely logic errors. Checked: Errors typical program should handle. Used for Operations prone to error. Examples: IOexception, ClassNotFoundException. What is a comparison sort? - Correct Answer-An algorithmic sorting strategy that iterates through a data structure and compares two nodes at a time. Nodes can be <, =,

. Depending on the algorithm, the sort will cycle back to sort again What is a stable sort? - Correct Answer-When the relative order of equal keys remains unchanged What is an in-place sort? - Correct Answer-uses only constant additional space. Generally, produces an output in the same memory that contains the data What is an external sort? - Correct Answer-An external sort is required when the data being sorted does not fit into the main memory Sort complexity: bubble sort - Correct Answer-O(n^2) Sort complexity: heap sort - Correct Answer-O(nlog(n))

Sort complexity: Quick sort - Correct Answer-O(nlog(n)) Sort complexity: Counting Sort - Correct Answer-O(n) WORST-case complexity: Selection Sort - Correct Answer-O(n^2) WORST-case complexity: Tree Sort - Correct Answer-O(n^2) WORST-case complexity: Heap Sort - Correct Answer-O(nlog(n)) WORST-case complexity: Radix Sort - Correct Answer-O(n) Can the following sorts be performed in a stable manner? Bubble Sort Quick Sort Counting Sort - Correct Answer-Bubble Sort - yes Quick Sort - no Counting Sort - yes Can the following sorts be performed using an in-place algorithm? Selection Sort Tree Sort Merge Sort - Correct Answer-Selection Sort - yes Tree Sort - no Merge Sort - no What is divide and conquer? - Correct Answer-Divide problem into smaller sub- problems, Solve each problem recursively, Combine solutions to solve problem