0% found this document useful (0 votes)
19 views46 pages

Chapter 1 - Introduction and Preliminaries

Chapter 1 introduces basic concepts in data structures, focusing on pseudocode for algorithm development, the importance of Abstract Data Types (ADTs), and their implementations using arrays and linked lists. It also covers the use of void pointers, function pointers, and the principles of algorithm efficiency, including Big-O notation. The chapter aims to equip readers with foundational knowledge necessary for understanding and implementing data structures in C.

Uploaded by

Dhruval Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views46 pages

Chapter 1 - Introduction and Preliminaries

Chapter 1 introduces basic concepts in data structures, focusing on pseudocode for algorithm development, the importance of Abstract Data Types (ADTs), and their implementations using arrays and linked lists. It also covers the use of void pointers, function pointers, and the principles of algorithm efficiency, including Big-O notation. The chapter aims to equip readers with foundational knowledge necessary for understanding and implementing data structures in C.

Uploaded by

Dhruval Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Chapter 1

Basic Concepts

Objectives
Upon completion you will be able to:

• 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
Data Structures: A Pseudocode Approach with C 1
1-1 Pseudocode

Pseudocode is an English-like representation of the


algorithm logic. It consists of an extended version of
the basic algorithmic constructs: sequence, selection,
and iteration.

• Algorithm Header 3 things to write pseudocode:


1) Selection
• Purpose, Condition, and Return 2) Sequence
3) Loops
• Statement Numbers
• Variables
• Statment Constructs
• Algorithm Analysis
Data Structures: A Pseudocode Approach with C 2
"Selection"

Data Structures: A Pseudocode Approach with C 3


Data Structures: A Pseudocode Approach with C 4
1-2 The Abstract Data Type

An ADT consists of a data declaration packaged


together with the operations that are meaningful
on the data while embodying the structured
principles of encapsulation and data hiding. In this section
we define the basic parts of an ADT.
• Atomic and Composite Data
• Data Type
• Data Structure
• Abstract Data Type

Data Structures: A Pseudocode Approach with C 5


Data Structures: A Pseudocode Approach with C 6
Data Structures: A Pseudocode Approach with C 7
Data Structures: A Pseudocode Approach with C 8
1-3 Model for an Abstract Data Type

In this section we provide a conceptual


model for an Abstract Data Type (ADT).
• ADT Operation
• ADT Data Structure

Data Structures: A Pseudocode Approach with C 9


Data Structures: A Pseudocode Approach with C 10
1-4 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

Data Structures: A Pseudocode Approach with C 11


Data Structures: A Pseudocode Approach with C 12
Data Structures: A Pseudocode Approach with C 13
Data Structures: A Pseudocode Approach with C 14
1-5 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

Data Structures: A Pseudocode Approach with C 15


Data Structures: A Pseudocode Approach with C 16
pointer type var

int type var

float tyoe var

Loaded in the stack part of the memory

pg 19 of the book

*((int*)p) and *((float*)p)

Typecasting for void* and deferencing to get the value of the variable
Also, a pointer to void cannot
be dereferenced unless it is cast. In other words, we cannot use *p without casting.
Data Structures: A Pseudocode Approach with C 17
1-6 Algorithm Efficiency

To design and implement algorithms, programmers


must have a basic understanding of what
constitutes good, efficient algorithms. In this
section we discuss and develop several principles
that are used to analyze algorithms.

• Linear Loops
• Logarithmic Loops
• Nested Loops
• Big-O Notation
• Standard Measurement of Efficiency
Data Structures: A Pseudocode Approach with C 18
Data Structures: A Pseudocode Approach with C 19
Data Structures: A Pseudocode Approach with C 20
Data Structures: A Pseudocode Approach with C 21
Data Structures: A Pseudocode Approach with C 22
(Continued)

Data Structures: A Pseudocode Approach with C 23


Data Structures: A Pseudocode Approach with C 24
Data Structures: A Pseudocode Approach with C 25
Data Structures: A Pseudocode Approach with C 26
Data Structures: A Pseudocode Approach with C 27
(Continued)

Data Structures: A Pseudocode Approach with C 28


Data Structures: A Pseudocode Approach with C 29
Data Structures: A Pseudocode Approach with C 30
Data Structures: A Pseudocode Approach with C 31
Data Structures: A Pseudocode Approach with C 32
Data Structures: A Pseudocode Approach with C 33
Data Structures: A Pseudocode Approach with C 34
Data Structures: A Pseudocode Approach with C 35
Data Structures: A Pseudocode Approach with C 36
Data Structures: A Pseudocode Approach with C 37
Data Structures: A Pseudocode Approach with C 38
Data Structures: A Pseudocode Approach with C 39
Data Structures: A Pseudocode Approach with C 40
Data Structures: A Pseudocode Approach with C 41
Data Structures: A Pseudocode Approach with C 42
Data Structures: A Pseudocode Approach with C 43
Data Structures: A Pseudocode Approach with C 44
Data Structures: A Pseudocode Approach with C 45
Data Structures: A Pseudocode Approach with C 46

You might also like