Unit 6 plus HL Flashcards
(20 cards)
What is A collection
An ADT that hols elements of the same or different data type
Characteristics of a collection
Resizeable
has a set of methods that can be called on
stores multiple data of different types
only accessed sequentially
can have objects
What is a sub program
a small program with computer instructions within a larger program its purpose is to perform a specific task, this task may be used more than once in the main program
advantages of using sub program
breaks complex programming jobs into simpler jobs
distrubuting a large programming problem among various programmers
enables code reuse
improving maintainability and tracability
reducing programming code duplication
advantages of using a collection
reusability
modularity
reliability
what is code reuse
it is very useful as it allows programmers to take advantage of existing code to speed up their task
what are fundamental operations
the basic operations a computer performs(add compare retrieve store)
compound operations
a combination of fundamental operations
what is concurrent thinking
executing different instructions simultaneously by multiple processors
what is concurrent
something that happens at the same time as something else
pros and cons of concurrent thinking
better planning and coordination of resoureces
example is access to database by several users
what is a stack
an adt that stores elements in a particular order and only allows access to the last item inserted
what are the methods of a stack
push: pushes an item onto the stack
pop: returns and removes the last item inserted on the stack
isempty: checks if the stack is empty
size: checks the size of the stack
peek returns but does not remove teh item from the stack
characterists of a stack
last in first out
restricted access
applicaitons of stacks
undo button
tower of hanoi
reversing a word
what is a queue
an adt that stores elements in a particular order and only allows access to the front of the queue and the first item inserted
methods of a queue
enqueue, puts an item in the back of the queue
dequeue, removes the first item inserted in the queue
isempty, checks if the queue is empty
size, checks the size of the queue
peek, returns but does not remove the first item in teh queue
characteristics of a queue
restricted access
first in first out
applications of a queue
printing tasks
keyboard input
Explain the use of a one-dimensional array as a static stack. Your answer should include brief outlines of the push and pop operations and the tests for empty and full stacks.
An array A of N elements should be initialized,
keep track of the top of the stack since not all of the array holds stack elements (in an integer variable, for example, named TOP);
the main property of a stack is that stack values/objects go on and come off of the one end of the stack (LIFO data structure);
Push
Places a value (object) on the top of the stack;
Increase TOP by one and set A[TOP]= value;
Pop
Returns a value from the top of the stack and removes that value from the top of the stack;
Returns A[TOP] and decreases TOP by 1;
IsEmpty
Reports whether the stack is empty or not / returns True if the stack is empty, False otherwise;
Returns True if TOP is less than 0, False otherwise;
IsFull
Reports whether the stack is full or not/ returns True is stack is full, False otherwise;
Returns True if TOP is greater than N-1 (where N is size of the array), False otherwise;