DSAcpp-ch1-2

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/40

flashcard set

Earn XP

Description and Tags

key concepts and definitions in DSA

41 Terms

1
New cards

Phases of Software Development

Specification, Design, Implementation, Analysis, Testing/Debugging, Maintenance, and Obsolescence

2
New cards

Algorithm

A set of instructions for solving a problem

3
New cards

Pseudocode

A mixture of English and a programming language, used to design algorithms without being distracted by language syntax.

4
New cards

Decomposing the Problem

Break a task into a few subtasks, then decompose each subtask into smaller ones, and so on, until each piece is trivial to implement as a separate C++ function. Good subtasks favor code reuse and produce code that is easy to modify (information hiding: each function should know only as much about the others as necessary)

5
New cards

Procedural Abstraction

using a function (or any function call) without needing to know how it is implemented — only what it does. Achieve through precondition/postcondition contracts.

6
New cards

Precondition

A statement of the condition that must be true when a function is called. The function is not guaranteed to work correctly unless the precondition holds.

7
New cards

Postconditon

A statement describing what will be true when the function call completes, provided the precondition was true when it was called.

8
New cards

const <Data type> <Variable name> = <Value>;

A declared constant’s value cannot change while the program runs. Style convention: use ALL_CAPITALS for constant names

9
New cards

Time Analysis

Reasoning about how many operations an algorithm requires, generally as a function of the size of the input n, rather than measuring actual elapsed time (which depends on irrelevant factors like processor speed).

10
New cards

Big-O Notation

Expresses the order of an algorithm by keeping only the fastest-growing term of the operation-count formula and dropping multiplicative constants (e.g. both 2n and 42n are O(n)). The order of an algorithm generally matters more than processor speed.

11
New cards

Worst-Case Analysis

Counts the maximum number of operations required for any input of a given size n.

12
New cards

Average-Case/Best-Case Analysis

Counts the maximum number of operations required for any input of a given size n.

13
New cards

Linear Pattern

A loop that performs a fixed amount of work n times requires O(n) time.

14
New cards

Program Testing

Running a program and observing its behavior/timing on specific inputs.

15
New cards

Properties of Good Test Data

You must know what output a correct program should produce for each test input. The test inputs should include those most likely to cause errors.

16
New cards

Boundary Value

An input that is “one step away” from different program behavior (e.g. the lowest/highest legal value of a range). Consider 0, 1, and -1 as boundary values whenever they are legal inputs.

17
New cards

Fully Exercising Code

Ensure every line of code executes at least once by some test input. If part of the code can be skipped, endure at least one test input actually skips it. A profiler tool helps verify this by reporting how often each statement executed.

18
New cards

Debugger

A software tool that executes code one line at a time (or until a specified condition), letting you watch variable values and pause execution to track down bugs.

19
New cards

Object-Oriented Programming

An approach in which data is packaged into objects; objects are manipulated by member functions that belong to them.

20
New cards

Class

The C++ mechanism for creating a new data type made of data (member variables) and member functions. A class supports information hiding.

21
New cards

Abstract Data Type

A mathematical data type presented to programmers purely through its behavior (information hiding) — in practice, the term is often used interchangeably with “class” when information hiding is emphasized.

22
New cards

bool type

built-in true/false type (C++ Standard). Relational operators (==, !=, <, <=, >, >=) produce bool values; && (and) || (or), !(not) combine them.

23
New cards

Modification Member Function

A public member function that can change an object’s value

24
New cards

Constant Member Function

A member function, marked with trailing const, that may only examine — never modify — the object.

25
New cards

Private Member Variable

Data stored inside the class but accessible only to the class’s own member functions, not to outside code.

26
New cards

Scope Resolution Operator (::)

Used before a member of a function’s name in its full definition to tell the compiler which class the function belongs to.

27
New cards

Constructor

A special member function is automatically called whenever an object of the class is declared. Rules: same name as the class; no return type — not even void; may take parameters, whose arguments are given after the variable name at declaration.

28
New cards

Default Constructor

A constructor with no parameters (or with default arguments for all parameters). Calle automatically when an object is declared with no argument list.

29
New cards

Inline Member Functions

An inline member function’s full body is placed directly in the class definition (no trailing semicolon issues; no separate implementation needed). Best used only for very short, simple functions.

30
New cards

Namespace

A name a programmer chooses to group their own work and avoid name conflicts with other programmer’s code. Should include part of the programmer’s real name/email to stay unique

31
New cards

Macro Guard

A compiler directive block (#ifndef / #define / #endif) that prevents a header file’s contents (especially a class definition) from being compiled twice if the header is included more than once.

32
New cards

Assignment Operator

For objects x and y, y = x; copies x’s value into y. By default (“automatic assignment operator”), C++ copies each member variable individually.

33
New cards

Copy Constructor

A constructor with exactly one parameter of the same class type, used to initialize a new object as a copy of an existing one. C++ provides an automatic copy constructor that copies all member variables.

34
New cards

Three Kinds of Parameters

Value, Reference, and Const

35
New cards

Value parameter (point p)

Argument is copied into a local variable; changes inside the function do NOT affect the caller’s argument.

36
New cards

Reference parameter (point& p)

Refers directly to the caller’s argument; changes inside the function DO affect the argument.

37
New cards

Const reference parameter (const point& p)

efficient like a reference (no copy) but guaranteed no to be modified by the function

38
New cards

Operator Overloading

Defining the meaning of a built-in C++ operator (such as ==, +, << ) for a new class, by writing a function named operator followed by the operator symbol

39
New cards

Friend Function

A function that is not a member function but is granted access to a class’s private members by listing its prototype inside the class definition, preceded by the keyword friend. Should be limited to functions written by the class’s own implementor.

40
New cards

Standard Template Library

a collection of ready-made, reusable C++ container classes (like pair) available in every C++ program, so common data structures don’t need to be built from scratch

41
New cards

Pair

The two data types are specified in angle brackets —- pair <int, double> — called a template instantiation. first and second are public member variables and may hold different (or the same) data types.