Arrays Flashcards
1
Q
memory address
A
the index number of RAM
2
Q
Linked lists
A
- data structures that overcome problems of space by allocating blocks of memory on demand
- work by storing a series of nodes.
- primary operations in a linked list are insert, remove, and get (find)
3
Q
node
A
- unit of memory holding a single item in a linked list
- A node can be allocated from anywhere in the memory, it does not have to be next to the previously allocated node. Hence, linked lists are stored in non-contiguous blocks of memory.
- consists of a value and a pointer to the next node in the sequence
- node class is named with a _ (underscore). The underscore simply indicates that the node class is a private class that should not be accessible by anyone else other than the linked list class.
4
Q
singly linked list
A
- a type of linked list where each node contains one pointer to the next node
5
Q
doubly linked list
A
-where nodes contain a pointer to the previous node in addition to the next
6
Q
head
A
- indicates the beginning of the list.
- The head always contains the 1st node
7
Q
insertion
A
- at the beginning of the list (insertFirst).
- at the end of the list (insertLast).
- anywhere in the list, between 2 nodes (insert, insertAt).
8
Q
insertFirst
A
- Create a new node item
- Point the head to that new node
9
Q
insertLast
A
- Create a new node item
- Check to see if the list is empty, if it is, then insert the new item as the only item in the list
- Start at the beginning of the list and move through the list until you reach the end of the list
- Set the end node’s next pointer to the new node
- The new node’s next pointer is null (indicating that the new node now is the last node on the list)
10
Q
get
A
- traverse the list, comparing the value stored in each node with the value you are searching.
- When the item is found, return the node.
11
Q
removal
A
- delete from the beginning of the list.
- delete from the end of the list.
- delete a node between 2 other nodes.
12
Q
delete 1st
A
if you delete the 1st item in a list, you need to change the head to indicate the new 1st item on the list.
13
Q
end or between
A
you find the node before the node you are removing and update its next pointer to skip over the removed node.