Exam 2 Flashcards
What is a precondition for a binary search?
The data must be in order
How does linear search work?
compare the first item with the search value
then compare next item with the search value
repeat process until end of array
to repeat process until the search item has been found and stopped
return the array position
What is the difference between passing a parameter by value and by reference?
By reference receives a memory location yet by value receives a copy of the variable
What is one benefit and one drawback of using global variables instead of local?
Can be accessed by any function
More memory used
Describe a feature of IDE’s that can be helped to write and test programs
Write:
Auto complete- can help fill in the rest
Testing:
Breakpoints- can stop the code at times to check values of variables
Why is an integer value used in an array instead of seperate variables
Numbers can be passed in as a single parameter
How can caching be used in a plane simulation?
Store frequently use data in the cache ( quicker memory) such as the weather
What is a difference between a data tree and a graph data structure?
Graphs don’t have a root node
Why is performance modelling used to test a system?
It is more expensive to test a system
How would you create a 2D array for cards?
cards = [][]
Table question:
5-4-3-2-1
5-4-3-2-1
start from bottom then add up all of the numbers 1+2+3+4+5
OOP code add in?
0
-1
-1
pointerValue
returnValue
Pseudocode for program stack?
True
push
false
print
How can an array be used to implement a queue data structure?
Queue has head pointer and tail pointer
When an item is enqueued the tail pointer increments
When an item is dequeued the head pointer increments
Breadth first vs depth first AO1?
Breadth: check top node then visits all nodes connecting to it, then all the nodes connecting to them
Depth: Visits far bottom left node- returns in then checks the one to its right, does all lf them then goes up and across