Menu

Question Discussion & Solution

MCQ
Q.
What would be the asymptotic time complexity to add an element in the linked list?

forum Community Discussion

speaker_notes_off

No discussions yet. Be the first to start!

You must be logged in to participate in the discussion.

login Login to Discuss

auto_awesome Similar Questions

MCQ
1.
Linked list is considered as an example of ___________ type of memory allocation.
forum Discussion
MCQ
2.
What is the time complexity to count the number of elements in the linked list?
forum Discussion
MCQ
3.
Choose the code snippet which inserts a node to the head of the list?

a)

public void insertHead(int data)
{
 Node temp = new Node(data);
 Node cur = head;
 while(cur.getNext() != head)
  cur = cur.getNext()
 if(head == null)
 {
  head = temp;
  head.setNext(head);
 }
 else
 {
  temp.setNext(head);
  head = temp;
  cur.setNext(temp);
 }
 size++;
}

b)

public void insertHead(int data)
{
 Node temp = new Node(data);
 while(cur != head)
  cur = cur.getNext()
 if(head == null)
 {
  head = temp;
  head.setNext(head);
 }
 else
 {
  temp.setNext(head.getNext());
  cur.setNext(temp);
 }
 size++;
}

c)

public void insertHead(int data)
{
 Node temp = new Node(data);
 if(head == null)
 {
  head = temp;
  head.setNext(head);
 }
 else
 {
  temp.setNext(head.getNext());
  head = temp;
 }
 size++;
}

d)

public void insertHead(int data)
{
 Node temp = new Node(data);
 if(head == null)
 {
  head = temp;
  head.setNext(head.getNext());
 }
 else
 {
  temp.setNext(head.getNext());
  head = temp;
 }
 size++;
}
forum Discussion
MCQ
4.
Which of the following piece of code has the functionality of counting the number of elements in the list?
forum Discussion
MCQ
5.
What is the space complexity for deleting a linked list?
forum Discussion

category More Data Structure Topics

article

Data Structure Basics

format_list_bulleted 128 MCQs
article

Abstract data types

format_list_bulleted 37 MCQs
article

Arrays

format_list_bulleted 134 MCQs
article

Lists

format_list_bulleted 166 MCQs
article

Stacks

format_list_bulleted 165 MCQs
article

Queues

format_list_bulleted 61 MCQs
article

Trees

format_list_bulleted 133 MCQs
article

Binary Trees

format_list_bulleted 120 MCQs
article

B Trees

format_list_bulleted 8 MCQs
article

Heaps

format_list_bulleted 36 MCQs
article

Hash based structures

format_list_bulleted 7 MCQs
article

Graphs

format_list_bulleted 157 MCQs
article

Mixed

format_list_bulleted 10 MCQs