Which of these is an application of linked lists 1 point?

Applications of linked list data structure

A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements in a linked list are linked using pointers as shown in the below image:

Which of these is an application of linked lists 1 point?

Applications of linked list in computer science

  1. Implementation of stacks and queues
  2. Implementation of graphs : Adjacency list representation of graphs is most popular which is uses linked list to store adjacent vertices.
  3. Dynamic memory allocation : We use linked list of free blocks.
  4. Maintaining directory of names
  5. Performing arithmetic operations on long integers
  6. Manipulation of polynomials by storing constants in the node of linked list
  7. representing sparse matrices

Applications of linked list in real world-

  1. Image viewer – Previous and next images are linked, hence can be accessed by next and previous button.
  2. Previous and next page in web browser – We can access previous and next url searched in web browser by pressing back and next button since, they are linked as linked list.
  3. Music Player – Songs in music player are linked to previous and next song. you can play songs either from starting or ending of the list.

Applications of Circular Linked Lists:

  1. Useful for implementation of queue. Unlike this implementation, we don’t need to maintain two pointers for front and rear if we use circular linked list. We can maintain a pointer to the last inserted node and front can always be obtained as next of last.
  2. Circular lists are useful in applications to repeatedly go around the list. For example, when multiple applications are running on a PC, it is common for the operating system to put the running applications on a list and then to cycle through them, giving each of them a slice of time to execute, and then making them wait while the CPU is given to another application. It is convenient for the operating system to use a circular list so that when it reaches the end of the list it can cycle around to the front of the list.
  3. Circular Doubly Linked Lists are used for implementation of advanced data structures like Fibonacci Heap.

An example problem:

Design a data structure that supports following operations efficiently.

  1. getMin : Gets minimum
  2. extractMin : Removes minimum
  3. getMax : Gets maximum
  4. extractMax : Removes maximum
  5. insert : Inserts an item. It may be assumed that the inserted item is always greater than maximum so far. For example, a valid insertion order is 10, 12, 13, 20, 50.

Doubly linked list is the best solution here. We maintain head and tail pointers, since inserted item is always greatest, we insert at tail. Deleting an item from head or tail can be done in O(1) time. So all operations take O(1) time.

Recent Articles on Linked List

Which of these is an application of linked lists 1 point?

Article Tags :
CS - Placements
Linked List
doubly linked list
Practice Tags :
Linked List

Data Structure MCQ - Linked List

This section focuses on the "Linked List" of the Data Structure. These Multiple Choice Questions (mcq) should be practiced to improve the Data Structure skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. 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); }

A. Prints all nodes of linked lists
B. Prints all nodes of linked list in reverse order
C. Prints alternate nodes of Linked List
D. Prints alternate nodes in reverse order

View Answer

Ans : B

Explanation: fun1() prints the given Linked List in reverse manner. For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1.


2. A linear collection of data elements where the linear node is given by means of pointer is called?

A. linked list
B. node list
C. primitive list
D. None of these

View Answer

Ans : A

Explanation: A linear collection of data elements where the linear node is given by means of pointer is called linked list.


3. What is the time complexity to count the number of elements in the linked list?

A. O(1)
B. O(n)
C. O(logn)
D. None of the mentioned

View Answer

Ans : B

Explanation: To count the number of elements, you have to traverse through the entire list, hence complexity is O(n).


4. What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?

A. O(1)
B. O(n)
C. θ (n)
D. θ (1)

View Answer

Ans : C

Explanation: No Explanation.


5. What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6

void fun(struct node* start) { if(start == NULL) return; printf("%d ", start->data); if(start->next != NULL ) fun(start->next->next); printf("%d ", start->data); }

A. 1 4 6 6 4 1
B. 1 3 5 1 3 5
C. 1 2 3 5
D. 1 3 5 5 3 1

View Answer

Ans : D

Explanation:fun() prints alternate nodes of the given Linked List, first from head to end, and then from end to head. If Linked List has even number of nodes, then skips the last node.


6. What is the functionality of the following piece of code?

public int function(int data) { Node temp = head; int var = 0; while(temp != null) { if(temp.getData() == data) { return var; } var = var+1; temp = temp.getNext(); } return Integer.MIN_VALUE; }

A. Find and delete a given element in the list
B. Find and return the given element in the list
C. Find and return the position of the given element in the list
D. Find and insert a new element in the list

View Answer

Ans : C

Explanation: When temp is equal to data, the position of data is returned.


7. Linked lists are not suitable to for the implementation of?

A. Insertion sort
B. Radix sort
C. Polynomial manipulation
D. Binary search

View Answer

Ans : D

Explanation: Linked lists are not suitable to for the implementation of Binary search.


8. In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

A. log 2 n
B. n/2
C. log 2 n – 1
D. n

View Answer

Ans : D

Explanation: In the worst case, the element to be searched has to be compared with all elements of linked list.


9. Which of these is an application of linked lists?

A. To implement file systems
B. For separate chaining in hash-tables
C. To implement non-binary trees
D. All of the mentioned

View Answer

Ans : D

Explanation: Linked lists can be used to implement all of the above mentioned applications.


10. In circular linked list, insertion of node requires modification of?

A. One pointer
B. Two pointer
C. Three pointer
D. None

View Answer

Ans : B

Explanation: In circular linked list, insertion of node requires modification of Two pointer.


Next »




Also Check :

  • Smalltalk Tutorials
  • Sed Tutorials

Discussion


* You must be logged in to add comment.

What is the application of linked list Why?

Applications of Linked Lists

Linked lists are used to implement stacks, queues, graphs, etc. Linked lists let you insert elements at the beginning and end of the list. In Linked Lists we don't need to know the size in advance.

Which of these is not a application of linked list?

Which of these is not an application of a linked list? Explanation: To implement file system, for separate chaining in hash-tables and to implement non-binary trees linked lists are used. Elements are accessed sequentially in linked list. Random access of elements is not an applications of linked list.