Skip to content

scps940707/Homework-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Homework 1

  1. Prove that each of the following sorting algorithms is stable or show that it is unstable by giving a counter example; moreover, determine whether it is in place: bubble sort, insertion sort, quick sort, merge sort and heap-sort.
    • 第十四組
  2. Given a positive integer n, design an algorithm for computing floor(sqrt(n)).
    • 第十六組
  3. How to implement merge-sort such that the extra space used is about n/2 where n is the number of input elements?
    • 第十三組
  4. Given two sorted arrays x[1..m] and y[1..n], design an algorithm to compute min_i,j|x[i]-y[i]|.
    • 第九組
  5. Solve the recurrence T(n)=2T(n/2)+n-1 where n=2^k is assumed; assume that T(n) is constant if n<=2.
    • 第一組
  6. Given a sorted array A[1..n] of n distinct integers, you want to find out the index i for which A[i]=i if it exists. Please design a Divide-and-Conquer algorithm that runs in time O(log(n)). (Analyze your algorithm and show it is correct.)
    • 第三組
  7. Analyze best-case, average-case, and worst-case performance of the following pseudocode which describes a sorting algorithm. Append your analyzing process or reasons.
    • 第七組
i = 2
while i <= size
    if i == 1 or array[i] >= array[i - 1]
        i += 1
    else
        swap array[i], array[i - 1]
        i -= 1

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Crystal 100.0%