• 沒有找到結果。

Answer the following short questions about binary search tress

N/A
N/A
Protected

Academic year: 2021

Share "Answer the following short questions about binary search tress"

Copied!
2
0
0

加載中.... (立即查看全文)

全文

(1)

1. Binary search trees find their widely use in many applications. Answer the following short questions about binary search tress. ( 2 O % )

(a) Define a binary search tree. (5%)

(b) Using data sequence: (40, 20, 60, 10, 30, 50, 70, 45, 55, 521, construct a binary search tree. (5%)

(c) Write a recursive search function for binary search trees, assuming that the input arguments are the root pointer and an integer key. The return value is the pointer of the node containing the key or null. (5%)

(d) Explain how t o use binary search trees to sort sequences. What is the time coinplexity of it? (5%)

2. Queues and priority queues are two widely used data structures. Answer the following short questions. (20 d/b)

(a) Describe the differences between queues and priority queues. (5%) (b) Define a min-priority queue. (5%)

(c) What are the time complexities of insertion and deletion operations when a min- prority queue is represented in terms of the following data structures: a n unordered array, an unordered linked list, a sorted array, a sorted linked list, and a rnin heap?

(10%)

3. Answer the followillg two short questions about stack and min-priority queue. ( ( I=, %)

(a) T h e stack is also a data structure. Describe its main features. (5%)

(b) Can a inin-priority queue be used as a stack? If yes, please explain how to do this.

(5%)

(2)

4. (20%)

(a) Briefly explain the hashing technique and discuss its advantages. (5%)

(b) Discuss the advantages and disadvantages of the two clash (collision) resolution strategies: open addressing and chaining. (5%)

(c) What are the key points for designing a good hash function? (5%)

(d) What would be a good hash function for license plates that is a string of numbers and letters of the form " * ic 000 * ic "', where an ''0" represents a digit and

an " * " represents a letter? Why? (5%)

5 (20%)

(a) Write an algorithm that checks if a complete binary tree is a heap. Analyze your algorithm and show the result using order notation. (1 0%)

(b) Design a sorting algorithm based on a ternary heap. A ternary heap is like an ordinary heap except that each internal node has three children. (10%)

6. (10%)

Write a C/C+t function that takes an integer array and its size as arguments and finds the minimum and the maximum of the numbers. This can be done by using no more than 3n/2 comparisons where n is the size of the array.

參考文獻

相關文件

Sometimes called integer linear programming (ILP), in which the objective function and the constraints (other than the integer constraints) are linear.. Note that integer programming

More precisely, it is the problem of partitioning a positive integer m into n positive integers such that any of the numbers is less than the sum of the remaining n − 1

A factorization method for reconstructing an impenetrable obstacle in a homogeneous medium (Helmholtz equation) using the spectral data of the far-field operator was developed

A factorization method for reconstructing an impenetrable obstacle in a homogeneous medium (Helmholtz equation) using the spectral data of the far-eld operator was developed

1 As an aside, I don’t know if this is the best way of motivating the definition of the Fourier transform, but I don’t know a better way and most sources you’re likely to check

The notation T n (x) is used to represent the nth partial sum of this series and we can call it as it the nth-degree Taylor polynomial of f at a... In general, it can be shown

[This function is named after the electrical engineer Oliver Heaviside (1850–1925) and can be used to describe an electric current that is switched on at time t = 0.] Its graph

Recall that we defined the moment of a particle about an axis as the product of its mass and its directed distance from the axis.. We divide D into