資料結構與演算法
國立中興大學 2025 · 考試 · 26 題 · 限時 100 分
整卷連續作答,作答時答案與解析隱藏;按「交卷」後揭曉正解、標準解析並自動批改(申論/計算題不計分,供自行對照)。
- 第 1 題選擇
(3 points) Which of the following sorting algorithms is considered a non-comparison-based sort?
- 第 2 題選擇
(3 points) Which of the following sorting algorithms has the best worst-case time complexity?
- 第 3 題選擇
(3 points) You are designing a program to compute the maximum achievable value from a limited set of resources with constraints. Which of the following techniques would you use to solve this problem most efficiently?
- 第 4 題選擇
(3 points) Given a weighted directed graph with potential negative edge weights, which of the following algorithms would you use to compute the shortest path from a single source to all other vertices?
- 第 5 題選擇
(3 points) Consider the following statements about NP-complete problems:
- Every NP-complete problem is also in NP.
- If an NP-hard problem is in NP, it is NP-complete.
- All NP problems can be reduced to an NP-complete problem in polynomial time.
- The Halting Problem is an NP-complete problem.
Which of the above statements are true?
- 第 6 題選擇
(3 points) Given the text "abcdefg" and the pattern "bcd", which algorithm would use hashing to compute the index of the first match efficiently?
- 第 7 題選擇
(3 points) What is the result of sorting the array in ascending order using Merge Sort?
- 第 8 題選擇
(3 points) Consider the following array of positive integers representing the value of items: values , and their corresponding weights: weights . You are given a knapsack with a maximum capacity of 9 units. Using dynamic programming, calculate the maximum total value you can achieve by selecting items such that their total weight does not exceed the capacity.
- 第 9 題選擇
(3 points) Which of the following best describes how Depth-First Search (DFS) detects a cycle in a directed graph?
- 第 10 題選擇
(3 points) Which of the following statements about topological sorting in a directed acyclic graph (DAG) is true?
- 第 11 題選擇
(3 points) Which of the following operations typically takes time in an array-based stack implementation?
- 第 12 題選擇
(3 points) In a linked list, what is the main advantage of using a doubly linked list over a singly linked list?
- 第 13 題選擇
(3 points) If you have a binary search tree (BST) containing the numbers 1 through 100, which element's search time would be the shortest (assuming balanced distribution)?
- 第 14 題選擇
(3 points) Which of the following data structures is best suited for implementing the undo operation in a text editor?
- 第 15 題選擇
(3 points) Consider a hash table implemented with open addressing (linear probing). If the load factor is close to 1, which of the following is most likely to occur?
- 第 16 題選擇
(3 points) When inserting a key into a B-Tree node that is already full, which operation occurs first to maintain the B-Tree properties?
- 第 17 題選擇
(3 points) What is the time complexity for insertion in a Red-Black Tree?
- 第 18 題選擇
(3 points) After inserting a new node into a Red-Black Tree, which of the following operations might be performed to restore Red-Black properties?
- 第 19 題選擇
(3 points) In an array-based circular queue, how do you check if the queue is full?
- 第 20 題選擇
(3 points) Which data structure is commonly used to implement breadth-first search (BFS) on graphs?
- 第 21 題計算
(5%) You are given the following set of activities, where each activity has a start time and an end time. Your task is to select the maximum number of non-overlapping activities that can be scheduled.
Activity Start Time End Time A 1 3 B 2 5 C 4 6 D 6 8 E 5 7 F 8 9 Using a greedy algorithm, compute the maximum number of non-overlapping activities that can be selected.
- 第 22 題計算
(5%) Given the array , perform two passes of the Bubble Sort algorithm in ascending order (smallest number comes first). What is the resulting array after these two passes?
- 第 23 題計算
(5%) You are given the sequence of integers 15, 10, 20, 8, 12, 17, 25, 19 to insert into an initially empty binary search tree (BST). After constructing the BST:
I. Delete the node with value 20 and replace it with its in-order successor. II. Perform a post-order traversal of the updated BST.
What is the resulting post-order traversal of the BST after the deletion?
- 第 24 題計算
(5%) Using Kruskal's algorithm, calculate the total cost of the minimum spanning tree (MST) for the graph shown.
The graph has vertices with the following weighted edges: , , , , , , .
- 第 25 題計算
(10%) Consider a binary min-heap represented by the array , where the element 1 is at the root. Suppose you need to insert a new element, 4, into this min-heap. Describe the complete insertion process step-by-step. Your answer should include:
- Indicating where the new element is initially placed in the array.
- Explaining the heapify-up (or bubble-up) process in detail, showing each intermediate state of the heap after any necessary swaps.
- Presenting the final min-heap array once the insertion is complete.
Make sure to clearly justify the steps taken and the reasoning behind each comparison and swap, based on the fundamental properties of a min-heap.
- 第 26 題申論
(10%) Design and describe the implementation of a dynamic array-like container that can grow as elements are added, without requiring a fixed size to be declared at initialization. Your explanation should include:
- Memory Management: How do you allocate and deallocate memory for the underlying storage? What functions or mechanisms would you use to manage this memory dynamically?
- Capacity Expansion Strategy: When the container runs out of capacity as new elements are inserted, how do you decide to increase its size? Discuss the growth factor and the trade-offs it involves in terms of memory usage and performance.
- Indexing Operations: How can you ensure random access to elements by index? What data structure or access method do you use to guarantee this?
- Insertion and Deletion Complexity: What is the expected time complexity for inserting and deleting elements at arbitrary positions, and how does this scale as the size of the container grows? Address the concept of amortized complexity and explain why it might differ from the worst-case scenario.