Dsa Terms Reviewer

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Module 1: Introduction to Data

Structures and Abstract Data Non-Primitive Data Structures:


- More sophisticated data structures
Type (ADT)
- Derived from the primitive data
Data structure:
structures
- representation of the logical
relationship existing between
- Emphasize on structuring of a
individual elements of data
group of homogenous (same type)
or heterogenous (different type)
- a way of organizing all data items
data items
that considers the elements and
their relation to each other
- The design of an efficient data
structure must take operations to
- affects the design of both structural
be performed on the data
and functional aspects of a
structure.
program
Non-Primitive Data Structures:
- Way of organizing the data with
- Linear List
their logical relationship retained
- Non-Linear List

Program = Algorithm + Data Structure


Linear List:
- Array
Algorithm:
- Link List
- A step by step procedure to solve
- Stack
a particular function
- Queue

- A set of instruction written to carry


Non-Linear List:
out certain tasks
- Graph
- Trees
DATA STRUCTURES ARE DIVIDED
INTO TWO BROAD CATEGORIES:
Linear List - in linear data structure,
- Primitive Data Structure
values are arranged in linear fashion.
- Non-Primitive Data Structure
- Array: Fixed-Size
- Linked List: Variable-Size
Primitive Data Structures:
- Stack: Add to top and remove
- Basic structures and directly
from top
operated upon by the machine
- Queue: Add to back and remove
instructions
from front
- Priority queue: Add anywhere,
- Different representation on
remove the highest priority
different computers
Non-Linear List - the data values in this
- Integer, Floating-point number,
structure are not arranged in order.
Character constants, string
- Hash Tables: unordered lists
constants, pointers etc. fall in this
which use a ‘hash function’ to
category
insert and search
- Tree: data is organized in Abstract Data Type (ADT):
branches - data type that separates the logical
- Graph: A more general branching properties from the implementation
structure, with less strict details
connection conditions than for a
tree - Support abstraction,
encapsulation, and information
hiding

Abstraction - providing only essential


information outside the world

Encapsulation - binding the data, and the


functions that use them

THE CORE OPERATION OF ADT


TYPES OF DATA STRUCTURES
Every Collection ADT should provide a
Homogenous - values of the same types way to:
of data are stored - Add an item
- Array - Remove an item
- Find, retrieve, or access an item
Non-Homogenous - values of different
types are grouped and stored Many, many more possibilities
- Structures - Is the collection empty
- Classes - Make the collection empty
- Give me a subset of the collection
SELECTION OF DATA STRUCTURES
The choice of particular data model
depends on two considerations:
- Must be rich enough in structure
to represent the relationship
between data elements
- Should be simple enough that
one can effectively process the
data when necessary

ABSTRACT DATA TYPE (ADT)

Abstraction:
- Separating design details from
usage
- Separating the logical properties
from the implementation details

Abstraction can also be applied to data

very nice explanation:


It produces a pointer that points to the
variable.

The & operator is simply called the


address-of-operator

DEREFERENCING OPERATOR (*)


When used as a unary operator, * is the
dereferencing operator or indirection
operator

Refers to object to which its operand


points

The * operator in front of a pointer


variable produces the variable to which
Module 2: Review of Pointers it points. When used this way, the *
operator is called the dereferencing
Pointer - the memory address of a operator.
variable

Pointer Variable - content is a memory


address

There is no name associated with the


pointer data type in C++

Declaring Pointer Variables:


Syntax - dataType *identifier;
Examples:
- int *p;
- char *ch

These statements are equivalent: (all of


them are the same)
- int *p;
- int* p;
- int * p;

ADDRESS OF THE OPERATOR (&)

Ampersand & - is called the address of


the operator that returns the address of its
operand

The & in front of an ordinary variable


produces the address of that variable.
IMPORTANT NOTES:
- When you apply delete to a pointer
variable, the dynamic variable to
which it is pointing is destroyed

- At that point, the value of the


pointer variable is undefined,
which means that you do not know
where it is pointing.

Dangling pointers - if a pointer variable


pointing to the dynamic variable that was
destroyed and becomes undefined, they
are called dangling pointers.

Type definitions - you can assign a name


The new Operator - creates a new definition and use the type name to
dynamic variable of a specified type and declare variables using typedef keyword.
returns a pointer that points to this new
variable

Example: p1 = new int;


- This new, nameless variable can
be referred to as *p1 (that is, as
the new variable pointed by p1

The heap (freestore) - special area of


memory that is reserved for dynamically
allocated variables

IMPORTANT NOTES:
- Any new dynamic variable
created by a program consumes
some of the memory in the
freestore

- If there was insufficient available


memory to create the new
variable, then new returned a
special value named NULL.

The delete Operator - eliminates a


dynamic variable and returns the memory
that the dynamic variable occupied to the
freestore manager so that the memory
can be reused. Module 3: Linked List
Linked list:
- a series of connected nodes,
where each node is a data
structure

- Can grow or shrink in size as the


program runs

- Can easily grow or shrink in size

- Insertion and deletion of nodes is


quicker with linked lists than with
vectors

Composition of a Linked List:


- Each node in a linked list contains
one or more members that
represent data

- In addition to the data, each node


contains a pointer, which can point
to another node.

- A linked list is called “linked”


because each node in the series
has a pointer that points to the
next node in the list

TINATAMAD NA AKONG
ILAGAY YUNG IBANG TERMS
FROM MODULE 3 TIGNAN
NIYO NALANG YUNG
MISMONG FILE SALAMAT

You might also like