data structures: a pseudocode approach with c, second edition1 chapter 1 objectives use pseudocode...
TRANSCRIPT
![Page 1: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/1.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 1
Chapter 1Chapter 1
Objectives
• Use pseudocode in the development of algorithms • Understand the need for Abstract Data Type (ADT)• Understand the implementation of ADTs• Use void pointers and pointer to functions• Understand the role of Big-O notation
Basic ConceptsBasic Concepts
![Page 2: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/2.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 2
Pseudocode
Pseudocode is an English-like representation of the algorithm logic. It Pseudocode is an English-like representation of the algorithm logic. It consists of an extended version of the basic algorithmic constructs: consists of an extended version of the basic algorithmic constructs:
sequence, selection, and iterationsequence, selection, and iteration. . • Algorithm Header
• Purpose, Condition, and Return
• Statement Numbers
• Variables
• Statment Constructs
• Algorithm Analysis
![Page 3: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/3.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 3
![Page 4: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/4.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 4
![Page 5: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/5.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 5
The Abstract Data Type
An ADT consists of a data declaration packaged An ADT consists of a data declaration packaged together with the operations that are meaningful together with the operations that are meaningful on the data while embodying the structured on the data while embodying the structured principles of encapsulation and data hiding. In this sectionprinciples of encapsulation and data hiding. In this sectionwe define the basic parts of an ADT.we define the basic parts of an ADT.
• Atomic and Composite Data
• Data Type
• Data Structure
• Abstract Data Type
![Page 6: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/6.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 6
![Page 7: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/7.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 7
Data StructureAggregation of atomic and composite data into a set with defined relationships. Structure refers to a set of rules that hold the data together.
• A combination of elements in which each is either a data type or another data structure.
• A set of associations of relationship involving combined elements.
Example:
![Page 8: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/8.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 8
![Page 9: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/9.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 9
Abstract Data Type
ADT users are NOT concerned with how the task is done but rather what it can do.
An abstract data type is a data declaration packaged together with the operations that are meaningful for the data type.
We encapsulate the data and the operations on the data, and then hide them from the user.
All references to and manipulation of the data in a data structure are handled through defined interfaces to the structure.
![Page 10: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/10.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 10
Model for an Abstract Data Type
In this section we provide a conceptual model for an Abstract Data Type (ADT).
• ADT Operation – passage like• ADT Data Structure – controlled entirely
![Page 11: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/11.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 11
![Page 12: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/12.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 12
ADT Implementations
There are two basic structures we can use to implement an ADT list: arrays and linked lists. In this section we discuss the basic linked-list implementation.
• Array Implementation• Linked List Implemenation
![Page 13: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/13.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 13
![Page 14: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/14.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 14
![Page 15: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/15.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 15
![Page 16: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/16.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 16
Generic Code for ADT
In this section we discuss and provide examples of two C tools that are required to implement an ADT.
• Pointer to Void• Pointer to Function
![Page 17: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/17.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 17
![Page 18: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/18.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 18
![Page 19: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/19.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 19
![Page 20: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/20.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 20
![Page 21: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/21.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 21
(Continued)
![Page 22: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/22.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 22
![Page 23: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/23.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 23
![Page 24: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/24.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 24
![Page 25: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/25.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 25
![Page 26: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/26.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 26
(Continued)
![Page 27: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/27.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 27
![Page 28: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/28.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 28
![Page 29: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/29.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 29
![Page 30: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/30.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 30
![Page 31: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/31.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 31
![Page 32: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/32.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 32
![Page 33: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/33.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 33
![Page 34: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/34.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 34
![Page 35: Data Structures: A Pseudocode Approach with C, Second Edition1 Chapter 1 Objectives Use pseudocode in the development of algorithms Understand the need](https://reader035.vdocument.in/reader035/viewer/2022062421/56649d895503460f94a6f43e/html5/thumbnails/35.jpg)
Data Structures: A Pseudocode Approach with C, Second Edition 35
Algorithm EfficiencyTo design and implement algorithms, programmers To design and implement algorithms, programmers must have a basic understanding of what constitutes must have a basic understanding of what constitutes good, efficient algorithms. good, efficient algorithms.
Linear Loops -Efficiency is a function of the number of intstructions. - Loop update either adds or subtracts.
• Logarithmic Loops-The controlling variable is either multiplied or divided in each iteration.- The number of iteration is a function of the multiplier or divisor.
• Nested Loops- The number of iterations is the total number which is the product of the number of iterations in the inner loop and number of iterations in the outer loop.
• Big-O Notation -Not concerned with exact measurement of efficiency but with the magnitude.- A dominant factor determines the magnitute.