Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 67

TABLE OF CONTENTS

INTRODUCTION TO DATA TRAVERSING TREES 32 - 39


2-9
STRUCTURE
PRELIM SEMI-FINALS SELECTION SORT
ALGORITHM
40 - 44
ARRAY CONCEPT 10 - 13
QUICK SORT ALGORITHM 45 - 49
STORAGE ALLOCATION /
ARRAY WITH 14 - 17
IMPLEMENTATION OF
LINKED LIST

GRAPH DATA STRCTURE 51 - 59


STACK DATA STRUCTURE 19 - 22
FINALS HASH TABLES 60 - 69
MIDTERM QUEUE DATA STRUCTURE 23 - 27

TREE DATA STRUCTURE 28 - 30


PRELIM
PRELIM LESSON
1:
INTRODUCTION TO DATA STRUCTURE
(Algorithm, Pseudo Codes, Flowchart)

Contents:
Definition of terms
Algorithm example
Pseudo codes
Example program
Output of the program
DEFINITION OF TERMS
Data: Collection of raw facts. Pseudo Codes – These are close to natural
languages that serve as a textual
Data Structure: is representation of the presentation of a flowchart.
logical relationship existing between
individual elements of data. Flowchart – It is a diagram that shows
step-by-step progression through a

Algorithm – It is a finite set of procedure or system especially using

instructions that specify a sequence of connecting lines and a set of conventional

operations. symbols.
ALGORITHM :
1. Display “Enter your age”
2. User will input an age from the keyboard
3. Create the condition
4. Display the result

PSEUDO CODES:

Display the “Enter your age: “


Enter age from the keyboard
If age is equal or greater than 18, then
print “You are an adult”
else
print “You are still a minor”
SAMPLE PROGRAM
CODES:
SAMPLE PROGRAM
OUTPUT:
PRELIM LESSON 2:

ARRAY CONCEPTS
Contents:
Definition of terms
Example program
Output of the program
DEFINITION OF TERMS
Array Array Length
A variable that stores the
Is defined as a set of finite
length of an array
number of homogenous
elements or same data
items.
Syntax
The syntax is the same as
Index for a normal variable
declaration except the
A numeric value starts with variable name should be
zero (0). Each element can follow by subscript to
be accessed via its index specify the size of
dimension of the array
SAMPLE PROGRAM
CODES
SAMPLE PROGRAM
OUTPUT
PRELIM LESSON 3:
STORAGE ALLOCATION /
ARRAY WITH
IMPLEMENTATION OF
LINKED
Contents:
LIST
Definition of terms
Example program
Output of the program
DEFINITION OF TERMS

Storage Allocation Parallel Arrays


It is a place for storing The structure can be built “on
information top of” the data

Key Next
Contains the data All the structure in the
parallel array

