0% found this document useful (0 votes)
15 views4 pages

DATA-STRUCTURE-AND-ALGORITHMS-REVIEWER

Uploaded by

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

DATA-STRUCTURE-AND-ALGORITHMS-REVIEWER

Uploaded by

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

DATA STRUCTURE AND ALGORITHMS REVIEWER

DEFINITIONS of Data Structures:


 is a way of organizing information effectively
 a specialized format for organizing and storing data
 means of storing a collection of data in an organized and efficient way
 refers to a collection of variables, possibly of different data types connected in
various ways

DATA STRUCTURES
> means of storing a collection of variables.
Samples of data type:
 Character
 Integer
 String
 Boolean
 Float
Basic Data Structures are:
 Arrays
 List
 Stacks
 Queues
 Graph
 Tree

ALGORITHM
> a recipe for solving a problem.
> a predetermined series of instructions for carrying out a task in a finite number
of steps.
2 Representation of ALGO:
1. FLOWCHART
-a graphical representation of an algorithm using standardized symbols
2. PSEUDOCODE
- initially a textual representation of an algorithms flowchart
(derived from pseudo and code) is a description of a computer programming
algorithm that uses the structural conventions of programming languages, but omits
detailed subroutines or language-specific syntax.
Symbol used in Flowchart
Oval- Denotes the beginning or ed of a program.
Flow line- Denotes the direction of logic flow in a program.
Parallelogram- Denotes either an input operation (e.g.., INPUT) or an output
operation (e.g. PRINT).
Rectangle- denoted a process to be carried out (e.g.., an addition).
Diamond- Denotes a decision (or branch) t be made. The program should continue
along one to two routes. (e.g.., IF/THEN/ELSE).
Translating Flowcharts into Pseudocodes
> The pseudecode of a procedure begins with a procedure name followed by open
and close parentheses, ().
> Words enclosed in open and close parentheses, (), present parameters.
> An open and close curly bracket, {}, enclose the pseudecode statements within a
procedure.
> Words enclosed in the “/” and “*/” pair are comments.
> A sequence of dots, ..., means that the preceding statements may be repeated as
necessary.

IF STATEMENT
When using the IF statement, Statement 1 is executed when Condition is true.
Processing then continues with Statement 2. When Condition is false, Statement 1 is
ignored and execution proceeds directly to Statement 2.
IF-ELSE STATEMENT
The IF-ELSE statement is a conditional statement that provides the computer with a
choice between two options.
In the IF-ELSE statement, Statement 1 is executed when Condition is true.
Processing then continues with Statement 3.When Condition is false, Statement 2 is
processed followed by Statement 3.
SWITCH STATEMENT
The SWITCH statement is basically an expansion of the IF-ELSE statement. It provides
a mechanism of choosing an option of several possibilities.
WHILE STATEMENT
The WHILE statement allows the computer to repeatedly perform a series of
statements based on a particular condition.
In the WHILE statement, Condition is tested before each iteration of the loop.
Statement 1 is executed if and only if Condition is true; thus it is possible that
Statement 1 is not executed at all. Once Condition is false, execution continues with
Statement 2.

ARRAYS(Module 2)
One of the simplest and most common type of data is the list. By definition, a list is
an ordered set consisting of a variable number of elements to which additions and
deletions may be made. If applicable. A list which displays the relationship of the
physical adjacency is called a linear list.

A linear list is a finite sequence of simple data items or records. Each of the
elements in a list forming a sequence (except for the first and last elements) has a
single successor and a single predecessor.
Ex.
Days of the week (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday,
Sunday)
Value in a Deck of Cards (2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, Ace)
Floors of a Building (Basement, Lobby, Mezzanine, First, Second, Third)
LINEAR LIST OPERATIONS
1. Finding the length of the list, n.
2. Reading the list from left to right (or right to left).
3. Retrieving the ith element in the list, 1 ≤ I ≤ n.
4. Sorting a new value into the ith position, 1 ≤ I ≤ n.
5. Inserting a new element at position I, where 1 ≤ I ≤ n, causing element numbered
I,i+1, …, n to become numbered i+1, i+2, …, n+1.
6. Deleting the element at position I, where 1 ≤ I ≤ n, causing element numbered I+1,
i+2, …, n to become numbered i, i+1, …, n-1.
7. Sorting the elements in the list into ascending or descending order.
8. Copying a list into another list.
9. Merging two or more lists from a new list.
10.Splitting a list into several sublists.

DEFINITION
The most common way of representing a linear list is through the use if an array. It is
appropriate that we begin our study of data structures with the array since the array
is often the only means provided in a programming language for structuring data.

An array may be defined as an ordered collection of data items of the same type
referred to collectively by a single name (the name of the array).
Individual items in an array are called elements. Array elements are ordered
according to subscripts (an integer from 1 to n); for this reason, they are sometimes
called subscripted variables.

Dimensionality of an Array
An array with only one subscript, for example, Array1[j], is called one-dimensional
array. In the same manner, an array two subscripts, as in Array1[I,j], is called two-
dimensional array. Arrays with more than two subscripts are call multi-dimensional
arrays.

ONE-DIMENSIONAL ARRAYS

Retrieving the ith Element of a One-Dimensional Array


> Retrieving the ith element of an array simply involves the specification of the array
name along with subscript of the desired element.
Reading the Elements of a One-Dimensional Array from Left to Right

Read_Arr ( Arr1,N)
{
Set Ctr to 1
While (Ctr<=N)
{
Print Arr1[Ctr1]
Increment Ctr
}
}
Storing a New Value into an Element of a One-Dimensional Array
Storing a value into an element of an array overwrites whatever value the element
previously contained. The process of assigning a value to an array element simply
requires referencing the element’s position and setting its value.

Deleting an Element from One-Dimensional Array


The elements of an array cannot be “physically” deleted. This is because the size of
an array, once defined, always remains the same. Instead, array element may be set
to a specific value, for example, blank, to signify deletion.

Sorting the Elements of a One-Dimensional Array in Ascending Order

Sort_Arr(Arr1,N)
{
Set Ctr to 1
While (Ctr1 <= N-1)
{
Set Ctr2 to Ctr1+1
While (Ctr2 <= N)
{
If (Arr1[Ctr1] > Arr1[Ctr2]) then
{
Set Temp to Arr1[Ctr1]
Set Arr1[Ctr1] to Arr1[Ctr2]
Set Arr1[Ctr2] to Temp
}
Increment Ctr2
}
Increment Ctr1
}
}

Copying a One-Dimensional Array


Merging Two One- Dimensional Arrays
Splitting a One-Dimensional Array

TWO-DIMENSIONAL ARRAYS
A two-dimensional array is an array with two subscripts. The first subscript is called
the row and the second subscript is referred to as the column. Because of this
property, twodimensional arrays are often called tables of matrices. To reference an
element of dimensional array, both the row number and column number of the
desired element must be specified. For example, the statement Arr1[2,3] accessed
the element in the second row, third column of the two-dimensional array Arr1.

You might also like