# Data structure/Data Structure Questions and Answers ��� Singly Linked Sample Test,Sample questions

1.O(1)

2.O(n)

3.O(n2)

4.O(n3)

2. Node list

3.Primitive list

4.Unordered list

## Question: ``` Consider the following definition in c programming language. struct node { int data; struct node * next; } typedef struct node NODE; NODE *ptr; Which of the following c code is used to create new node? ```

1. ptr = (NODE*)malloc(sizeof(NODE));

2.ptr = (NODE*)malloc(NODE);

3.ptr = (NODE*)malloc(sizeof(NODE*));

4.ptr = (NODE)malloc(sizeof(NODE));

## Question: ``` Which of the following points is/are not true about Linked List data structure when it is compared with an array? ```

1.Arrays have better cache locality that can make them better in terms of performance

2.It is easy to insert and delete elements in Linked List

3.Random access is not allowed in a typical implementation of Linked Lists

4.Access of elements in linked list takes less time than compared to arrays

## Question: ``` You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list? ```

1.Delete the first element

2. Insert a new element as a first element

3. Delete the last element of the list

4. Add a new element at the end of the list

1.I and II

2.I and III

3.I, II and III

4.I, II and IV

## Question: ```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? ```

1.Possible if X is not last node

2. Possible if size of linked list is eve

3. Possible if size of linked list is odd

4. Possible if X is not first node

1.Data

4.Node

1.log 2 n

2.n?2

3.log 2 n � 1

4.n

## Question: ```Linked list data structure offers considerable saving in _____________ ```

1.Computational Time

2.Space Utilization

3.Space Utilization and Computational Time

4.Speed Utilization

## Question: ```The concatenation of two lists can be performed in O(1) time. Which of the following variation of the linked list can be used? ```

4.Array implementation of list

## Question: ```What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head == NULL) return; fun1(head->next); printf("%d ", head->data); } ```

1.Prints all nodes of linked lists

2.Prints all nodes of linked list in reverse order

3.Prints alternate nodes of Linked List

4.Prints alternate nodes in reverse order

## Question: ```What is the space complexity for deleting a linked list? ```

1.O(1)

2.O(n)

3.Either O(1) or O(n)

4.O(logn)

## Question: ```What is the time complexity of inserting at the end in dynamic arrays? ```

1.O(1)

2.O(n)

3.O(logn)

4.Either O(1) or O(n)

1.O(1)

2.O(n)

3.O(logn)

4.O(n2)

1.O(1)

2.O(n)

3.?(n)

4.?(1)

1.O(1)

2.O(n)

3.O(n2)

4.O(n4)

1.O(1)

2.O(n)

3.O(n2)

4.O(n3)

## Question: ```Which of the following is not a disadvantage to the usage of array? ```

1.Fixed size

2. There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size

3. Insertion based on position

4. Accessing elements at specified positions

## Question: ```Which of these is not an application of a linked list? ```

1.To implement file systems

2.For separate chaining in hash-tables

3.To implement non-binary trees

4.Random Access of elements

## More MCQS

##### R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!