Key [Next [Next [Head]] Key [Next [Head]]


refers to the second item on the refers to the information
list. associated with the first
item on the list.
Sample Program
Codes:
OUTPUT:
MIDTERM
MIDTERM LESSON 1:

STACK DATA STRUCTURE


Contents:
Definition of terms
Example program
Output of the program
DEFINITION OF TERMS
Linked List Data Structure
A linked list is a dynamic data
Data Structure can be defined as the group of
structure where each element
data elements which provides an efficient
(called a node) is made up of two
way of storing and organizing data in the
items: the data and a reference
computer so that it can be used efficiently.
(or pointer), which points to the
next node

STACK Queue
Stack is an abstract data type that holds an ordered, An abstract data structure,
Array
linear sequence of items. In contrast to a queue, a
stack is a last in, first out (LIFO) structure. A real-life
somewhat similar to Stacks.
Unlike stacks, a queue is open
Implementation
example is a stack of plates: you can only take a plate at both its ends. The stack is formed by using the
from the top of the stack, and you can only add a array.
plate to the top of the stack.
Codes :
Output
MIDTERM LESSON 2:

Queue Data Structure


Contents:
Definition of terms
Example program
Output of the program
DEFINITION OF TERMS
Queue - is a collection of entities that are maintained in a sequence and can be modified by the addition of
entities at one end of the sequence and the removal of entities from the other end of the sequence.

Sequence - an array of elements, a maximum number of elements that the array may contain its
allocated size, and a logical length indicating how many of the allocated elements are valid.

Linear Data Structures - A data structure is said to be linear if its elements form a sequence.

Circular Buffer- is a data structure that uses a single, fixed-size buffer as if it were connected
end-to-end. This structure lends itself easily to buffering data streams.

Computer Science - is the study of computation, automation, and information. Computer


science is generally considered an area of academic research and distinct from computer programming.
Codes:
Codes:
Output
MIDTERM LESSON 3:

TREE DATA STRUCTURE


Contents:
Definition of terms
Example of Tree Data Structure
DEFINITION OF TERMS
Tree Data Structure Root
A hierarchical structure
consists of multiple levels, Top node or the defining
root, node, and vertices property of a tree
Complete Binary Tree
A tree data structure that has each
Internal Nodes node have a maximum of two
External Nodes
Any node except the root children The node below a given node
node that has at least
one child

Forest Subtree Level of Nodes


represents the number of nodes in the path
a set of trees. descendants of a from the node to the
node. root
EXAMPLE OF TREE DATA
STRUCTURE
SEMI-FINALS
SEMI-FINAL LESSON 1:

Traversing Trees
Contents:
Definition of terms
Example program
Output of the program
DEFINITION OF TERMS

Graph Traversal
Refers to the process of visiting
(checking and/or updating) each
vertex in a graph.
Tree Traversal
Is a process in the use of tree models
that evaluates the nodes of a tree on a
systematic basis.

Algorithm
A specific procedure for solving
a well-defined computational
problem
TRAVERSING TREES
CODES :
OUTPUT:
SEMI-FINAL LESSON 2:

SELECTION SORT
ALGORITHM
Contents:
Definition of terms
Example program
Output of the program
DEFINITION OF TERMS
Selection Sort
Algorithm Insertion Sort
Sorts an array by repeatedly Is a simple sorting
finding the minimum element algorithm that builds the
(considering ascending order) final sorted array (or list) one
from unsorted part and putting item at a time.
it at the beginning.
Sort
Sorting the arrangement of data in a
Algorithm prescribed sequence

is an algorithm that
puts elements of
a list into an order.
CODES
OUTPUT
SEMI-FINAL LESSON 3:

QUICK SORT
ALGORITHMContents:
Definition of terms
Example program
Output of the program
DEFINITION OF TERMS

Merge Sort Stable Sort Algorithm


QUICKSORT Is an efficient, general- equal elements in the same
Uses divide-and-conquer, and purpose, and comparison- order that they appear in the
so it's a recursive algorithm. based sorting algorithm. input.
The way that quicksort uses
divide-and-conquer is a little
different from how merge sort
does.
Primary Storage Comparison Sort
Is the only one directly Meaning that it can sort items
accessible to the CPU. of any type for which a "less-
than" relation formally, a total
order is defined
CODES
:
OUTPUT:
FINALS
FINAL LESSON 1:

GRAPH DATA STRUCTURE


Contents:
Definition of terms
Example program: (Adjacency Lists, Adjacency Matrix)
Output of the program
DEFINITION OF TERMS
Are a convenient way to store certain types of data. The concept was
ported from mathematics and appropriated for the needs of computer
Graphs science.

Sometimes also called the connection matrix, of a simple labeled graph


is a matrix with rows and columns labeled by graph vertices, with a 1 or
0 in position (v_i,v_j) according to whether v_i and v_j are adjacent or
Adjacency Matrix not.

Also called an edge list, is one of the most basic and frequently used
representations of a network. Each edge in the network is indicated by
Adjacency Lists listing the pair of nodes that are connected.
CODES: ADJACENCY
LISTS
OUTPUT: ADJACENCY LISTS
CODES: ADJACENCY MATRIX
OUTPUT: ADJACENCY
MATRIX
FINAL LESSON 2:

HASH TABLES
Contents:
Definition of terms
Example program: (Add, Removing, Changing, Iterating Elements)
Output of the program
DEFINITION OF TERMS

Any non-null object can be used as a key or as a value. To successfully


store and retrieve objects from a hashtable, the objects used as keys must
Hashtable implement the hashCode method and the equals method.

Is a type of fast key lookup data structure that offers a flexible means of
Mapping indexing into its individual elements

Are control structures that allow sections of code to be executed


Loops repeatedly according to the controlling conditions of the loop
CODES: ADD ELEMENTS
OUTPUT: ADD ELEMENTS
CODES: REMOVING
ELEMENTS
OUTPUT: REMOVING
ELEMENTS
CODES: CHANGING
ELEMENTS
OUTPUT: CHANGING
ELEMENTS
CODES: ITERATING
ELEMENTS
OUTPUT: ITERATING
ELEMENTS

You might also like