Cs P2 common Flashcards

1
Q

Examples of sorting algorithms

A

Bubble, merge, insertion sort

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

Searching algorithms

A

linear, binary

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

MOD and DIV

A

DIV // whole number
MOD % reminder

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

File handling

A

myfile = open(“nameFile.txt” , “r”)
print(myfile,readlines())
myFile.close()

myfile = open(“asdf.txt” , “w”)
myfile.write(“asdfgrad”)
myfile.close()

myfile = open(“filename.txt” , “a”)
myfile.write(“dfsgsg”)
myfile.close()

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

1D Arrays

A

Store multiple data values like list X[0] to call on the list
[“fdgdfgh” , “dfsdfgg” , “sdfsgyj”]
X.insert(1,”abcdefg”)

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

Subprograms

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

Translators

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

High level low level

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

IDE

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

Bubble sort

A

Compare first two items in list and swap if not in same order do same for 2nd and 3rd and so on until reached end of list called on pass. Keep doing passes until a pass results in no swaps

Simple but inefficient for large lists

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

Insertion sort

A

Compare second item to first item and insert it into the right order then look at 3rd item and insert it into right place and so on until you reach the last item

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

Merge sort

A

uses facts that small lists are easier to sort and sorted lists are easier to merge

More efficient than insertion for larger lists
Same run time no matter complexity of list

Slower for short lists compared to others
Takes the same amount of time if the whole list is sorted

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

What is casting

A

changing data type

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

String manipulation

A

upper(x)
lower(x)
len(x)

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

2D array

A

List of list [ [“pine” , “elm”] , [“asd” , “sdfa”] , [“asfl”, “lepd”]]

Call on them with X[0,1] being elm

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