Professional Documents
Culture Documents
In __________________ search start at the beginning of the list and check every
element in the list.
*linear search
4. The preorder traversal sequence of a binary search tree is 29, 18, 10, 15, 23,
21, 37, 35, 45. Which one of the following is the postorder traversal sequence of
the same tree?
Answers
1. 10, 18, 15, 21, 23, 35, 45, 37, 29
2. 15, 10, 23, 21, 18, 45, 35, 37, 29
3. 15, 18, 10, 21, 23, 45, 35, 37, 29
*4. 15, 10, 21, 23, 18, 35, 45, 37, 29
5. How do you count the number of elements in the circular linked list?
Answers
1. int count(struct node *head) { int total = 0; struct node *current =
head; do { current = current->next; total++; } while
(current != NULL); return total; }
*2. int count(struct node *head) { int total = 0; struct node *current =
head; do { current = current->next; total++; } while
(current != head); return total; }
3. int count(struct node *head) { int total = 0; struct node *current =
head; do { current = current->next; total++; } while
(current != head && temp != null); return total; }
4. int count(struct node *head) { int total = 0; struct node *current =
head; do { current = current->next; total++; } while
(current < head); return total; }
7. Which of the following statements is not true about Singly circular linked list?
Answers
*1. Time complexity to searching an element is o(1).
2. Every node in circular is successor.
3. Time complexity to inserting new node at the head in list is o(n).
4. Time complexity to deleting the last node is o(n).
8. The difference between stacks and queues is in ______________________.
Answers
*1. removing elements
2. adding elements at first position
3. inserting elements at given position
4. removing elements from given position
13. what does the following function do for a given linked list with with first
node as head?
void function(struct node* head)
{
if(head == NULL)
return;
function(head -> next);
printf("%d", head-> data);
}
Answers
1. prints alternate node of linked list
2. prints alternate nodes in reverse order
3. prints only even places nodes values
*4. prints all nodes of linked list in reverse order
14._____________ are those structures that have one or more pointers which point to
the same type of structure, as their member.
Answers
*1. Self Referential structures
2. Circulre structures
3. Data structures
4. Pointer structures
15. Which of the following is/are not the advantages of Linked List over an array?
1-The size of a linked list can be incremented at runtime which is impossible in
the case of the array.
2-The List is not required to be contiguously present in the main memory, if the
contiguous space is not available, the nodes can be stored anywhere in the memory
connected through the links.
3-The number of elements in the linked list are limited to the available memory
space while the number of elements in the array is limited to the size of an array.
Answers
1. 1,2
2. 1
3. 1,2,3
*4. none of above
Answers
1. release(tmp)
*2. free(tmp);
3. create(tmp)
4. insert(tmp)