L1- PEDAC + Selection&Transformation + Arr Element Flashcards

1
Q

What do the letters of PEDAC stand for?

A

P - [Understand the] Problem

E - Examples / Test cases

D - Data Structure

A - Algorithm

C - Code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is involved with PROBLEMS in PEDAC? (6 things)

A

Understand the problem
1.
- read the problem description
- examine all given examples for info

  • identify INPUTS/OUTPUTS
  • identify RULES/REQUIREMENTS. Restate descriptions in a way that make sense to you to help identify explicitly what is required.
  • mental model problem. Sort of like a very simple algorithm. Just describe what you broadly need to do.
  • ask clarifying questions (all these assumptions about edge cases, what data types it should handle, just ask!)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is involved with EXAMPLES in PEDAC (4 things)

A
  • understand how the input translates to output
  • identify VALID CASES
  • identify EDGE CASES
  • create the test cases and confirm outputs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is involved with DATA STRUCTURES in PEDAC? (3 things)

A
  • what sort of actions do you have to do (sort, collect, filter, etc.)
  • what kind of data are you primarily dealing with for inputs/outputs? (strings, arrays, numbers, objects, etc.)
  • focus on methods for these types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is involved with ALGORITHM in PEDAC? (2 things)

A
  • step by step process that takes you from input to output, your code will depend on your algorithm
  • handles edges cases and valid example inputs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the pseudocode format for multiple functions

A

// Algorithm:
// substrings function
// =================
// - create an empty array called result that will contain all required substrings
// - create a startingIndex variable (value 0) for the starting index of a substring
// - start a loop that uses startingIndex to iterate over string from 0 to the length of the string minus 2
// - create a numChars variable (value 2) for the length of a substring
// - start an inner loop that uses numChars to iterate over string from 2 to string.length - startingIndex
// - extract a substring of length numChars from string starting at startingIndex
// - append the extracted substring to the result array
// - increment the numChars variable by 1
// - end the inner loop
// - increment the startingIndex variable by 1
// - end the outer loop
// - return the result array

// isPalindrome function
// =====================
// - Inside the isPalindrome function, check whether the string
// value is equal to its reversed value.

// palindromeSubstrings function
// ============================
// - declare a result variable and initialize it to an empty array
// - create an array named substrArray that will contain all of the
// substrings of the input string that are at least 2 characters long.
// - loop through the words in the substrArray array.
// - if the word is a palindrome, append it to the result array
// - return the result array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The pseudo code keywords (8)

A

Keyword Meaning
START start of the program
SET set a variable that we can use for later
GET retrieve input from user
PRINT display output to user
READ retrieve a value from a variable
IF/ELSE IF/ELSE show conditional branches in logic
WHILE show looping logic
END end of the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is filtering, selection, and transformation?

A

Selection- Selection is picking some elements out of a collection depending on one or more criteria. For example, you might want to pick out all the odd numbers from an array.

Transformation- refers to manipulating every element in the collection. For example, increment all elements of an array by 1. Though we didn’t change all of the elements, we can reasonably say that we performed a transformation on the array, it’s just that the transformation left some elements unchanged.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Transforming happens ONLY when a mutation occurs
T or F

A

F
Both mutation and returning and be referred to transformation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Does this:
let array = [1]
array[‘4’] = 2
effect the length of the array? Or is it just a key named ‘4’

A

Yes it does.
An array’s elements are basically numbered keys with additional functionality. So giving it a string key is the same as going array[4] = 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a sparse array?

A

an array with empty items

How well did you know this?
1
Not at all
2
3
4
5
Perfectly