Search
Create
Log in
Sign up
Log in
Sign up
Computer Science Praxis - 125 Terms
STUDY
Flashcards
Learn
Write
Spell
Test
PLAY
Match
Gravity
Terms in this set (132)
Parts of a loop
Start, Check, Action, Step
Types of Loops
for, while, do while
What type of loop requires a post condition?
Do While
While loop definition
Pretest loop that starts and repeats while a condition is true; ends when false
What is the output for a while loop:
int x <- 1
while (x <=3)
print x;
x<-x+1
end while
1
2
3
For Loop definition
Repeat/check
What is the structure of a For Loop?
for (condition; true; false}
{
code here
}
What is the output of this for loop?
for (int value=0; value<=7; value++){
system.out.println(value);
}
0
1
2
3
4
5
6
7
What is the output of this For loop?
for (int i=1; i<=5; i++){
system.out.print(i+ ' ");
}
1 2 3 4 5
What type of loop always runs AT LEAST once?
Do While
What is the structure of a do while loop?
int x<-some number
do {set value
do some code
} while (condition)
What is the output of this do while loop?
int x<- 100
do {x<-x/2
print 5 * x
} while (x>0)
250 125 60 30 15 5 0
What is the output of this do while loop?
int i = 0;
int n = 7;
do {
system.out.print("*);
i++;
} while (i<n);
System.out.print(n);
*******
Area 51 number 14
for (int i=1; i<= 500; i++)
Area 51 number 17
Do while
Area 51 #19
6
Area 51 #20
nothing prints
Area 51 #22
once
Area 51 #23
Do While
Area 51 #24
infinite loop
Area 51 #25
-90
Which is better, a loop or recursion?
Recursion is more memory efficient but there are things recursion can do that loops cannot. Use a loop when you can.
What are the characteristics of an array?
All entries must be the same data type, of a fixed size, index based
What is a single dimension array?
a weekly pill box
What is a multi-dimensional array?
stacked coke crates
Start of an array index? (What is the first number?)
0
Consider the following array called beads:
8 6 7 4 3 0 9
what is beads[3]?
4
Consider the following array called beads:
8 6 7 4 3 0 9
What is beads.length?
7
Consider this line of code:
int [ ] list <- new int [4]
What is the name of this thing?
list
Consider this line of code:
int [ ] list <- new int [4]
What does list[0]<-6 mean?
Put a 6 in the first box, index 0.
What does this yield?
int [i] list<-{1,2,-3,4}
An array of length 4 that looks like this:
1 2 -3 4
Consider this line of code:
int [i] nums = {8,6,7,5,3,0,9}
for (int i=0; i<nums.length-1;i++){
system.out.print(nums[i]);
What is the output?
8 6 7 5 3 0
Define Stack
Data can only be added or removed from the top
What is PUSH in a stack?
Add a value to the top
What is POP in a stack?
Remove the top element
What is PEEK in a stack?
Look at the top element
Let s be a Stack.
s.push(1)
s.push(3)
s.peek()
s.pop()
what is the output of the last line?
1
Let s be a Stack. What does this code yield?
s.push(2);
s.push(4);
s.push(6);
print s.pop();
print s.peek();
The stack is
4
2
The last line yields 4
Trace the code:
Stack s<- new Stack();
s.push(3);
s.push(2);
s.push(5);
Print s.push(pop()*peek());
Print s.push(pop()*pop());
20
3
What describes a Stack operator?
LIFO (Last in, first out)
What is a queue?
collection of data kept in the order it was collected. You can only add from the back and remove from the front (line at BestBuy)
What describes a queue operator?
FIFO (First in, first out)
What is a head and tail of a queue?
head-what is removed; tail-what is added
Trace the code
Queue q=new
LinkedList();
q.add(1)
q.add(2)
q.add(3)
q.remove()
2 3
Trace the code
q.add(5);
q.add(6);
q.remove();
q.add(7);
6 7
Trace through the code:
Stack s<-new Stack()
Stack q<-new Stack()
s.push(7);
q.push(3);
s.push(s.peek()*2);
s.push(s.pop()+s.peek();
q.peek()
print s.pop()
print q.pop()
21
3
Area 51 #34
3
Area 51 #35
LIFO
Area 51 #36
3
Area 51 #37
when you need to
Area 51 #38
3
Area 51 #39
16
Area 51 #40
7
Area 51 #41
Stack (LIFO)
Area 51 #42
Queue (FIFO)
Area 51 #43
pop
Area 51 #44
peek
Area 51 #26
10 20 30 40 50
Area 51 #27
6
Area 51 #28
array
What is a linear search?
uses a loop process to search for the target; starts at front then proceeds one term at a time; stop at target or when hit the end
What is a binary search?
List must be in order; looks in middle; goes left if lower and right if greater
What is the pre condition of a binary search?
The numbers must be in order
What is a bubble sort?
Compares two; switches places
What is an insertion sort?
places each element in the right place one at a time
What is a selection sort?
King, queen jack; finds the best value for each
What is a merge sort?
divide by 2, pass off; continue until 1
pass back in order; very efficient
Big "O" Notation
Describes the performance or complexity of an algorithm - based on number of operations (growth of n). Describes the worst-case scenario.
O(1)
"Constant time" - fastest, instant access regardless of size (array)
O(n^2)
"Quadratic time" - performance is directly proportional to the square of the size of the input data set (nested): Selection Sort.
O(log n)
"Log time" - divides sets in half: Binary Search
O(n log n)
Fastest sorting algorithm - unsorted (log n) and proportional to the number of elements (n): Quick Sort (pivot), Merge Sort.
What is DHCP?
Process that assigns IP addresses
Primary storage?
RAM
Secondary storage?
hard drive
What is a worm?
sends copies without attachments
What is SMTP?
send and receive email
what is pass by value?
Like a google copy; the original DOES NOT CHANGE
Trace code
procedure calc (pass by value int x; PBV int y)
x<- x * 2
y<- y + 3
t<-x
x<-y
y<-t
print x
print y
end proc
int a<-5
int b<-4
calc (a,b)
print a
print b
5 4
What is pass by reference?
An object points to an object in memory; someone viewing a shared google doc
Trace the code
x<-x*2
y<-y+3
t<-x
x<-y
y<-t
print x
print y
a<-5
b<-4
print a
print b
7 10 7 10
Area 51 #45
-1
Area 51 #46
2 2 7 2
Area 51 #47
4 7
Trace the code
proc calc (PBV int w), PBV int x, PBR int y, PBR int z)
w<-w+1
x<-x*2
y<-y+3
z<-z*4
int a<-5
int b<-6
calc (a,a,b,b)
print a
print b
5 36
The best way to use a library of code is to:
access the methods (functions) in the interface
What are the two parts of recursion?
terminate base case and recursive case
What is the result of the code below?
void h(int n) h(16)
if (n>=4)
h(n/2)
end if
print n
end h
2
4
8
16
area 51 #49
7
Area 51 #50
3
Area 51 #51
13
Which runs slower, RAM or hard drive?
hard drive
What does email stand for?
electronic mail
Name a graphics format
jpg, gif, bmp, png, tiff, etc.
What connector has 15 pins and connects monitor to tower? (old school)
VGA
Name two document formats
doc, rtf
What is an IP address format?
four places, separated by dots, all between 0 and 255.
Parts of a computer are connected by
buses
students that learn through physically doing
tactile or kinesthetic
students that learn by watching or taking notes
visual
an example of pair programming
one observes, the other codes
when you start a computer, what runs first?
BIOS
BIOS stands for:
basic input output system
free trial software is called
shareware
How can you ensure that an email sent to a colleague stays private?
share on a school server where a password is required
What is an unformatted text editor extension?
TXT
Absolute reference is noted by a:
$
What is software that is burned into the image?
firmware
What does SMTP (send mail to people) really stand for?
simple message transfer protocol
What hampers blind readers using ereaders?
ereaders cannot read symbols or pictures
In a standard database, one row stands for:
a record
How do you connect a digital camera to a computer? (old school)
USB
USB stands for:
universal serial bus
Name the steps in a development cycle.
Analysis, design, Implement, Test, Maintain
Development Models
Waterfall, Incremental, Agile, Spiral, Chaos
Name three design types in development cycle.
top-down, bottom-up, object-oriented
What is object-oriented design?
Contains modules, or pieces, that you create that link together.
Waterfall Method
Development flows in a linear downward direction through the SDLC phases - linear, requirements-heavy, low risk, rigid
Incremental Method
Divided into various builds / development cycles - more flexible, risk-tolerant, cyclical.
Spiral Model
The project is carried out as a series of complete loops that go through most of the SDLC (except maintenance). Each loop produces a 'prototype' of some aspect of the system - high risk.
draw a binary tree from the numbers 8,6,7,5,3,9,12
What is a childless node called?
a leaf
What distinguishes the root from other nodes?
It has children but no parents.
Consider this binary tree. What is the root?
Node Left Child Right Child
5 none none
6 5 3
3 none none
8 6 7
7 none none
8
What is Backnus Naur form?
A formal notation to describe the syntax of a given language. ::= means "is defined as." | is or.
Chaos Method
Unify the best programming methodologies with the best project management techniques - to identify pertinent issues and "always resolve the most important issue first". Characteristics include: pattern-switching and logic gates.
Agile Method
Incremental approach breaks complex projects down into simpler mini-projects: change-tolerant, incremental value, SCRUM.
O(n)
"Linear time" - proportional to the number of operations: Simple Search
O(n!)
"Factorial time" - increases proportionally to the sum of all numbers: Brute Force, Traveling Salesman problem
Big "O" Notation Hierarchy
O(1), O(log n), O(n), O(n log n), O(n^2), O(n!)
Binary Search Tree
Data structure possessing one root node with each node having <= 2 child nodes (left, right). Ordering Property: Left node < root node < all right nodes. Best Case: O(log n), Worst Case: O(n) (unbalanced).
Hash Table
Key-Value lookup
;