SDD Flashcards

1
Q

What is the difference between a singly and a doubly linked list?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the advantages of a linked list over an array?

A
  • More dynamic (easier to add and remove items, length not fixed)
  • To insert or delete items only pointers need to be changed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the disadvantages of a linked list over an array?

A
  • List needs to be traversed to reach a required item (can’t be indexed)
  • Takes up more memory to store pointers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the definition of an object?

A

An instance of a class with instance variables and methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the definition of properties and methods?

A

Class variables and procedures/functions respectively

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the definition of a class?

A

A template to create an object with class attributes and methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the definition of a sub-class?

A

A class that inherits its attributes and methods from its super-class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the definition of encapsulation?

A

When information is hidden from some objects to allow for public and private variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the definition of inheritance?

A

When a sub-class derives its variables and methods from its super-class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the definition of instantiation?

A

Creating an instance of the class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the definition of polymorphism?

A

When a sub-class redefines an inherited attribute or method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the steps for a binary search?

A
  • Set the minimum to the first index (0) and the maximum to the last (length of array - 1)
  • Start a conditional loop that runs while min <= max
  • Set the middle index to (min + max) / 2
  • If the item at the middle index is greater than the target then set max to mid - 1
  • If the item at the middle index is smaller than the target then set min to mid + 1
  • Otherwise, return the middle index (or the item at the middle index)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the requirements for a binary search?

A

All data must be sorted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the steps for an insertion sort?

A
  • Start an unconditional loop from index 1 to the index of the last list item
  • Store the value of the currently indexed item
  • Store a temporary copy of the current index (so that it can be modified)
  • Start a conditional loop that runs while the temporary index is greater than 0 and the item at the temporary index is greater than the current item
  • Set the item at the temporary index to the item at the index before
  • Subtract one from the temporary index
  • Outside of the conditional loop, set the item at the temporary index to the current item
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the steps for a bubble sort?

A

-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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the three sections in the boxes representing each class on a UML class diagram?

A

Class name, attributes (with - or + to represent private or public, name of attribute, and attribute type), and methods (- or +, includes constructor, getters, and setters)

17
Q

How is inheritance shown on a UML class diagram?

A

An arrow from the subclass to the superclass

18
Q

How would polymorphism be shown on a UML class diagram?

A

The method/attribute from the superclass would be included in a subclass, showing that it is being changed not just inherited

19
Q

What are the steps to insert a new node into a singly linked list?

A

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)

20
Q

What are the steps to delete an item in a singly linked list?

A

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

21
Q

When are structure diagrams created?

A

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

22
Q

How is a process represented in a structure diagram?

A

A rectangle

23
Q

How is a loop represented in a structure diagram?

A

A box with rounded edges (or ellipse)

24
Q

How is a selection (if statement) represented in a structure diagram?

A

A hexagon

25
Q

How is a predefined function/procedure represented in a structure diagram?

A

A rectangle with double sides on the side (and single on the top and bottom)

26
Q

How is top level design used?

A

By developing a top level algorithm and then developing refinements for each module

27
Q

How is data flow shown on a structure diagram?

A

Using input and output arrows labelled with variable names to show the parameters passed in and out

28
Q

What is the purpose of a UML class diagram?

A

To give a quick overview of a system, describing its structure by showing its classes, variables, structures and types, methods of the classes, and relationships between the classes to model the static aspect of the system

29
Q

What is on a UML class diagram?

A

A box for each class, one cell in the box has the class name, a cell below has instance variables with their data type and encapsulation (e.g. -address: String is private, +bedrooms: Integer is public, -scores: Array of Score[] would be an array of objects when Score is another class), the bottom cell has methods including a constructor and getters and setters with a note of whether each is public or private (+-), inheritance between classes shown by an arrow from the subclass to the superclass, polymorphism would be shown by including a method/attribute from a superclass in a subclass

30
Q

What is the purpose of testing software?

A

Not to prove the absence of errors but to systematically eliminate the possibility of leaving errors unfound

31
Q

What is component testing?

A

Testing the individual modules of code within a program to ensure the smallest testable units function, it can take place during development

32
Q

When are stubs and drivers used?

A

To test partially completed code

33
Q

When are stubs used?

A

In top-down testing to simulate uncompleted sub-modules while testing the major module

34
Q

When are drivers used?

A

In bottom-up testing to call the sub-modules and display their output when the major module is uncompleted

35
Q

What are the steps for component testing?

A

Planning - how will it be carried out, will it use drivers/stubs, what does successful completion look like
Test data - including test cases, what inputs and what outputs from there
Execute test - follow the plan and use the test data
Record results - to compare actual output with expected output
Check for completion - if they don’t match then identify why not and repeat testing after making modifications, if they do then testing is complete