ExamVeda
Login
Home
51
The following C function takes a simply-linked list as an 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. Choose the correct alternative to replace the blank line.
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;
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
52
Which of the following concepts make extensive use of arrays?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
53
Elements in an array are accessed . . . . . . . .
Discuss
Answer & Solution
Answer: Option A
Solution:
Option A: randomly - This means you can go directly to any box (element) in the array by knowing its number (index). Arrays are designed to let you jump straight to an element without looking at the others.

Option B: sequentially - This means you'd have to go through each box one after the other to find the one you want. While you *can* access an array sequentially, it's not how they're designed to be used or the most efficient way.

Option C: exponentially and Option D: logarithmically - These terms don't really relate to how we access elements in an array. These usually relate to more complex algorithms or how things grow in size.
Arrays provide direct access to elements using their index. So, you can get to element number 5 just as quickly as you can get to element number 1. That's why it's called random access.
54
Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time?
I. Insertion at the front of the linked list
II. Insertion at the end of the linked list
III. Deletion of the front node of the linked list
IV. Deletion of the last node of the linked list
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
55
Which of the following array element will return the top-of-the-stack-element for a stack of size N elements(capacity of stack > N)?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
56
What is the need for a circular queue?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
57
Which of these is not an application of a linked list?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
58
Assuming int is of 4bytes, what is the size of int arr[15];?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
59
How do you initialize an array in C?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
60
Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board