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

TABLE OF CONTENTS

INTRODUCTION TO DATA TRAVERSING TREES 32 - 39


2-9
PRELIM SEMI-FINALS
STRUCTURE
SELECTION SORT 40 - 44
ARRAY CONCEPT 10 - 13 ALGORITHM

QUICK SORT ALGORITHM 45 - 49


STORAGE ALLOCATION /
ARRAY WITH 14 - 17
IMPLEMENTATION OF LINKED
LIST

GRAPH DATA STRCTURE 51 - 59

FINALS
STACK DATA STRUCTURE 19 - 22
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

Syntax
items.

Index
The syntax is the same as
for a normal variable
declaration except the
A numeric value starts variable name should be
with zero (0). Each follow by subscript to
element can be accessed specify the size of
via its index dimension of the array
SAMPLE PROGRAM
CODES
SAMPLE PROGRAM
OUTPUT
PRELIM LESSON 3:
STORAGE ALLOCATION / ARRAY
WITH IMPLEMENTATION OF
LINKED LIST
Contents:
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
information “on 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
structure where each element
of data elements which provides an
(called a node) is made up of
efficient way of storing and organizing data
two items: the data and a
in the computer so that it can be used
reference (or pointer), which
efficiently.
points to the next node

STACK Queue
Array
Implementation
Stack is an abstract data type that holds an An abstract data structure,
ordered, linear sequence of items. In contrast to a somewhat similar to Stacks.
queue, a stack is a last in, first out (LIFO) structure. Unlike stacks, a queue is open
A real-life example is a stack of plates: you can only at both its ends. The stack is formed by using
take a plate from the top of the stack, and you can the array.
only add a 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
property of a tree
Complete Binary Tree
root, node, and vertices

Internal Nodes A tree data structure that has each


node have a maximum of
External Nodes
Any node except the root two children The node below a given
node that has at least node
one child

Forest Subtree Level of Nodes


represents the number of nodes in the
a set of trees. descendants of path from the node to
a node. the 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)

Tree Traversal
each vertex in a graph.

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
Algorithm
the arrangement of data in a
prescribed sequence

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

QUICK SORT ALGORITHM


Contents:
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, purpose, and comparison- order that they appear in the
and so it's a recursive based sorting algorithm. input.
algorithm. 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
accessible to the CPU. items 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
Graphs computer 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
Adjacency Matrix adjacent or 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
Adjacency Lists by 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 implement the hashCode method and the equals
Hashtable method.

Is a type of fast key lookup data structure that offers a flexible means
Mapping of 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