BCS2122DCS2192 Data Structure and Algorithm - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

BCS2122DCS2192 Data Structure and Algorithm

Description:

Subscript (index) is used to refer to the array element. ... A string is a groups of characters. An array of char data type! Complete definition of a string: ... – PowerPoint PPT presentation

Number of Views:139
Avg rating:3.0/5.0
Slides: 18
Provided by: notesU
Category:

less

Transcript and Presenter's Notes

Title: BCS2122DCS2192 Data Structure and Algorithm


1
BCS2122/DCS2192Data Structure and Algorithm
  • Muhammed Ramiza Ramli
  • July 10 Oct 21

2
Preface
  • About This Course

3
Rules
  • Full Attendance
  • Fail to come to my class
  • fail to this course

4
Objective
  • Strengthen the skill - using an adequate
    algorithm Pointer, Linked list, Stack, Queue
  • Student capable to use the sorting and searching
    technique for data manipulation of data structure
  • Student capable present algorithm for performing
    computations on a tree.

5
Course Overview
  • This course describes the following areas
  • The syntax of the C programming language.
  • Data representation in C programming data type.
  • Data Structure concepts as they apply to the C
    programming language.
  • Data manipulation for storing and retrieving
    information.

6
Topic
  • Primitive Data Type
  • Pointer
  • Storage Structure
  • Array
  • Structure
  • Linkage Structure
  • Linked List
  • Tree
  • Graph

7
Modules
  • Module 1 Getting started
  • Module 2 Pointer
  • Module 3 Structure
  • Module 4 Dynamic Memory Allocation
  • Module 5 Stack
  • Module 6 Queue
  • Module 7 Searching
  • Module 8 Sorting
  • Module 9 Tree

8
Tools
  • Lecture Note
  • Presentation Slides
  • Software
  • gcc with Anjuta IDE on Linux
  • gcc with DevC on Windows
  • Visual C on Windows
  • Any Editor
  • Book
  • Any Data Structure Books

9
Array
  • A list of a finite number with a similar data
    elements.
  • Subscript (index) is used to refer to the array
    element.
  • Example array11
  • Refer to the second element in array array1

10
Illustration of array array1
4
3
2
1
0
array1
11
Illustration of array C
12
Initialized an Array Value
  • During initialization
  • int marks 10, 40, 30, 20, 50
  • int C32 22,66,88,55,77,44
  • Assignment operator
  • marks2 70
  • Marks3 marks2
  • User input
  • scanf(d,marks4)

13
Sample Code
  • / Initialize the elements of array
  • s to the even integers from 2 to 20 /
  • include ltstdio.hgt
  • define SIZE 10
  • int main()
  • int sSIZE, j
  • for(j 0 jltSIZE 1 j)
    / Set the Values /
  • sj 2 2 j
  • for(j 0 j lt SIZE j)
    / Print the Values /
  • printf(7d13d\n, j, sj)
  • return 0

14
Strings
  • How to store a string instead of character?
  • Using Array
  • char name20
  • char name220
  • store a data into array of char
  • scanf( s,name)
  • print out a data
  • printf( s,name)

15
A string
  • A string is a groups of characters
  • An array of char data type!
  • Complete definition of a string
  • A sequence of char type data terminated by a
    NULL character.

16
Sample Code
  • include ltstdio.hgt
  • define SIZE 5
  • int main()
  • char nameSIZE
  • name0 S
  • name1 i
  • name2 t
  • name3 i
  • name4 \0
  • printf(The name is s\n,name)
  • printf(One letter is c\n,name3)
  • return 0

17
Operation with String
  • Copy
  • using strcpy/strncpy function
  • include ltstring.hgt
  • strcpy(str1,str2)
  • Concatenate
  • Using strcat/strncat function
  • strcat(str1,str2)
  • Compare
  • Using strcmp/strncmp function
  • strcmp(str1,str2)
Write a Comment
User Comments (0)
About PowerShow.com