cce 105 final exam 2 Flashcards
What are data structures?
Sets of associations or relationships (structure) involving combined elements.
What does the stackTop
operation do in a stack ADT?
It returns the topmost element.
When is a stack considered empty?
When the isEmpty()
method returns true.
What does the POP
operation do?
It removes the element currently at the top.
What does the PUSH
operation do?
It inserts an element on top of the most recently inserted data.
What happens when PUSH
is called on a full stack?
Stack overflow occurs.
What is data encapsulation?
Packaging together data values with the operations on those values.
When is the water tank considered empty?
When the water level is zero, and isEmpty()
returns true.
What kind of operation is addWater()
in a water tank ADT?
It is a transformer.
What is the purpose of the ~waterTank()
operation?
It serves as a destructor.
What happens when PUSH
is called on a non-empty, non-full stack?
The new item is inserted and becomes the last element.
What happens after a POP
operation?
The next oldest item becomes the topmost item.
What aspect does ADT emphasize?
The ‘what’ rather than the ‘how’.
What technique does a stack follow?
Last-In, First-Out (LIFO).
What happens if POP
is called on a full stack?
The topmost element is deleted.
What happens if POP
is called on an empty stack?
Stack underflow occurs.
What are the operations involved in an ADT?
Creators, transformers, observers, and input/output.
Which data structures are hierarchical?
General trees and binary trees.
What is a general tree?
A tree with at least three child nodes.
What type of relationship do hierarchical data structures have?
One-to-many.
Which data structures are linear, and which are hierarchical?
Stacks and queues are linear; trees are hierarchical.
What type of elements does an array contain?
Elements of the same type only.
How do you declare a one-dimensional array in Java?
int arr[] = new int[3];
How do you declare a multidimensional array in Java?
int[][] arr;
or int arr[][];