Strings
Pointers
Linked Lists
Binary Trees
100

What function is used to copy one string to another?

strcpy(), strncpy()

100

What operator is used to access the value at a memory address?

* (dereferencing)

100

What are the necessary parts of a singly linked list node?

Some data and a next pointer

100

What are the necessary parts of a singly linked list node?

comparable data, left and right pointers

200

What preprocessor directive is necessary to use strlen()?

#include <string.h>

200

What is the difference between the following lines?

int *p;

int* p;

No difference

200

How do you dynamically allocate a node in C?

struct Node *newNode = malloc(sizeof(struct Node));

200

What is the base case for recursive tree traversal?

If the node is NULL, return

300

What's wrong with this line?

strcpy(dest, "Hello", 5);

strcpy() only takes in 2 arguments,

strncpy() should be used instead

300

What does **&p evaluate to given the following lines?

int a = 10;

int *p = &a;

10

300

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

300

What’s the difference between inorder and preorder traversal?

Inorder: Left → Root → Right; Preorder: Root → Left → Right

400

What does strcat() do?

Concatenates two strings

400
What is the function pointer to the following function:

char *copy(char *stringToCopy)

char *(*fPtr)(char *)

400

How do you detect the end of a singly linked list?

node->next is NULL

400

How can you calculate the height of a binary tree recursively?

Max of left/right subtree height + 1

500

How do you safely copy a string using strncpy()?

strncpy(dest, src, strlen(src) - 1);

dest[strlen(src) - 1] = '\0';

500

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

500

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 variable
500

What is the big O of inserting a node into a binary tree?

O(n)

M
e
n
u