What does the following function do for a given linked list (not empty) with the first node as head?
void fun1(struct node* head) {
if(head == NULL) {
return;
}
fun1(head->next);
cout << head->data << endl;
}
Print all nodes of the linked list
Print all nodes of the linked list in reverse order
Print alternate nodes of the linked list
Print alternate nodes in reverse order
Which of the following is false?
The time complexity for one division is constant.
The time complexity for the Traveling Salesman Problem is O(2n).
The time complexity for one double write is constant.
The time complexity for one integer read is constant.
Which of the following Big O is most desired when designing an algorithm?
O(n^2)
O(logn)
O(1)
O(n logn)
When calculating the Big-O for an algorithm, which of the following rules is not true?
Focus on the dominant term
Disregard any constants
Focus only on polynomials
None of the above
Which of the following scenarios has the worst O(n)?
Swap two integers with the help of using a temporary variable
Search a non-existent value in a degenerate binary tree with n nodes
Create a new node to a BST with n nodes
Execute a loop with 10000 iterations
Which of the following statements is true?
When using iteration and recursion to implement factorial, Big O is the same
When using iteration and recursion to find the Fibonacci sequence, Big O is the same
When using iteration and recursion to print Pascal’s Triangle, Big O is the same
None of the above