cs 202 computer science ii lab fall 2009 november 5

11
CS 202 Computer Science II Lab Fall 2009 November 5

Post on 19-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 202 Computer Science II Lab Fall 2009 November 5

CS 202Computer Science II Lab

Fall 2009November 5

Page 2: CS 202 Computer Science II Lab Fall 2009 November 5

Today Topics

• Makefile• Sort Algorithms• Palindrome String

Page 3: CS 202 Computer Science II Lab Fall 2009 November 5

Makefilemain

main.o cylinder.o

main.cpp

cylinder.h cylinder.h

cylinder.cpp

circle.o point.o

circle.h

point.h

circle.h

circle.h

point.h

circle.cpp point.cpp

point.h

Page 4: CS 202 Computer Science II Lab Fall 2009 November 5

Bubble Sort

24

7

12

53

14

11

1

7

24

12

53

14

11

1

7

12

24

53

14

11

1

7

12

24

53

14

11

1

7

12

24

14

53

11

1

7

12

24

14

11

53

1

7

12

24

14

11

1

53

Page 5: CS 202 Computer Science II Lab Fall 2009 November 5

Selection Sort

24

7

12

53

14

11

1

6

19

23

1

7

12

53

14

11

24

6

19

23

1

6

12

53

14

11

24

7

19

23

1

6

7

53

14

11

24

12

19

23

1

6

7

11

14

53

24

12

19

23

Page 6: CS 202 Computer Science II Lab Fall 2009 November 5

Insertion Sort

12 10 18 20 7 40 15 23 2 17 38 32 27

current

12 12 18 20 7 40 15 23 2 17 38 32 27

temp: 10

10 12 18 20 7 40 15 23 2 17 38 32 27

current

10 12 18 20 7 40 15 23 2 17 38 32 27

current

temp: 10

Page 7: CS 202 Computer Science II Lab Fall 2009 November 5

Insertion Sort10 12 18 20 7 40 15 23 2 17 38 32 27

current

10 12 18 20 7 40 15 23 2 17 38 32 27

temp: 7

7 10 12 18 20 40 15 23 2 17 38 32 27

current

7 10 12 18 20 40 15 23 2 17 38 32 27

current

temp: 7

temp: 15

Page 8: CS 202 Computer Science II Lab Fall 2009 November 5

Insertion Sort7 10 12 18 20 40 15 23 2 17 38 32 27

temp: 15

7 10 12 15 18 20 40 23 2 17 38 32 27

current

7 10 12 15 18 20 40 23 2 17 38 32 27

temp: 23

7 10 12 15 18 20 23 40 2 17 38 32 27

current

Page 9: CS 202 Computer Science II Lab Fall 2009 November 5

Palindrome String

• A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction. (Wikipedia)

1. K2. IMLOBOLMI3. 7345437• Create:bool ifPalindrome( char inStr[], int start, int end)

Page 10: CS 202 Computer Science II Lab Fall 2009 November 5

List All Palindrome

• Create a function which shows all palindrome substrings of the input string. Size of substrings are more than one.

• GBNCCNBPBNCCNBK1. CC2. BNCCNB3. BNCCNBBNCCNB4. …?

Page 11: CS 202 Computer Science II Lab Fall 2009 November 5

Questions?