C++ Programming: Lists and Strings

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

1/30

flashcard set

Earn XP

Description and Tags

Flashcards covering key concepts from a C++ programming lecture on lists, arrays, and strings.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

31 Terms

1
New cards

List

A variable-length, linear collection of homogeneous elements.

2
New cards

Linear (in the context of a list)

Each list element (except the first) has a unique predecessor, and each element (except the last) has a unique successor

3
New cards

Constructors

Create a new instance (object) of an ADT.

4
New cards

Transformers

Change the state of one or more of the data values of an instance.

5
New cards

Observers

Allow client to observe the state of one or more of the data values of an instance without changing them.

6
New cards

Iterators

Allow client to access the data values in sequence.

7
New cards

List Transformer Operations

Insert, Delete, Sort

8
New cards

List Observer Operations

IsEmpty, IsFull, Length, IsPresent

9
New cards

List Iterator Operations

Reset, GetNextItem

10
New cards

Reset (Iterator)

Prepares for the iteration.

11
New cards

GetNextItem (Iterator)

Returns the next item in sequence.

12
New cards

Unsorted List

Elements are placed into the list in no particular order.

13
New cards

Sorted List

List elements are sorted in some way -- either numerically or alphabetically.

14
New cards

Selection Sort Algorithm

Find minimum value in data[passCount . . length-1] and swap minimum value with data[passCount]

15
New cards

Insert Algorithm for SortedList ADT

Create space for the new item by shifting down all the larger list elements, put the new item in the list, and increment the length.

16
New cards

Delete Algorithm for SortedList ADT

Find the position of the element to be deleted from the sorted list, eliminate space occupied by the item being deleted by shifting up all the larger list elements, and decrement length.

17
New cards

Binary Search

Examines the element in the middle of the array to determine if the sought item, then continues accordingly.

18
New cards

Order of Magnitude (Big-O notation)

Describes the complexity of an algorithm according to the highest order of N that appears in its complexity expression.

19
New cards

O(1)

constant time

20
New cards

O(log2N)

logarithmic time

21
New cards

O(N)

linear time

22
New cards

O(N^2)

quadratic time

23
New cards

O(N^3)

cubic time

24
New cards

C String

A char array terminated by the null character ‘\0’.

25
New cards

Extraction operator >> (for C strings)

Skips any leading whitespace characters such as blanks and newlines, then reads successive characters into the array, stopping at the first trailing whitespace character, and adds the null character to the end of the string.

26
New cards

Function get() (for C strings)

Does not skip leading whitespace characters, reads successive characters (including blanks) into the array, stops when it either has read count characters, or it reaches the newline character ‘\n’, appends the null character to str. If newline is reached, it is not consumed by get, but remains waiting in the input stream.

27
New cards

Function ignore()

Can be used to consume any remaining characters up to and including the newline ‘\n’ left in the input stream by get.

28
New cards

strlen (C string function)

Integer length of string str (not including ‘\0’).

29
New cards

strcmp (C string function)

Negative, if str1 precedes str2 lexicographically; positive, if str1 follows str2 lexicographically; 0, if str1 and str2 characters same through ‘\0’.

30
New cards

strcpy (C string function)

Base address of toStr (usually ignored). Characters in string fromStr are copied to string toStr, up to and including ‘\0’, overwriting contents of string toStr.

31
New cards

typedef char String20[21]

Names String20 as an array type.