Data Structure and Algorithms (Midterm Reviewer)

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

1/92

flashcard set

Earn XP

Description and Tags

SCOPE Introduction to C++ Selection Structure for Loop Introduction to Data Structures and Algorithms Arrays Functions Structures

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

93 Terms

1
New cards

C++

a good foundation of learning other programming languages like Java, Python, etc.

2
New cards

Bjarne Stroustrup

C++ general-purpose programming language developed by__________as an extension of the C language.

3
New cards

int main()

entrypoint of the program. The codes in main will be executed.

4
New cards

return 0;

exit status of the application. If 0 is the exit status, the program worked fine until the end, without errors.

5
New cards

cout<<

is used for printing a certain text or number. To use, the header file must be included

6
New cards

<<insertion operator

That sends the text or value in the console to be printed.

7
New cards

Data Structure

a way of arranging data on a computer so that it can be accessed and updated efficiently

8
New cards

Escape Sequences

are special characters characterized by a backslash (\) and a letter or symbol beside it

9
New cards

Escape Sequences

used in cout statements to show spaces, new lines, or show symbols that cannot be outputted using the normal way of printing

10
New cards

New Line

Moves the cursor to the beginning of the next line.

11
New cards

/n

What is new line symbol?

12
New cards

Tab

Inserts a horizontal tab.

13
New cards

\t

What is tab symbol?

14
New cards

Pre defined and user defined functions

Function two Types are ___________, ____________?

15
New cards

Function Declaration

Function Definition

Function Call

The Three Function Aspects are?

16
New cards

\\

What is symbol of backlash character?

17
New cards

Variables

they act as containers or buckets where the data will be put into and stored

objects that are used to store values

18
New cards

Variable

A___________ data type remains as it is once declared, so when you try to assign a letter to an integer variable, the character value will be converted into its integer equivalent.

19
New cards

- American Standard Code for Information Interchange

What is the meaning of ASCII?

20
New cards

65

ASCII of “A”

21
New cards

97

ASCII of “a”

22
New cards

48

ASCII of “o”

23
New cards

cin>>

allows the user to type in the data asked by the program. works if the iostream header file is included.

24
New cards

>> extraction operator

that reads the input from the keyboard

25
New cards

Algorithm

a set of well-defined instructions to solve a particular problem it takes a set of input(s) and produces the desired output.

26
New cards

Good Quality Program

precisely defined input and output

clear and unambiguous steps

most effective in solving problems

not written in computer code

usable in any programming language

27
New cards

Data Structures

a storage that is used to store and organize data

a way of arranging data on a computer so that it can be accessed and updated efficiently

28
New cards

Linear Data Structures

elements are arranged in sequence one after the other, making it easy to implement.

29
New cards

Linear Data Structures

Examples: arrays, stacks, queues, linked lists

30
New cards

Nonlinear Data Structures

Elements are not in any sequence. They are arranged in a hierarchical manner where one element will be connected to one or more elements.

31
New cards

Nonlinear Data Structures

Examples: graphs and trees

32
New cards

Data Structure

are used to hold data

33
New cards

Algorithm

used to solve the problem using that data.

34
New cards

Arrays

It is an ordered collection of values of the same type.

Elements can be accessed via its index (address, location).

All arrays consist of contiguous memory locations.

35
New cards

One-dimensional Arrays

It is made up of one row or one column of array members with the same name but different index values

36
New cards

2D Array

is the most basic type of multi-dimensional array.

37
New cards

Outer Loop, Inner Loop

Using for loop to access all elements of the 2D array. The ________ is for the rows, the________ is for the columns.

38
New cards

Functions

Container for a few lines of code to accomplish a specific task

Set of programming statements enclosed in { and }

39
New cards

Functions

For reusability and modularity, they can be called numerous times.

40
New cards

Pre-defined Functions.

Built into the language to perform operations. It is stored in Standard Function Library.

41
New cards

User-defined Functions.

Defined by the user to perform specific tasks.

42
New cards

Function Declaration

tells the compiler about a function name and how to call the function.

43
New cards

Function Definition

contains the actual statements which are to be executed

44
New cards

Function Call

performs the defined tasks

45
New cards

Actual Parameters or arguments

are values which are passed in the function call.

46
New cards

Formal Parameters

are variables local to that function and cannot be used in other parts of the program,

47
New cards

return Keyword

Terminates the function and returns the value.

48
New cards

-Define the function’s return data type

-Use the return keyword inside the function body.

Two things are required to return a value to the caller:

49
New cards

void Keyword

It is defined before the function name.

The call to the void function is a standalone statement.

Void functions don’t need to have the return statement

50
New cards

Recursive Functions

A function whose definition contains a call to itself.

51
New cards

TAIL RECURSION

• The function calls itself as the final statement of the function.

