Data Structures PRELIM

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/63

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

64 Terms

1
New cards

Data Types

all programming language has a set of built-in ____ ____

2
New cards

Abstract Data Types

  • specification of a set of data and set of operations performed in a data

  • storage for data defined in terms of set of operations to be performed on the data

3
New cards

Algorithms

finite set of instructions that specify a sequence of operations to be carried out

  • recipe for solving a problem

  • Example of simple algorithm

    - Apply to wet hair

    - Massage gently

    - Leave on for a few moments

    - Rinse Off

4
New cards

Criteria for Algorithm

  • Input - zero or more quantities are externally supplied

  • Output - at least one quantity is produced

  • Definiteness - each instruction must be clear and unambiguous

  • Finiteness - all instructions of an algorithm will terminate after a finite number of steps

  • Effectiveness - each operation must be definite, but must also be feasible

5
New cards

Input

zero or more quantities are externally supplied

6
New cards

Output

at least one quantity is produced

7
New cards

Definiteness

each instruction must be clear and unambiguous

8
New cards

Finiteness

all instructions of an algorithm will terminate after a finite

9
New cards

Effectiveness

each operation must be definite, but must also be feasible

10
New cards

Raw data

is an input to a computer and an algorithm is used to transform this into a refined data

11
New cards

PSEUDOCODE

  • textual presentation of a flowchart

  • close to a natural language

  • the control structures impose the logic

  • may become part of the program documentation

  • could be translated into a program

12
New cards

STEPWISE REFINEMENT

  • The process by which a programmer refines an initial idea to a problem's solution into more specific terms.

  • The last phase of refinement results in a program ready to be coded for execution

13
New cards

Analysis of Algorithms

determining the amount of resources necessary to execute it

such as time and storage

usually in terms of CPU time and memory requirements

Best-case analysis

• Worst-case analysis

• Average-case analysis

14
New cards

Data structure

is a special format for storing and organizing data.

15
New cards

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.

16
New cards

Linear

Elements are accessed in a sequential order but may be stored

unsystematically.

17
New cards

Non-Linear

Elements are stored and accessed in a non-sequential order.

18
New cards

Abstract Data Type

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.

19
New cards

Benefits of using ADT:

  • Code is easier to understand. o Implementations of ADTs can be changed without requiring changes to the program that uses the ADTs.

  • ADTs can be used in future programs.

20
New cards

Public or external

the data and the operations

21
New cards

Private or internal

the representation and the implementation

22
New cards

Linked list

is used for storing elements where each is a separate object.

23
New cards

Stack

is an ordered list in which insertion and deletion are done at one (1) end.

24
New cards

Queue

is an ordered list in which insertion and deletion are done at separate

ends.

25
New cards

Tree

represents a hierarchical nature of a structure in a graphical form.

26
New cards

Priority queue

is used for retrieving and removing either the minimum or

maximum element

27
New cards

Heap

is a partially sorted binary tree.

28
New cards

Set

represents a collection of elements that do not have to be in order.

29
New cards

Map

is a set of ordered pairs with elements known as key and value.

30
New cards

Graph

consists of a set of points/nodes (vertices) and set of links (edges) which

connects the pairs of vertices.

31
New cards

initializing, adding, accessing, and removing of data.

The four (4) main operations that could be defined for each ADT are _____

32
New cards

Algorithm

is a step-by-step set of instructions to be

executed in sequence for solving a problem.

33
New cards

Characteristics of an algorithm:

  • Finiteness: An algorithm must terminate after a specified number of steps.

  • Definiteness: Each instruction has to be clear and unambiguous.

  • Input: An algorithm should have zero or more well- defined data given before

the algorithm begins.

  • Output: An algorithm must have one (1) or more results, with specified relation

to the input.

  • Uniqueness: The result of each step depends on the input and/or the result of the previous step.

34
New cards

Finiteness

An algorithm must terminate after a specified number of steps.

35
New cards

Definiteness

Each instruction has to be clear and unambiguous.

36
New cards

Uniqueness

The result of each step depends on the input and/or the result of

37
New cards

Elements of an algorithm:

Sequential operations

Actions based on the state of a data structure.

  • Iteration – repeating an action multiple times.

  • Recursion – when a function calls itself once or

    multiple times to solve a problem.

38
New cards

Sequential operations

Actions based on the state of a data structure.

39
New cards

Iteration

repeating an action multiple times.

40
New cards

Recursion

when a function calls itself once or

multiple times to solve a problem.

41
New cards

Algorithm design paradigms:

  • Divide and Conquer – breaking a problem into smaller

subproblems.

  • Greedy Algorithms – always chooses the optimal approach

in solving a problem.

  • Dynamic Programming – similar to divide and conquer

except that the results of the subproblems are reused for

overlapping subproblems

42
New cards

Divide and Conquer

breaking a problem into smaller

subproblems.

43
New cards

Greedy Algorithms

always chooses the optimal approach

in solving a problem.

44
New cards

Dynamic Programming

similar to divide and conquer

except that the results of the subproblems are reused for

overlapping subproblems

45
New cards

Arrays

ordered collection of data items of the same type referred to collectively by a single name

46
New cards

Index

each variable or cell in an array

47
New cards

Elements

individual data / items in an array indicated by the array name followed by its dimensions appears in a square brackets

48
New cards

Dimensions

an integer from 1 – n called dimensioned variables

49
New cards

Operations in Arrays

  • Insert

  • Search

  • Delete

50
New cards

Insert

  • Adds item to the indicated place/cell

  • The process is very fast because it only includes one step

  • Every data inserted is placed in the first vacant cell

51
New cards

Search

  • Another process that the algorithm carries out

  • The red arrow from the figure states where the search starts

  • Moves methodically downwards to search for the item

52
New cards

Delete

  • The algorithm must first locate the item to delete it

  • The deleted item causes hole in the array

53
New cards

Basics of Arrays in Java

Arrays are treated as primitive type, they are treated as objects

use the new operator to declare an array

int arrayLength //find array length

intArray.length;

intArray name is a reference to an array and not the array itself

The length field of an array can be used to find the size in bytes:

int[] intArray; // declares a reference to an array

intArray = new int[100]; // initialize the array, and sets // intArray to refer to it

the size of an array, when created, can no longer be modified

54
New cards

One-dimensional Array

Array1[j]

55
New cards

Two-dimensional Array

Array1[i][j]

56
New cards

Multi-dimensional Array

Array[i][j][k]…

57
New cards

One-Dimensional Array

  • It is the basic array

  • A vertical table with number of columns and only one row

An array of ints

int[] intArray;

An array of Random objects

Random[] randomArray;

Arrays are fixed-length structure

58
New cards

Indices

  • used to access each location of arrays from 0 ranging up to the instantiated array

  • An array of length 10, instantiated as

59
New cards

Two-Dimensional Array

  • It is an array of an array

  • Also called as tables or matrices

  • Row – first dimension

  • Column – second dimension

60
New cards

Row

first dimension

61
New cards

Column

second dimension

62
New cards

Matrix

is a mathematical object which arises in many physical problems

63
New cards

Magic Square

is an n x n matrix of the integers 1 to n2

64
New cards

Transpose

another operation that can be performed on matrices that computes for the transpose of matrix