Which implementation of a list can be used in case of concatenating two lists that is to be performed in O 1?

GATE | GATE CS 1997 | Question 4

The concatenation of two lists is to be performed in O(1) time. Which of the following implementations of a list should be used?
(A) singly linked list
(B) doubly linked list
(C) circular doubly linked list
(D) array implementation of lists

Answer: (C)
Explanation: Singly linked list cannot be answer because we cannot find last element of a singly linked list in O(1) time.

Doubly linked list cannot also not be answer because of the same reason as singly linked list.
Quiz of this Question

Which implementation of a list can be used in case of concatenating two lists that is to be performed in O 1?

Article Tags :
GATE
GATE CS 1997
GATE-GATE CS 1997

Linked Lists in Python: An Introduction

by Pedro Pregueiro intermediate python
Mark as Completed
Tweet Share Email

Table of Contents

Remove ads

Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with the written tutorial to deepen your understanding: Working With Linked Lists in Python

Linked lists are like a lesser-known cousin of lists. They’re not as popular or as cool, and you might not even remember them from your algorithms class. But in the right context, they can really shine.

In this article, you’ll learn:

  • What linked lists are and when you should use them
  • How to use collections.deque for all of your linked list needs
  • How to implement your own linked lists
  • What the other types of linked lists are and what they can be used for

If you’re looking to brush up on your coding skills for a job interview, or if you want to learn more about Python data structures besides the usual dictionaries and lists, then you’ve come to the right place!

You can follow along with the examples in this tutorial by downloading the source code available at the link below:

Get the Source Code: Click here to get the source code you’ll use to learn about linked lists in this tutorial.