Unit 6-lists, loops, and transversals Flashcards

1
Q

list

A

an ordered collection of elements

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

element

A

an individual value in a list that is
assigned a unique index

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

index

A

a common method for referencing the elements in a list or string using numbers (lists in Javascript start with index 0

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

length

A

how many elements it contains, The length of the list is 1 more than the last index

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

How are lists an example of data abstraction?

A

They allow us to name and program with large collections of information while ignoring the low level details of how the data is stored, organized, etc.

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

what is a While Loop and how does it work?

A

uses a boolean condition to repeatedly run a block of code. If it is true it runs the block of code contained within it.
-This process of checking the condition and running the block of code is repeated as long as the Boolean condition remains true. -Once the Boolean expression becomes false it will stop.

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

for Loop

A

condenses the parts of a while loop into a shorter statement. Like the while loop, once the Boolean expression becomes false, the loop ends.

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

What are the three components of for and while loops?

A

Create a count/index variable
Ex. var count = 0

Write a while loop to check a condition
Ex. while (count <10)…

Increase/Decrease the value of count/index variable
Ex. …count ++

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

What is an iteration and what is an example?

A

Iteration (loops): a repetitive portion of an algorithm which repeats a specified number of times, while a condition is met, or until a given condition is no longer met
- an example is loops!

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

What is in an infinite loop and when do they occur?

A

occurs when the while condition is always true (or the ending condition will never occur); will result in cycling through a set of commands forever without stopping

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

When would you want to use a loop versus a function

A

Use a function when you have a piece of code (a procedure) that you might reuse in other places in your program.
Use a loop when there is something you need to do over and over again repeatedly (consecutively) or when you don’t want to call a function many times in a row manually.
Use a loop when you don’t want to call a function many times in a row manually

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

What is a simulation and why is it important?

A

Simulations are models of the real world that allow the user to investigate hypotheses and draw conclusions by inputting various sets of data or values to demonstrate the changing state of a phenomenon.
-Simulations allow us to test solutions or run experiments in a way that is usually cheaper, safer, and often times faster.

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

algorithm

A

finite set of instructions that accomplish a specific task.

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

what is the definition of a traversal?

A

the process of accessing each item in a list one at a time

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

how do lists relate to abstraction?

A

they manage complexity in programs by giving a collection of data a name without referencing the specific details of the representation.

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

what is the definition of a loop?

A

change the sequential flow of control by repeating a set of statements zero or
more times, until a stopping condition is met

17
Q

what is another term for a loop?

A

iteration statement

18
Q

what is a substrsing?

A

a part of an existing string

19
Q
A