What is the difference between a singly and a doubly linked list?
A singly linked list stores each piece of data with a pointer to the next item (so can only be traversed in one direction), a doubly linked list also stores the pointer to the previous item (so it can be traversed in both directions)
What are the advantages of a linked list over an array?
What are the disadvantages of a linked list over an array?
What is the definition of an object?
An instance of a class with instance variables and methods
What is the definition of properties and methods?
Class variables and procedures/functions respectively
What is the definition of a class?
A template to create an object with class attributes and methods
What is the definition of a sub-class?
A class that inherits its attributes and methods from its super-class
What is the definition of encapsulation?
When information is hidden from some objects to allow for public and private variables
What is the definition of inheritance?
When a sub-class derives its variables and methods from its super-class
What is the definition of instantiation?
Creating an instance of the class
What is the definition of polymorphism?
When a sub-class redefines an inherited attribute or method
What are the steps for a binary search?
What are the requirements for a binary search?
All data must be sorted
What are the steps for an insertion sort?
What are the steps for a bubble sort?
-Declare a variable n to be the length of the array
-Declare a Boolean swapped variable to be true
-Start a conditional loop while swapped is true and n >= 0
-Set swapped to false
-Start an unconditional loop from 0 to n-2
- If the item at the current index is greater than the item at the next index then
- Set a temporary variable to the currently indexed item
- Set the currently indexed item to the value at the next index
- Set the item at the next index to the temporary variable
-Set swapped to true
-Outside of the unconditional loop, deincrement n
What are the three sections in the boxes representing each class on a UML class diagram?
Class name, attributes (with - or + to represent private or public, name of attribute, and attribute type), and methods (- or +, includes constructor, getters, and setters)
How is inheritance shown on a UML class diagram?
An arrow from the subclass to the superclass
How would polymorphism be shown on a UML class diagram?
The method/attribute from the superclass would be included in a subclass, showing that it is being changed not just inherited
What are the steps to insert a new node into a singly linked list?
A new node is created somewhere in memory, the list is traversed until the required node to be updated is found, the pointer for this node is changed, then the pointer is set for the new node (if it is at the end, pointer is set to null)
What are the steps to delete an item in a singly linked list?
The memory location where the node is stored is freed up, the list is traversed to find the previous node, the pointer is updated to be the memory location of the node after the deleted item
When are structure diagrams created?
As part of the top down analysis (breaking a problem down into smaller subproblems in order to make it easier to build a solution) of a software specification
How is a process represented in a structure diagram?
A rectangle
How is a loop represented in a structure diagram?
A box with rounded edges (or ellipse)
How is a selection (if statement) represented in a structure diagram?
A hexagon