CPSC_1160_Practice_Final_Exam

.docx

School

Langara College *

*We aren’t endorsed by this school

Course

1160

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

2

Uploaded by BailiffWildcat2224

Report
CPSC 1160 Algorithms and Data Structures I: Practice Final Exam Part 1: Multiple Choice Questions 1. Algorithm Complexity: What is the time complexity of a binary search algorithm in the worst case? A) O(n) B) O(log n) C) O(n log n) D) O(n^2) 2. Data Structures: Which data structure uses LIFO (Last In, First Out) principle? A) Queue B) Stack C) Linked List D) Array 3. C++ Syntax: Which of the following is the correct way to declare a dynamic array in C++? A) int* arr = new int[10]; B) int arr[10]; C) int* arr = int[10]; D) int arr = new int[10]; Part 2: Short Answer Questions 4. Recursion: Write a recursive function in C++ that calculates the factorial of a given number. 5. Algorithm Analysis: Explain the difference between time complexity and space complexity in algorithms. Part 3: Coding Problems 6. Sorting Algorithm: Implement the Merge Sort algorithm in C++. 7. Data Structure Implementation: Write a C++ program to implement a singly linked list with functions to add and delete nodes. 8. Advanced Coding Problem: Write a C++ program that uses a recursive function to find all the combinations of a given string.
Part 4: Theory Questions 9. Q1: Explain the concept of a binary tree and its applications. 10. Q2: Describe the process of memory management in C++ and the role of constructors and destructors. Instructions for the Exam Allocate time wisely to each section of the exam. For coding problems, ensure that your code compiles and runs as expected. Provide clear and concise answers for theory and short answer questions. Check your work for errors before submitting the exam.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help