# DaTA STRUCTURE 課程簡介 Lai Ah Fur 2003/2/20. Input Output Process Algorithm+Data Structures.

## Presentation on theme: "DaTA STRUCTURE 課程簡介 Lai Ah Fur 2003/2/20. Input Output Process Algorithm+Data Structures."— Presentation transcript:

DaTA STRUCTURE 課程簡介 Lai Ah Fur 2003/2/20

Input Output Process Algorithm+Data Structures

Data structures 資料項之間的關係 線性： linked list, Queue,Stack 階層 :Tree(BST,B-tree,AVL tree,..) 網狀 :graph (network,circuit)

Evaluation mid & final Test: 60% 術科實作考試： 15% Homework: 20% Attendance & discussion: 5%

bubble sort for integer static int[] bubbleSort(int[] a) { int t; for (int i=0; ia[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } return a; }

bubble sort for string String t; int n = args.length; for (int i=0; i 0) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; }

Selection sort-1 static void sort(String name[],int ary[],int n) { int temp=100; String st=""; for(int i=0;i<=n-2;i++) //0..n-2=n-1 pass for(int j=i+1;j<=n-1;j++) { if (ary[i]<=ary[j]) { temp=ary[i];ary[i]=ary[j];ary[j]=temp; st=name[i];name[i]=name[j];name[j]=st; } }}

Selection sort-2 static void sort(String name[],int ary[],int n) { int temp=100,min=0; String st=""; for(int i=0;i<=n-2;i++) //0..n-2=n-1 pass { min=i; for(int j=i+1;j<=n-1;j++) { if (ary[i]<=ary[j]) min=j; } temp=ary[i];ary[i]=ary[j];ary[j]=temp; st=name[i];name[i]=name[j];name[j]=st; }

Linear search static int linearsearch(int num,int n) { int findno=-1; for(int i=0;i<=n-1;i++) if (sc[i] ==num) { findno=i;break;} return (findno); }

Binary search static int binarysearch(int refsc[],int num) { int low=0,mid=0,high=0; high=refsc.length-1; while (low<=high) { mid=(int)((low+high)/2); if (refsc[mid]num) high=mid-1; else return (mid); }//while return (-1); //not found!! }

static int Rbinarysearch (int refsc[],int num,int low, int high ) { int mid=0; mid=(int)((low+high)/2); if (low>high) return (-1); //not found!! else if (refsc[mid]num) //Asce return ( Rbinarysearch (refsc,num,low,mid-1)); else //if (refsc[mid]==num) return (mid)); }// Rbinarysearch

Download ppt "DaTA STRUCTURE 課程簡介 Lai Ah Fur 2003/2/20. Input Output Process Algorithm+Data Structures."

Similar presentations