Total Ten Questions. Each Carry 2 Marks.
Total Time 20 Minutes.
Quiz Summary
0 of 10 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
Results
Results
0 of 10 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
Categories
- Not categorized 0%
-
If you score less than 16 marks. Please retake the test after a week.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- Current
- Review
- Answered
- Correct
- Incorrect
-
Question 1 of 10
1. Question
1) Consider the C code fragment given below.
typedef struct node { int data; node* next ; } node; void join(node* m, node* n) { node* p = n; while (p->next != NULL) { p = p->next; } p–>next = m; }
Assuming that m and n point to valid NULL- terminated linked lists, invocation of join willCorrectIncorrect -
Question 2 of 10
2. Question
2) Linked lists are not suitable data structures for which one of the following problems?
CorrectIncorrect -
Question 3 of 10
3. Question
3) A circularly linked list is used to represent a Queue. A single variable p is used to access the Queue. To which node should p point such that both the operations enQueue and deQueue can be performed in constant time?
CorrectIncorrect -
Question 4 of 10
4. Question
4) The following C function takes a simply-linked list as input argument.
It modifies the list by moving the last element to the front of the list and returns the modified list.
Some part of the code is left blank.typedef
struct
node
{
int
value;
struct
node *next;
}Node;
Node *move_to_front(Node *head)
{
Node *p, *q;
if
((head== NULL: || (head->next == NULL))
return
head;
q = NULL; p = head;
while
(p->next !=NULL)
{
q = p;
p = p->next;
}
_______________________________
return
head;
}
Choose the correct alternative to replace the blank line.CorrectIncorrect -
Question 5 of 10
5. Question
5)
The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1,2,3,4,5,6,7 in the given order. What will be the contents of the list after the function completes execution?
struct node
{
int value;struct node *next;
};
Void rearrange (struct node *list )
{
struct node *p, * q;
int temp;
if( !list || !list-> next)
return;
p = list; q = list->next;
while (q)
{
temp = p->value;
p-> value = q ->value;
q-> value = temp;
p = q-> next;
q = p ? p->next : 0;
}
}
CorrectIncorrect -
Question 6 of 10
6. Question
6) The below function will reverse the given linked list.
Identify the missing statement at the blank given in function.
Assume variable head pointing to first node of the list.void reverseList()
{
struct node *prevNode, *curNode;
if(head != NULL)
{
prevNode = head;
curNode = head->next;
head = head->next;
prevNode->next = NULL;
while(head != NULL)
{
head = head->next;
curNode->next = prevNode;
prevNode = curNode;
curNode = head;
}
----------------------
}
}
CorrectIncorrect -
Question 7 of 10
7. Question
7) The below delete function will delete a node from the singly linked list.
Assume head variable is takking the first node address of the list.
struct node
{
int data;
struct node *link;
};
void delete(node *x,int p)
{
int i;
for(i=0;i<p;i++,x=x->link);
x->link=x->link->link;
}
The elements in the list after calling the delete(head,3) function?
If the list containing elements 1-2-3-4-5-6-null.CorrectIncorrect -
Question 8 of 10
8. Question
8) What is the functionality of the following code?
public void function(Node node) { if(size == 0) head = node; else { Node temp,cur; for(cur = head; (temp = cur.getNext())!=null; cur = temp); cur.setNext(node); } size++; }CorrectIncorrect -
Question 9 of 10
9. Question
9) Which of the following piece of code has the functionality of counting the number of elements in the list?
CorrectIncorrect -
Question 10 of 10
10. Question
10) What is the functionality of the following piece of code?
public int function(int data) { Node temp = head; int var = 0; while(temp != null) { if(temp.getData() == data) { return var; } var = var+1; temp = temp.getNext(); } return Integer.MIN_VALUE; }CorrectIncorrect