1 / 25

Data Structures

Data Structures. Introduction Homepage : www.cs.hongik.ac.kr/~rhanha Mail : jhbang@cs.hongik.ac.kr. 1. Introduction to Unix 2. Array / 과제#1 3. Queue & Stack 4. Project #1 제출/설명 5. 식목일 6. Linked list / 과제#2 7. Tree. 8. 중간고사 9 . Project #2 제출/설명 10. Encoding

sylvia
Download Presentation

Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures Introduction Homepage : www.cs.hongik.ac.kr/~rhanha Mail : jhbang@cs.hongik.ac.kr

  2. 1. Introduction to Unix 2. Array / 과제#1 3. Queue & Stack 4. Project #1 제출/설명 5. 식목일 6. Linked list / 과제#2 7. Tree 8. 중간고사 9. Project#2 제출/설명 10. Encoding 11. Graph / 과제 #3 12. Sorting 13. Project #3 제출/설명 14. Hashing 15. 기말고사 Schedule

  3. Grading Policy (1) • Total=3Project(35)+3x숙제(15)+출석(10) • Project (35) = Project (100) 0.35 • 숙제 (15) = 과제(100) 0.15 • Assignment(100) = Program (90) + Report (10) • Program (90) = • Compile (10) • Comment (10) • Execution (Correctness) (70)

  4. Grading Policy (2) • Copy 적발 시 • Program = 0 • No Late Submission • No Submission F

  5. Data Structures #1 Introduction to Unix

  6. 기본 Tool 사용법 • man: find and display reference manual pages • Usage: >man [query] • ftp: User interface to file transfer protocol • Usage:>ftp [ip_address | Hostname] • telnet: communicate with another host • Usage: >telnet [ip_address | Hostname] • vi editor: Screen-oriented display editor based on ex • Usage: >vi [options][filename] • More Info.: man page

  7. Compile & Debug (GNU) • g++: C and C++ compilers are integrated • Usage : g++ [-options | filenames]… • -c [source_filename] : compile & generate an object file (.o) • -o [execute_filename] [object_files] [libraries] : generate execution file • -g <source_filename> : use debug • More info. >man g++

  8. Compile & Debug (GNU) .c .h

  9. Compile & Debug (GNU) • gdb: Debugger for gcc and g++ > gdb [executable file] > (gdb) b or break [line_number] > (gdb) r or run > (gdb) n or next > (gdb) s or step > (gdb) display <variable> • For more info. > (gdb) help > man gdb

  10. Example Compile & Debug (GNU) • #include <stdio.h> • struct samp{ • int a, b; • }; • main() • { • struct samp ob[5]={{1,2},{3,4},{5.6},{7.8},{9,10}}; • int i; • samp *p; • p=ob; /* get stating address of array */ • for( i=0; i<4; i++){ • printf(“%d ”, p->a); • printf(“%d \n”, p->b); • p++; • } • printf(“\n”); • return 0; • }

  11. Example Compile & Debug (GNU)

  12. Example Compile & Debug (GNU)

  13. Make (1) • make의 필요성 • 여러 개의 파일로 나누어 개발할 경우 • 링크 에러의 원인이 되기도 함 • 에러의 원인을 제대로 찾기가 힘이 든다 • 수정한 file만 새롭게 update 할 필요가 있을 때make를 사용 • make명령으로 여러file을 compile

  14. Make (2) • Make file은 반드시makefile이라는 file name 사용 • 다른 file name을 사용 할 경우 -foption 사용 • makefile의 구성 • target • dependency • command • ex)test.o (target):test.h test.c (dependency) <TAB>g++ -c test.c (command) command 부분은 반드시 제일 앞에 TAB character 사용

  15. Make (3) • Example test.c test.h test1.c test1.h test.o test1.o test

  16. Make (4) • Example must tab

  17. Make (5) • Example

  18. Assignment 제출 요령 (1) • >telnet 203.249.75.51 or telnet ce1.ce.hongik.ac.kr로 접속 • Using Submit, can’t overwrite • tar: create tape archives and add or extract files • make assign.tar at parent directory of assign >tar cvf assign.tar assign • unpack .tar file >tar xvf assign.tar • File_name: Student-ID_Version.tar • A011001_hw1.tar (Must be include *.h, *.c, makefile) • Make sure your program on ce execution before submission

  19. Assignment 제출 요령 (2) Usage : submit #> submit (Prof. Or T/A 계정) (제출 디렉토리) (제출할 화일이름) - 계정 : jhbang - 제출 디렉토리 구성 : 반이름/과제+과제번호 예) f반, 숙제#1 또는 project#1 : f/hw1 or f/pro1

  20. Comment - example (1) • File Head Comment /*********************************************************************/ /* File Name : Main.c */ /* Date : 2001/3/09 */ /* Compiler : g++ 2.8.1 */ /* Os : Solaris 7.2 */ /* Author : Bang ji ho */ /* Student ID : A011053 */ /* ----------------------------------------------------------------- */ /* ver : 1.0.0 */ /* Description : … */ /* Etc.. : Data Structure Homework #1 ( sparse matrix ) */ /*********************************************************************/

  21. Comment - example (2) • Function Head Comment /*********************************************************************/ /* TMatrix :: _InsertNode */ /* ================================================================= */ /* Input: Node* -> Insert Node, */ /* Node* -> Column node before insert node */ /* Node* -> Row node before insert node */ /* (Input parameter Description) */ /* Output: int - 1 success */ /* 0 - fail */ /* (Out parameter Description) */ /* Purpose: Insert node */ /*********************************************************************/

  22. Comment - example (3) • In-Line Comment /**********************Row insert **************************/ if( pRowPos->pNextRow != pRowPos ) { pTemp->pNextRow = pRowPos->pNextRow; // pTemp set next row if( !( pRowPos->pNextRow->bHead ) ){ pRowPos->pNextRow->NodeItem.pPrevRow = pTemp; } // end of if } // end of if else { pTemp->pNextRow = pRowPos; // pTemp set next row } // end of else pTemp->NodeItem.pPrevRow = pRowPos; // pTemp set previous row pRowPos->pNextRow = pTemp; /********************** End of row insert ********************/

  23. Report 제출 요령 • Program Overview • Algorithm • pseudo code • flow char • etc. • Analysis

  24. Report 제출요령 - example (1) • Algorithm-pseudo code FixHeap(Node *root, Key k) { Node vacant, largerChild; vacant = root; while( vacant is not leaf ) { largerChild = the child of vacant with the larger key; if( k < largerChild’s Key ) { copy lagerChild’s key to vacant; vacant = largerChild; } else exit loop; } }

  25. Report 제출요령 - example (2) • Algorithm - Flow Chart (Each function) Start Find head node Make head node Find inserted position Insert End

More Related