Quiz 3 Flashcards

1
Q

In a linked list:

What components do you need for the print function?

A
  • Create a pointer to root
  • Check if the pointer is null
  • Check if next is NULL, print
  • loop until null and print pointer while setting pointer to next
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In a linked list:

What components do you need in a add function?

A
  • Set the an object pointer to the parameter (e.g. newnode)
  • Set newnode’s next to NULL
  • Create pointer to root
  • Check if root is null else
  • Iterate until en of list and set root to new node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In a linked list:

What components do you need in a delete function?

A
  • Create pointer to root
  • Check if root is null
  • Check if next is null
  • Create temp node set to to the pointer
    else {
    mynode* tmp= 0;
while (ptr->GetNext() != NULL{
tmp= ptr;
ptr= ptr->GetNext();}
delete ptr;
tmp->SetNext(NULL);
return;}}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In a linked list:

What components do you need in a length function?

A
  • Pointer to root
  • Check if null
  • Check if next is null
  • Iterate until the end
  • Increment counter
How well did you know this?
1
Not at all
2
3
4
5
Perfectly