Programming for Problem Solving (PPS) Mid-II: Arrays, Strings, Recursion, Structures, File Handling, Searching and Sorting

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

1/46

flashcard set

Earn XP

Description and Tags

Vocabulary practice flashcards covering Arrays, Strings, Recursion, Enums, Structures, Unions, File Handling, Searching, and Sorting based on Programming for Problem Solving Mid-II course material.

47 Terms

1
New cards

Array

A collection of elements of the same data type stored in contiguous memory locations, referred to by a single name, and accessed using an index starting from 0.

2
New cards

One-Dimensional (1-D) Array

A linear list of elements of the same data type accessed using a single subscript (e.g., a[i]).

3
New cards

Two-Dimensional (2-D) Array

A collection of data elements organized into rows and columns (matrix or table) stored in row-major order and accessed using two subscripts (e.g., a[i][j]).

4
New cards

Row-Major Order

The memory storage arrangement for two-dimensional arrays in C where elements are stored contiguously row by row.

5
New cards

Matrix Multiplication Condition

The mathematical requirement that the number of columns of the first matrix must equal the number of rows of the second matrix (c1=r2c_1 = r_2) for multiplication to be possible.

6
New cards

Matrix Addition Condition

The rule stating that two matrices can only be added if they share the exact same order (identical numbers of rows and columns).

7
New cards

String (in C)

A sequence of characters stored in a char array and terminated by the null character '\0', requiring an array size of at least length +1+ 1.

8
New cards

Null Character ('\0')

The character constant with an ASCII value of 0 used to mark the end or termination of a string in C.

9
New cards

strlen()

A library function in with syntax strlen(str) that returns the length of a string without counting the terminating '\0'.

10
New cards

strcpy()

A library function in that copies the entire source string, including the null character '\0', into the destination array.

11
New cards

strncpy()

A library function in with syntax strncpy(dest, src, n) that copies at most n characters from the source string into the destination.

12
New cards

strcat()

A library function in with syntax strcat(dest, src) that appends the source string to the end of the destination string (concatenation).

13
New cards

strcmp()

A library function in that compares two strings character by character; returns 0 if they are equal, <0< 0 if the first is smaller, and >0> 0 if the first is greater.

14
New cards

strncmp()

A library function in with syntax strncmp(s1, s2, n) that compares only the first n characters of two strings.

15
New cards

strchr()

A string-handling library function in that finds the first occurrence of a specific character in a string.

16
New cards

strstr()

A string-handling library function in that finds the first occurrence of a substring within a larger string.

17
New cards

Substring

A portion of a main string taken from a specified starting index position for a specified length.

18
New cards

Recursion

A programming technique in which a function calls itself directly or indirectly to solve a problem by dividing it into smaller sub-problems of the same type.

19
New cards

Base Case

The stopping condition in a recursive function that is solved directly without further recursive calls, preventing infinite recursion.

20
New cards

Recursive Case

The branch of a recursive function in which the function invokes itself with modified parameters to progress toward the base case.

21
New cards

Calling Phase (in Recursion)

The initial phase of recursion where each consecutive function call pushes a new activation record (containing parameters, local variables, and return address) onto the call stack.

22
New cards

Returning Phase (in Recursion)

The second phase of recursion, initiated after reaching the base case, where stacked calls are popped one by one in LIFO order and each returns its value to its caller.

23
New cards

Stack Overflow

A runtime failure that happens when a recursive function lacks a proper base case or fails to reach it, resulting in endless calls that exhaust stack memory.

24
New cards

Factorial (Recursive Formula)

The mathematical product of integers from 1 to n defined recursively as n!=n×(n−1)!n! = n \times (n - 1)!, with base cases 0!=10! = 1 and 1!=11! = 1.

25
New cards

Fibonacci Series

A sequence of numbers where each term is the sum of the preceding two terms, defined recursively by fib(n)=fib(n−1)+fib(n−2)fib(n) = fib(n - 1) + fib(n - 2) with fib(0)=0fib(0) = 0 and fib(1)=1fib(1) = 1.

26
New cards

Enumerated Data Type (enum)

A user-defined data type in C consisting of a set of named integer constants, where the first identifier defaults to 0 and each subsequent one increments by 1 unless explicitly assigned.

27
New cards

Structure (struct)

A user-defined data type in C that groups variables of different data types under a single name, where each member is assigned its own separate memory.

28
New cards

Dot (.) Operator

The member access operator in C used to access individual members of a structure or union variable (e.g., variable.member).

29
New cards

Nested Structure

A structure that contains another structure variable as one of its internal members, accessed using chained dot operators (e.g., s.dob.day).

30
New cards

Array of Structures

An array in which every element is an individual structure variable of the same type, typically used to store collections of records.

31
New cards

Union

A user-defined data type in C where all members share the same single memory location, the allocated size equals the largest member, and only one member can store a valid value at a time.

32
New cards

File Pointer (FILE *)

A pointer variable of type FILE declared in that points to a structure containing information used to track and control an opened file.

33
New cards

fopen()

A C file-handling function with syntax fopen("filename", "mode") that opens a file and returns a FILE pointer, or NULL if the operation fails.

34
New cards

File Mode "r"

A file-opening mode that opens an existing text file for reading only, setting the file pointer at the beginning; returns NULL if the file does not exist.

35
New cards

File Mode "w"

A file-opening mode for writing only that creates a new text file if it does not exist, or truncates (erases) existing contents if the file already exists.

36
New cards

File Mode "a"

A file-opening mode for appending that creates a new file if nonexistent, or adds new data exclusively to the end of the file without erasing existing contents.

37
New cards

fprintf()

A file-handling function that writes formatted data into an opened file according to format specifiers, analogous to printf().

38
New cards

fscanf()

A file-handling function that reads formatted input from an opened file into specified variable addresses, returning the number of items successfully read or EOF on failure.

39
New cards

fputc()

A file-handling function with syntax int fputc(int ch, FILE *fp) that writes a single character to a file.

40
New cards

fgetc()

A file-handling function with syntax int fgetc(FILE *fp) that reads a single character from a file and returns EOF when reaching the end of the file.

41
New cards

fwrite()

A binary file-handling function used to write contiguous blocks of data (such as records, structs, or arrays) directly into a file.

42
New cards

fread()

A binary file-handling function used to read contiguous blocks of data from a file directly into memory.

43
New cards

Linear Search

A sequential searching algorithm that checks every array element one by one from start to end until the key is found or the list ends; works on unsorted data with O(n)O(n) worst-case complexity.

44
New cards

Binary Search

A divide-and-conquer search algorithm for sorted arrays that compares the target key to the middle element, repeatedly discarding half the remaining search space with O(log⁡(n))O(\log(n)) worst-case complexity.

45
New cards

Bubble Sort

A sorting algorithm that repeatedly compares adjacent elements and swaps them if they are in the wrong order, causing the largest unsorted element to bubble up to the end each pass.

46
New cards

Selection Sort

A sorting algorithm that repeatedly selects the minimum element from the unsorted sub-array and places it at the beginning, executing at most n−1n - 1 swaps with O(n2)O(n^2) time complexity.

47
New cards

Insertion Sort

A sorting algorithm that sequentially takes each element from the unsorted portion and shifts larger elements in the sorted portion to insert it into its correct position.