What function is used to copy one string to another?
strcpy(), strncpy()
What operator is used to access the value at a memory address?
* (dereferencing)
What are the necessary parts of a singly linked list node?
Some data and a next pointer
What are the necessary parts of a singly linked list node?
comparable data, left and right pointers
What preprocessor directive is necessary to use strlen()?
#include <string.h>
What is the difference between the following lines?
int *p;
int* p;
No difference
How do you dynamically allocate a node in C?
struct Node *newNode = malloc(sizeof(struct Node));
What is the base case for recursive tree traversal?
If the node is NULL, return
What's wrong with this line?
strcpy(dest, "Hello", 5);
strcpy() only takes in 2 arguments,
strncpy() should be used instead
What does **&p evaluate to given the following lines?
int a = 10;
int *p = &a;
10
How do your insert a node at the beginning of a singly linked list?
Allocate a new node, set its next to the head node, update the head variable
What’s the difference between inorder and preorder traversal?
Inorder: Left → Root → Right; Preorder: Root → Left → Right
What does strcat() do?
Concatenates two strings
char *copy(char *stringToCopy)
char *(*fPtr)(char *)
How do you detect the end of a singly linked list?
node->next is NULL
How can you calculate the height of a binary tree recursively?
Max of left/right subtree height + 1
How do you safely copy a string using strncpy()?
strncpy(dest, src, strlen(src) - 1);
dest[strlen(src) - 1] = '\0';
What's the difference between the following lines of code:
const int *a;
int * const a;
The first line has an immutable integer value, the second has an immutable direct (pointer) value
What is the big O of adding to the end of a doubly linked list?
O(n) with no tail variable
O(1) with tail variableWhat is the big O of inserting a node into a binary tree?
O(n)