What is the data structure used in the following code?


class Node {
Object data;
Node next;
}

void algo(Node node1, Node node2){

Node temp = node1.next;
node1 = node2;
node2.next = temp;
}

a. Single-linked list
b. Double-linked list
c. Binary search tree
d. Priority queue


a. Single-linked list
There is a single link to the next node. In the function, the node is being inserted at the head of the list.

Computer Science & Information Technology

You might also like to view...

What objects would you encounter in going to a movie?

What will be an ideal response?

Computer Science & Information Technology

The ________ is designed to reduce the time spent performing disk I/O operations.

a) slab cache b) page cache c) slab allocator d) zone allocator

Computer Science & Information Technology

What are the five altitude metaphors for describing use case on different levels? What do they represent?

What will be an ideal response?

Computer Science & Information Technology

________ is when your computer transfers files from the hard disk to RAM and back

A) Reading B) Swapping C) Paging D) Progressing

Computer Science & Information Technology