practical data structures using c c chapter 1 introduction n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
PRACTICAL DATA STRUCTURES USING C/C++ Chapter 1 Introduction PowerPoint Presentation
Download Presentation
PRACTICAL DATA STRUCTURES USING C/C++ Chapter 1 Introduction

Loading in 2 Seconds...

play fullscreen
1 / 14

PRACTICAL DATA STRUCTURES USING C/C++ Chapter 1 Introduction - PowerPoint PPT Presentation


  • 135 Views
  • Uploaded on

PRACTICAL DATA STRUCTURES USING C/C++ Chapter 1 Introduction. Email: cjtsai@cc.ncue.edu.tw Tel: 04-7232105 ext.3242 . 彰師大 數學系 蔡政容 (Cheng-Jung Tsai). textbook. Practical Data Structure Using C/C++

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'PRACTICAL DATA STRUCTURES USING C/C++ Chapter 1 Introduction' - imala


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
practical data structures using c c chapter 1 introduction

PRACTICAL DATA STRUCTURES USING C/C++Chapter 1Introduction

Email: cjtsai@cc.ncue.edu.tw

Tel: 04-7232105 ext.3242

彰師大 數學系

蔡政容 (Cheng-Jung Tsai)

textbook
textbook
  • Practical Data Structure Using C/C++
  • Fundamentals of Data Structures in C++, E. Horowitz, S. Sahni and D. Mehta, 2nd Edition, Silicon Press.
about c and c textbook
About C and C++ textbook
  • C
    • The C Programming Language, 2/e, Brian W. Kernighan and Dennis M. Ritchie;(K&R), Prentice-Hall (C Bible)
      • C 語言程式設計, 蔡文能 譯
    • C PRIMER PLUS, Fifth Edition, Stephen Prata, 2005.
      • C Primer Plus 5/e中文精華版,蔡明志, 碁峰, 2005
    • C HOW TO PROGRAM 5/E, DEITEL, Prentice Hall, 2007
      • C程式設計藝術(第五版), 陳大任、陳心瑋, 全華科技, 2008
  • C++
    • The C++ Programming Language (3rd), Bjarne Stroustrup, Addison Wesley, 1997 (C++ Bible)
      • C++ 程式語言經典增訂版, 葉秉哲, 儒林
    • C++ Primer Plus (5th Edition), Stephen Prata
      • C++ Primer 4/e中文版C++ Primer 4/e中文版, 侯捷 譯, 碁峰, 2008.
      • C++ Primer Plus 5/e中文精華版, 蔡明志, 碁峰, 2005
outline
Outline
  • Introduction
  • 1.1 What is a data structure
  • 1.2 Static and dynamic data structures
  • 1.3 Why do we need data structures
  • 1.4 Typical data structures
  • 1.5 Operations on data structures
  • 1.6 Choosing a data structure
  • 1.7 A note about C++
introduction
Introduction
  • Some programs will use a lot of memory, while others will need to access data stored on disk
  • A data structure is used to access the memory and disk in a way that saves or retrieves information efficiently
  • Data structure
    • Bulit-in to a programming language
      • Variable, array
    • User specified
      • Created by the programmer to meet the needs and requirements of his program
1 1 what is a data structure
1.1 What is a data structure
  • A predefined arrangement of one or more pieces of data
    • Three characters c+a+t are grouped
    • Array:
      • Store the distances between four towns
      • see Fig 1.1 in page 3
    • Can be one or more items of the same type or a mixture of many different types
  • char, int, float in C/C++ can be thought as the simplest data structure
1 2 static and dynamic data structures
1.2 Static and dynamic data structures
  • Static data structures
    • Its allocated memory size is fixed
    • float, integer, array
  • Dynamic data structures
    • Start out empty
    • Grow until they occupy as much space as they need to
    • See the code in page 5
    • Common to use a pointer when dealing with a dynamic data structure
  • If you know in advance the number of pieces of data used by the application, static allocation is acceptable.
1 3 why do we need data structures
1.3 Why do we need data structures
  • Simplify our programming chores
1 4 typical data structures
1.4 Typical data structures
  • Common data structure: See Fig 1.2 in page 7
    • Strings and array
    • User defined
      • static
    • Linked-list
      • dynamic
      • link static variable together (nodes)
    • Stacks (LIFO) and queues (FIFO)
    • Trees and graphs
      • Search problem
    • Hash table
      • Hash function
      • Collision: bad design
      • Fast access time
    • Files, Heaps, Sets, Lookup Tables
1 5 operations on data structures
1.5 Operations on data structures
  • See pages 9 to 11 and Table 1.1 in page 11
  • Strings
  • Array
  • User defined
    • Structure name. variable name
  • Linked-list
    • Structure name
    • pointer
  • Stacks (LIFO)
    • push(), pop(), empty()
  • Queues (FIFO)
    • en_queue(), de_queue(), empty()
operations on data structures con
Operations on data structures (con.)
  • Trees
    • Child node, parent node
    • Level
    • Post-order
    • Depth-first search vs. breadth-first search
  • Graphs
    • A tree but no level
    • A node in a graph can connect to any other node in the graph
    • Require different search algorithms than trees do
  • Hash table
1 6 choosing a data structure
1.6 Choosing a data structure
  • A mismatched data structure will actually lower the performance of a program
  • Consider the following questions to decide
    • Is memory being used efficiently
      • Static or dynamic
    • What is the search time
      • If your program frequently search some elements among a lot ones, tree is much more efficiently than array
      • 1024 times in a array vs about 10 times in a tree
choosing a data structure con
Choosing a data structure (con.)
  • Consider the following questions to decide
    • How easy is it to use the structure
      • Of course, a array or a queue are easier than a tree
    • Can the access method be tested
      • A bad hash function may be more inefficient than an array
      • Using testing data to test your hash function
    • What are the tradeoffs
      • Time
      • Memory usage
      • Change your source code
1 7 a note about c
1.7 A note about C++
  • See pages 13
    • Class
    • Public vs private
    • Instantiation