• When it is called, it must process or carry out some action.

• It does nothing after that call.

52
New cards

HEAD RECURSION

• The initial statement of a recursive function is also the first time it calls itself.

• At the time of calling, is not required to process anything.

• Everything is completed when the method returns.

53
New cards

LOCAL VARIABLES

Only statements that are inside that function or block of code can use them.

• They are not known to functions outside their own.

54
New cards

GLOBAL VARIABLES

• Their values are maintained throughout the life of your program.

• It may be accessed from any of the program’s functions.

55
New cards

Base case, Recursive case

A recursion has two parts:

56
New cards

Base Case

Or the halting case. It is the indication of when the recursion will stop.

57
New cards

Recursive Case.

It is the recursive call with a different input that progressively gets closer to the base case.

58
New cards

Structures

A collection of different data types under a single name.

Used to express data about anything that is more complex than what can be represented by a single integer, character, or Boolean.

59
New cards

Importance of Structure

-compile multiple pieces of information on a single topic in one location

-collect data of the same data kinds and parameters incredibly simple to maintain

-aggregating together related data in one entity through the struct keyword allows programs to construct user-defined types.

60
New cards

Syntax and Implementation

Structures are declared by starting with the struct keyword then the structure name (identifier).

Inside the curly braces are the member variables with different data types.

61
New cards

Accessing Elements

Use the dot [.] operator to access the inner variables of the structure

62
New cards

Typedef

is a keyword used to specify alternative names for primitive types.

63
New cards

typedef struct,

With the application of ____________ variable declaration no longer needs the keyword struct.

64
New cards

True

True or False | The main method is the entrypoint of the program

65
New cards

std::cout

statements to show spaces, new lines, or show symbols that cannot be outputted using the normal way of printing.

66
New cards

#include<iomanip>

to be able to use std::setprecision, defines the manipulator functions that are used to manipulate the format of the input and output of our program. It is a part of the input/output library in C++.

67
New cards

std::cout << std::fixed;

this is needed to change the default formatting of the numbers that are printed to "fixed-point notation".

68
New cards

std::setprecision(3)

- this is the line that sets the number of decimal places to be printed.

69
New cards

Namespace

cout is part of the standard library, and all the elements in the standard C++ library are declared within what is called a ____________

70
New cards

Character

A letter, symbol, or white space). This should be enclosed in single quotes.

71
New cards

Integer

Whole numbers ranging between ±32767.

72
New cards

Floating Point Values

Real numbers that can handle up to 7 decimals. To indicate

that it is float, you should add an f at the end of the value.

73
New cards

Double Floating Point Values

Real numbers that can handle up to 15 decimals

Double is just the same as a

Float but can hold larger

numbers.

74
New cards

Boolean

Truth values (true/false).

75
New cards

Constant variables

are special type of variables whose values can't be changed.

76
New cards

const data_type CONSTANT_NAME = value;

Declaring a constant variable using that follows this

syntax:

77
New cards

Uppercase letters

The naming of constants are usually in____________ to easily identify that the variable is indeed a constant.

78
New cards

Comments

in your code will not be executed because they serve as guide to the programmers, which makes it very useful especially when making a project with lots of lines of codes.

79
New cards

Flat Case

All words are in lowercase but connected directly.

80
New cards

Camel Case

Uncapitalized first word, capitalized proceeding words (like a camel shape) and connected directly.

81
New cards

Pascal Case

All words are capitalized and connected directly.

82
New cards

Snake Case

All words are in lowercase and connected by an underscore (_).

83
New cards

Macro Case

All words are in uppercase and connected by an underscore (_).

This casing is often used in constants.

84
New cards

Overriding Shortcuts

There are instances when we wish to perform calculations on the value of a variable and then overwrite the value of the variable by the result it garnered.

85
New cards

pow ( )

Returns the value of the left operand

(base) raised to the power of the right

operand (exponent).

86
New cards

sqrt ( )

Returns the square root of a number.

87
New cards

floor ( )

Rounds down a number to the largest

integer less than or equal to the number.

88
New cards

ceil ( )

The opposite of floor. Rounds up the

number to the smallest integer greater

than or equal to the number

89
New cards

fabs ( )

Returns the absolute, positive value of num.

90
New cards

Data Structure

-a storage that is used to store and organize data

. It is a way of arranging data on a computer so that it can

be accessed and updated efficiently

91
New cards

Graphs

Example of Non-Linear Data Structure that each node is called vertex, and each vertex is connected to other vertices through edges.

92
New cards

Trees

Example of Non-Linear Data Structure also a collection of vertices and edges. But there can only be one edge between two vertices.

93
New cards

ARRAY TRAVERSAL

-Used for visiting, accessing, and printing each element of an array exactly once

• It is necessary to create a variable that will track the position of the element that is currently being accessed