This document discusses fundamentals of data structures and algorithms. It defines data structures as special formats for storing and organizing data, distinguishing between linear and non-linear types. Abstract data types are introduced as logical descriptions of how data is viewed and operations allowed, without specifying implementation. Common ADTs like lists, stacks, queues, trees and graphs are described. The document also defines the elements of an algorithm as sequential operations and actions based on data state, and mentions iteration, recursion and paradigms like divide and conquer, greedy algorithms and dynamic programming.
This document discusses fundamentals of data structures and algorithms. It defines data structures as special formats for storing and organizing data, distinguishing between linear and non-linear types. Abstract data types are introduced as logical descriptions of how data is viewed and operations allowed, without specifying implementation. Common ADTs like lists, stacks, queues, trees and graphs are described. The document also defines the elements of an algorithm as sequential operations and actions based on data state, and mentions iteration, recursion and paradigms like divide and conquer, greedy algorithms and dynamic programming.
MIKAELA ARCIAGA IT Instructor LEARNING OBJECTIVES:
LO1: Differentiate abstract data types;
LO2: Describe algorithm and its elements;
LO3: Compare the paradigms of algorithm
design; and
LO4: Create a program based on a given
algorithm. Data Structures A data structure is a special format for storing and organizing data. Two (2) types of data structure Linear: Elements are accessed in a sequential order but may be stored unsystematically.
Non-Linear: Elements are stored and
accessed in a non-sequential order. Abstract Data Types is a logical description of how data is viewed as well as the operations that are allowed without regard to how they will be implemented.
• Code is easier to understand.
• Implementations of ADTs can be changed without requiring changes to the program that uses the ADTs. • ADTs can be used in future programs Wall of ADT • Create a list
• Insert an item into the list
• Remove an item from the list
• Check if the list is empty
• Display list content
Two (2) parts of ADT Public or external ADT – the data and the operations Private or internal ADT – the representation and the implementation The four (4) main operations that could be defined for each ADT are • initializing, • adding, • accessing, and • removing of data Abstract data types: Linked list – used for storing elements where each is a separate object.
Stack – an ordered list in which the last
element added is the first element retrieved or removed (Last-In, First-Out).
Queue – an ordered list in which the first
element added is the first element retrieved or removed (First-In, FirstOut) Tree – represents a hierarchical nature of a structure in a graphical form.
Graph – consists of a set of vertices (or
nodes) and a set of edges (relations) between the pairs of vertices.
Heap – a complete binary tree where the
value of each parent node is either higher or lower than the value of its child nodes. Priority queue – a special type of queue where elements are processed based on their order (natural or custom).
Set – a collection of elements where each
element is unique.
Map – a set of ordered pairs where elements
are known as keys (identifiers) and values (content). Elements of an algorithm: Sequential operations Actions based on the state of a data structure Iteration – repeating an action multiple times Recursion – occurs when a function calls itself once or multiple times to solve a problem
Algorithm design paradigms:
Divide and Conquer: A problem is broken into smaller sub-problems. Greedy Algorithms: The optimal approach is always chosen in solving a problem. Dynamic Programming: Similar to Divide and Conquer except that the results of the sub-problems are reused for overlapping sub-problems.